首页 > 代码库 > ArcGIS API For Silverlight 中 用户自定义Symbol在C#中调用
ArcGIS API For Silverlight 中 用户自定义Symbol在C#中调用
ArcGIS API For Silverlight 中 用户自定义Symbol在C#中调用
1.创建帮助类,其中,Application.LoadComponent的参数/Tel.Jsyd.FileImport;component/Themes/Symbol.xaml,是自定义Symbol所在位置
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; }}
2.自定义Symbol
<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>
3.C#中调用
if (this.isPlotCurrent) this.Plot.Graphic.Symbol = SymbolHelper.GetCommonSymbol("CurrentProjectSymbol");
ArcGIS API For Silverlight 中 用户自定义Symbol在C#中调用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。