码迷,mamicode.com
首页 > Windows程序 > 详细

ArcGIS API For Silverlight 中 用户自定义Symbol在C#中调用

时间:2014-10-31 11:35:51      阅读:423      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   os   ar   for   sp   

ArcGIS API For Silverlight 中 用户自定义Symbol在C#中调用

1.创建帮助类,其中,Application.LoadComponent的参数/Tel.Jsyd.FileImport;component/Themes/Symbol.xaml,是自定义Symbol所在位置

bubuko.com,布布扣
public class SymbolHelper
    {
        static SymbolHelper()
        {
            ResourceDictionary rd = new ResourceDictionary();
            Application.LoadComponent(rd, new Uri("/Tel.Jsyd.FileImport;component/Themes/Symbol.xaml", UriKind.Relative));
            Application.Current.Resources.MergedDictionaries.Add(rd);
        }

        public static Symbol GetCommonSymbol(string key)
        {
            if (Application.Current.Resources.Contains(key))
            {
                object symbol = Application.Current.Resources[key];
                return symbol as Symbol;
            }
            return null;
        }
}
View Code

 2.自定义Symbol

bubuko.com,布布扣
 <ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esrisb="clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client">

   <esrisb:FillSymbol x:Name="CurrentProjectSymbol" BorderBrush="Green" BorderThickness="2">
        <esrisb:FillSymbol.Fill>
            <SolidColorBrush Color="Green" Opacity="0" />
        </esrisb:FillSymbol.Fill>
    </esrisb:FillSymbol>
    <esrisb:FillSymbol x:Key="CurrentProjectFlickingSymbol">
        <esrisb:FillSymbol.ControlTemplate>
            <ControlTemplate xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows">
                <Grid>
                    <vsm:VisualStateManager.VisualStateGroups>
                        <vsm:VisualStateGroup x:Name="CommonStates">
                            <vsm:VisualState x:Name="MouseOver">
                                <Storyboard>
                                    <DoubleAnimation BeginTime="0" Storyboard.TargetName="Element" Storyboard.TargetProperty="(Shape.Opacity)" To="0.75" Duration="00:00:01" RepeatBehavior="Forever"/>
                                </Storyboard>
                            </vsm:VisualState>
                            <vsm:VisualState x:Name="Normal">
                                <Storyboard>
                                    <DoubleAnimation BeginTime="0" Storyboard.TargetName="Element" Storyboard.TargetProperty="(Shape.Opacity)" To="0.75" Duration="00:00:02" RepeatBehavior="Forever"/>
                                </Storyboard>
                            </vsm:VisualState>
                        </vsm:VisualStateGroup>
                    </vsm:VisualStateManager.VisualStateGroups>
                    <Path x:Name="Element" Fill="Green" Opacity="0.15" Stroke="Green" StrokeThickness="2"></Path>
                </Grid>
            </ControlTemplate>
        </esrisb:FillSymbol.ControlTemplate>
    </esrisb:FillSymbol>
</ResourceDictionary>
View Code

 3.C#中调用

bubuko.com,布布扣
if (this.isPlotCurrent)
                this.Plot.Graphic.Symbol = SymbolHelper.GetCommonSymbol("CurrentProjectSymbol");
View Code

 

ArcGIS API For Silverlight 中 用户自定义Symbol在C#中调用

标签:style   blog   http   io   color   os   ar   for   sp   

原文地址:http://www.cnblogs.com/jmllc/p/4064450.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!