Table of Contents [Hide/Show]
Example - Line Symbol (single-color line) Example - Fill Symbol (diagonal hatch pattern with a border) Example - Default Point Symbol (loads a strobe symbol defined in XAML) Example - Returns the default point symbol Example - Returns the specified symbol with custom fill color Example - Returns the specified symbol with custom fill and stroke colors Example - red hatch fill Example - fill based on a hue shift Example - setting the palette to red Example - shifting the palette for groups of objects Example - drawing geometry with a palette shiftSee Also
public static Symbol GetLineSymbol(Color color) { return new SimpleLineSymbol { Color = new SolidColorBrush(color), Width = 4 }; }
public static Symbol GetFillSymbol(Color[] colors) { SimpleFillSymbol symbol = new SimpleFillSymbol(); symbol.BorderBrush = new SolidColorBrush(colors[0]); symbol.Fill = new LinearGradientBrush(new GradientStopCollection { new GradientStop { Color = colors[1] }, new GradientStop { Color = colors[2], Offset = 0.526 }, new GradientStop { Color = Colors.Transparent, Offset = 0.544 }, new GradientStop { Color = Colors.Transparent, Offset = 1 } }, 0) { EndPoint = new Point(1.5, 1.5), MappingMode = BrushMappingMode.Absolute, SpreadMethod = GradientSpreadMethod.Repeat, StartPoint = new Point(0, 0) }; symbol.BorderThickness = 4; return symbol; }
public static Symbol DefaultPointSymbol { get { return (Symbol)Application.Current.Resources["CustomStrobeMarkerSymbol"]); } }
<esriSymbols:MarkerSymbol x:Name="CustomStrobeMarkerSymbol"> <esriSymbols:MarkerSymbol.ControlTemplate> <ControlTemplate> <Canvas> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="MouseOver"> <Storyboard RepeatBehavior="ForEver"> <DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" From="1" To="10" Duration="00:00:01" /> <DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" From="1" To="10" Duration="00:00:01" /> <DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)" From="1" To="0" Duration="00:00:01" /> </Storyboard> </VisualState> <VisualState x:Name="Normal" /> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Ellipse Height="10" Width="10" Canvas.Left="-5" Canvas.Top="-5" RenderTransformOrigin="0.5,0.5" x:Name="ellipse" IsHitTestVisible="False"> <Ellipse.RenderTransform> <ScaleTransform /> </Ellipse.RenderTransform> <Ellipse.Fill> <RadialGradientBrush> <GradientStop Color="#00FF0000" /> <GradientStop Color="#FFFF0000" Offset="0.25" /> <GradientStop Color="#00FF0000" Offset="0.5" /> <GradientStop Color="#FFFF0000" Offset="0.75" /> <GradientStop Color="#00FF0000" Offset="1" /> </RadialGradientBrush> </Ellipse.Fill> </Ellipse> <Ellipse Height="10" Width="10" Canvas.Left="-5" Canvas.Top="-5" Fill="#FFFF0000" x:Name="ellipse1" /> </Canvas> </ControlTemplate> </esriSymbols:MarkerSymbol.ControlTemplate> </esriSymbols:MarkerSymbol>
public static Symbol GetMarkerSymbol() { return Controls.MarkerSymbol.CreateSymbol(); }
public static Symbol GetMarkerSymbol(string symbolType, string color) { return Controls.MarkerSymbol.CreateSymbol(symbolType, color); }
public static Symbol GetMarkerSymbol(string symbolType, string color, string stroke) { return Controls.MarkerSymbol.CreateSymbol(symbolType, color, stroke); }
Symbol symbol = SymbolManager.GetFillSymbol("#FF0000");
double hueShift = 0.0; // no shift, starts at the palette base color foreach(DataContracts.Geometry geometry in myDrawingObjects) { graphicsManager.AddGraphic(geometry, SymbolManager.GetFillSymbol(hueShift), null, null); hueShift += 0.1; }
SymbolManager.SetPalette("#FF0000");
double hueShift = 0.0; // no shift, starts at the palette base color foreach(IEnumerable<DataContracts.Geometry> myDrawingObjects in myDrawingObjectGroups) { SymbolManager.ShiftPalette(hueShift); foreach(DataContracts.Geometry geometry in myDrawingObjects) { // null symbol uses default based on current palette graphicsManager.AddGraphic(geometry, null, null, null); } hueShift += 0.1; } SetDefaultPalette(); // return the palette to the framework default