private static List <GradientStopCollection> GetPreDefinedGradients() { if (stops == null) { lock (lockObject) { if (stops == null) { stops = new List <GradientStopCollection>(); stops.Add(createGradientStopCollection(new Color[] { Colors.Transparent, Colors.Blue, Colors.Red, Colors.Yellow, Colors.White })); stops.Add(createGradientStopCollection(new Color[] { Colors.White, Colors.Yellow, Colors.Red, Colors.Blue, Colors.Transparent })); stops.Add(createGradientStopCollection(new Color[] { ColorPickerUtils.FromHex("#FFFFC800"), ColorPickerUtils.FromHex("#FF0000FF"), ColorPickerUtils.FromHex("#FFB700C4"), ColorPickerUtils.FromHex("#FFFF0088"), ColorPickerUtils.FromHex("#FFFF0051"), ColorPickerUtils.FromHex("#FFFF4229"), ColorPickerUtils.FromHex("#FFFF8C00") })); stops.Add(createGradientStopCollection(new Color[] { ColorPickerUtils.FromHex("#FFFF8C00"), ColorPickerUtils.FromHex("#FFFF4229"), ColorPickerUtils.FromHex("#FFFF0051"), ColorPickerUtils.FromHex("#FFFF0088"), ColorPickerUtils.FromHex("#FFB700C4"), ColorPickerUtils.FromHex("#FF0000FF"), ColorPickerUtils.FromHex("#FFFFC800") })); stops.Add(createGradientStopCollection(new Color[] { Colors.Transparent, Colors.Black, Colors.Yellow, Colors.Red, Colors.White })); stops.Add(createGradientStopCollection(new Color[] { Colors.White, Colors.Red, Colors.Yellow, Colors.Black, Colors.Transparent })); } } } return(stops); }
internal static Color FromHex(string newColor) { return(ColorPickerUtils.FromHex(newColor)); }
private static LinearGradientBrush createBrush(string startHex, string endHex) { return(createBrush(ColorPickerUtils.FromHex(startHex), ColorPickerUtils.FromHex(endHex))); }
private static void applyColorToSymbol(Symbol symbol, Color color) { if (symbol == null) { return; } FillSymbol fillSymbol = symbol as FillSymbol; if (fillSymbol != null) { byte currentAlpha = (byte)255; if (fillSymbol.Fill != null) { currentAlpha = (byte)(255 * fillSymbol.Fill.Opacity); // Preserve current opacity of symbol color } string colorHex = Color.FromArgb(currentAlpha, color.R, color.G, color.B).ToString(); Color newColor = ColorPickerUtils.FromHex(colorHex); if (fillSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleFillSymbol) { (fillSymbol as ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleFillSymbol).Color = newColor; } else { fillSymbol.Fill = new SolidColorBrush(newColor); } } else { LineSymbol lineSymbol = symbol as LineSymbol; if (lineSymbol != null) { byte currentAlpha = (byte)255; if (lineSymbol.Color != null) { currentAlpha = (byte)(255 * lineSymbol.Color.Opacity);// Preserve current opacity of symbol color } string colorHex = Color.FromArgb(currentAlpha, color.R, color.G, color.B).ToString(); Color newColor = ColorPickerUtils.FromHex(colorHex); lineSymbol.Color = new SolidColorBrush(newColor); } else { ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (markerSymbol != null) { byte currentAlpha = (byte)255; if (markerSymbol.Color != null) { currentAlpha = (byte)(255 * markerSymbol.Color.Opacity);// Preserve current opacity of symbol color } string colorHex = Color.FromArgb(currentAlpha, color.R, color.G, color.B).ToString(); Color newColor = ColorPickerUtils.FromHex(colorHex); markerSymbol.Color = new SolidColorBrush(newColor); } else { ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol = symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol; if (simpleMarkerSymbol != null) { byte currentAlpha = (byte)255; if (simpleMarkerSymbol.Color != null) { currentAlpha = (byte)(255 * simpleMarkerSymbol.Color.Opacity);// Preserve current opacity of symbol color } string colorHex = Color.FromArgb(currentAlpha, color.R, color.G, color.B).ToString(); Color newColor = ColorPickerUtils.FromHex(colorHex); simpleMarkerSymbol.Color = new SolidColorBrush(newColor); } else { ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol sms = symbol as ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol; if (sms != null) { byte currentAlpha = (byte)255; if (sms.Color is SolidColorBrush) { currentAlpha = (sms.Color as SolidColorBrush).Color.A; } else if (sms.Color != null) { currentAlpha = (byte)(255 * sms.Color.Opacity);// Preserve current opacity of symbol color } string colorHex = Color.FromArgb(currentAlpha, color.R, color.G, color.B).ToString(); Color newColor = ColorPickerUtils.FromHex(colorHex); sms.Color = new SolidColorBrush(newColor); if (sms.OutlineColor != null) { sms.OutlineColor = new SolidColorBrush(newColor); } } } } } } }