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

2020-12-13 14:36

阅读:544

标签: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所在位置

soscw.com,搜素材soscw.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

soscw.com,搜素材soscw.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#中调用

soscw.com,搜素材soscw.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


评论


亲,登录后才可以留言!