void PointThickness_ThicknessValueChanged(object sender, EventArgs e) { ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = Symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (markerSymbol != null) { markerSymbol.Size = PointThickness.TargetThickness.Bottom; onCurrentSymbolChanged(true); } else { ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol = Symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol; if (simpleMarkerSymbol != null) { simpleMarkerSymbol.Size = PointThickness.TargetThickness.Bottom; onCurrentSymbolChanged(true); } else { ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol sms = Symbol as ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol; if (sms != null) { sms.Size = PointThickness.TargetThickness.Bottom; onCurrentSymbolChanged(true); } } } }
void OutlineColorSelector_ColorPicked(object sender, ColorChosenEventArgs e) { FillSymbol fillSymbol = Symbol as FillSymbol; LineSymbol lineSymbol = Symbol as LineSymbol; FSS.SimpleMarkerSymbol sms = Symbol as FSS.SimpleMarkerSymbol; if (sms != null) { SolidColorBrush brush = sms.OutlineColor as SolidColorBrush; if (brush != null) { brush.Color = e.Color; onCurrentSymbolChanged(); } } else if (fillSymbol != null) { SolidColorBrush brush = fillSymbol.BorderBrush as SolidColorBrush; if (brush != null) { brush.Color = e.Color; onCurrentSymbolChanged(); } } else if (lineSymbol != null) { SolidColorBrush brush = lineSymbol.Color as SolidColorBrush; if (brush != null) { brush.Color = e.Color; onCurrentSymbolChanged(); } } }
public static void ChangeDefaultSymbolFillColor(this GraphicsLayer layer, Brush fillBrush) { Symbol symbol = layer.GetDefaultSymbol(); #region FSS.SFS if (symbol is FSS.SimpleFillSymbol && fillBrush is SolidColorBrush) { ((FSS.SimpleFillSymbol)symbol).Color = (fillBrush as SolidColorBrush).Color; } #endregion #region FSS.PFS else if (symbol is FSS.PictureFillSymbol) { FSS.PictureFillSymbol pfs = symbol as FSS.PictureFillSymbol; pfs.Color = fillBrush; } #endregion #region Default Fill Symbol else if (symbol is FillSymbol) { (symbol as FillSymbol).Fill = fillBrush; } #endregion #region Marker Symbols else { #region Mapping Core Marker ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (markerSymbol != null) { markerSymbol.Color = fillBrush; } #endregion else { #region Client SMS ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol = symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol; if (simpleMarkerSymbol != null) { simpleMarkerSymbol.Color = fillBrush; } #endregion #region FSS.SMS else { FSS.SimpleMarkerSymbol sms = symbol as FSS.SimpleMarkerSymbol; if (sms != null) { sms.Color = fillBrush; } } #endregion } } #endregion }
void SymbolBorderThickness_ThicknessValueChanged(object sender, EventArgs e) { if (SymbolBorderThickness == null) { return; } double newSize = SymbolBorderThickness.TargetThickness.Bottom; if (newSize < 0) { return; } FillSymbol fillSymbol = Symbol as FillSymbol; FSS.SimpleMarkerSymbol sms = Symbol as FSS.SimpleMarkerSymbol; if (sms != null) { sms.OutlineThickness = newSize; onCurrentSymbolChanged(); } else if (fillSymbol != null) { fillSymbol.BorderThickness = newSize; onCurrentSymbolChanged(); } else { LineSymbol lineSymbol = Symbol as LineSymbol; if (lineSymbol != null) { lineSymbol.Width = newSize; onCurrentSymbolChanged(); } } }
void BorderOpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = Symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol = Symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol; FSS.SimpleMarkerSymbol sms = Symbol as FSS.SimpleMarkerSymbol; FillSymbol fillSymbol = Symbol as FillSymbol; if (fillSymbol != null) { if (fillSymbol.BorderBrush != null) { fillSymbol.BorderBrush.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } else if (sms != null) { if (sms.OutlineColor != null) { sms.OutlineColor.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } }
public static void SetSymbolSizeTo(this Symbol symbol, int symbolSize) { ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (markerSymbol != null) { markerSymbol.Size = symbolSize; } else { ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol ms = symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol; if (ms != null) { ms.Size = symbolSize; } else { FSS.SimpleMarkerSymbol sms = symbol as FSS.SimpleMarkerSymbol; if (sms != null) { sms.Size = symbolSize; } } } }
public static void IncreaseDecreaseSymbolSizeBy(this Symbol symbol, int increaseDecreaseBy) { ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (markerSymbol != null) { double newSize = markerSymbol.Size + increaseDecreaseBy; if (newSize >= 0) { markerSymbol.Size = newSize; } } else { ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol ms = symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol; if (ms != null) { double newSize = ms.Size + increaseDecreaseBy; if (newSize >= 0) { ms.Size = newSize; } } else { FSS.SimpleMarkerSymbol sms = symbol as FSS.SimpleMarkerSymbol; if (sms != null) { double newSize = sms.Size + increaseDecreaseBy; if (newSize >= 0) { sms.Size = newSize; } } } } }
void bindUIToSymbol() { if (SymbolPicker != null) { SymbolPicker.Symbol = Symbol; } ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = Symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; FSS.SimpleMarkerSymbol fsSimpleMarkerSymbol = Symbol as FSS.SimpleMarkerSymbol; FSS.SimpleLineSymbol fsSimpleLineSymbol = Symbol as FSS.SimpleLineSymbol; FSS.SimpleFillSymbol fsSimpleFillSymbol = Symbol as FSS.SimpleFillSymbol; SimpleMarkerSymbol simpleMarkerSymbol = Symbol as SimpleMarkerSymbol; FillSymbol fillSymbol = Symbol as FillSymbol; LineSymbol lineSymbol = Symbol as LineSymbol; if (Symbol != null) { #region Size if (PointThickness != null) { // we support Size property on SimpleMarkerSymbol and ImageFillSymbol ImageFillSymbol imagefillSymbol = Symbol as ImageFillSymbol; if (imagefillSymbol != null) { PointThickness.IsEnabled = true; PointThickness.TargetThickness = new Thickness(imagefillSymbol.Size); } else { if (markerSymbol != null) { PointThickness.IsEnabled = true; PointThickness.TargetThickness = new Thickness(markerSymbol.Size); } else { if (simpleMarkerSymbol != null) { PointThickness.IsEnabled = true; PointThickness.TargetThickness = new Thickness(simpleMarkerSymbol.Size); } else if (fsSimpleMarkerSymbol != null) { PointThickness.IsEnabled = true; PointThickness.TargetThickness = new Thickness(fsSimpleMarkerSymbol.Size); } else { PointThickness.IsEnabled = false; } } } } #endregion #region Border Thickness if (SymbolBorderThickness != null) { if (fillSymbol != null) { SymbolBorderThickness.IsEnabled = true; SymbolBorderThickness.TargetThickness = new Thickness(fillSymbol.BorderThickness); } else if (lineSymbol != null) { SymbolBorderThickness.IsEnabled = true; SymbolBorderThickness.TargetThickness = new Thickness(lineSymbol.Width); } else if (fsSimpleMarkerSymbol != null) { if (fsSimpleMarkerSymbol.OutlineColor != null) { SymbolBorderThickness.IsEnabled = true; SymbolBorderThickness.TargetThickness = new Thickness( double.IsNaN(fsSimpleMarkerSymbol.OutlineThickness) ? 0 : fsSimpleMarkerSymbol.OutlineThickness); } else { SymbolBorderThickness.IsEnabled = false; } } else { SymbolBorderThickness.IsEnabled = false; } } #endregion #region BorderColor if (OutlineColorSelector != null) { if (fsSimpleMarkerSymbol != null) { SolidColorBrush sb = fsSimpleMarkerSymbol.OutlineColor as SolidColorBrush; if (sb != null) { OutlineColorSelector.IsEnabled = true; OutlineColorSelector.ColorBrush = sb; } else { OutlineColorSelector.IsEnabled = false; } } else if (fillSymbol != null) { SolidColorBrush sb = fillSymbol.BorderBrush as SolidColorBrush; if (sb != null) { OutlineColorSelector.IsEnabled = true; OutlineColorSelector.ColorBrush = sb; } else { OutlineColorSelector.IsEnabled = false; } } else if (lineSymbol != null) { SolidColorBrush sb = lineSymbol.Color as SolidColorBrush; if (sb != null) { OutlineColorSelector.IsEnabled = true; OutlineColorSelector.ColorBrush = sb; } else { OutlineColorSelector.IsEnabled = false; } } else { OutlineColorSelector.IsEnabled = false; } } #endregion #region Fill Color if (FillColorSelector != null) { if (fillSymbol != null) { SolidColorBrush sb = fillSymbol.Fill as SolidColorBrush; if (sb != null) { FillColorSelector.IsEnabled = true; FillColorSelector.ColorBrush = sb; } else { FillColorSelector.IsEnabled = false; } } else { if (markerSymbol != null) { SolidColorBrush sb = markerSymbol.Color as SolidColorBrush; if (sb != null) { FillColorSelector.IsEnabled = true; FillColorSelector.ColorBrush = sb; } else { FillColorSelector.IsEnabled = false; } } else if (fsSimpleMarkerSymbol != null) { SolidColorBrush sb = fsSimpleMarkerSymbol.Color as SolidColorBrush; if (sb != null) { FillColorSelector.IsEnabled = true; FillColorSelector.ColorBrush = sb; } else { FillColorSelector.IsEnabled = false; } } else if (simpleMarkerSymbol != null) { SolidColorBrush sb = simpleMarkerSymbol.Color as SolidColorBrush; if (sb != null) { FillColorSelector.IsEnabled = true; FillColorSelector.ColorBrush = sb; } else { FillColorSelector.IsEnabled = false; } } else { FillColorSelector.IsEnabled = false; } } } #endregion #region Opacity if (OpacitySlider != null) { if (markerSymbol != null) { OpacitySlider.Value = markerSymbol.Opacity; } else if (simpleMarkerSymbol != null) { if (simpleMarkerSymbol.Color != null) { OpacitySlider.Value = simpleMarkerSymbol.Color.GetOpacity(); } } else if (fsSimpleMarkerSymbol != null) { if (fsSimpleMarkerSymbol.Color != null) { OpacitySlider.Value = fsSimpleMarkerSymbol.Color.GetOpacity(); } } else if (fsSimpleLineSymbol != null) { if (fsSimpleLineSymbol.Color != null) { OpacitySlider.Value = fsSimpleLineSymbol.Color.GetOpacity(); } } else if (fsSimpleFillSymbol != null) { if (fsSimpleFillSymbol.Color != null) { OpacitySlider.Value = fsSimpleFillSymbol.Color.A / 255d; } } else if (fillSymbol != null) { if (fillSymbol.Fill != null) { OpacitySlider.Value = fillSymbol.Fill.GetOpacity(); } } else if (lineSymbol != null) { if (lineSymbol.Color != null) { OpacitySlider.Value = lineSymbol.Color.GetOpacity(); } } } #endregion #region Border Opacity if (BorderOpacitySlider != null) { if (fillSymbol != null) { if (fillSymbol.BorderBrush != null) { BorderOpacitySlider.Visibility = System.Windows.Visibility.Visible; BorderOpacitySlider.Value = fillSymbol.BorderBrush.GetOpacity(); } else { BorderOpacitySlider.Visibility = System.Windows.Visibility.Collapsed; } } else if (fsSimpleMarkerSymbol != null && fsSimpleMarkerSymbol.OutlineColor != null) { BorderOpacitySlider.Visibility = System.Windows.Visibility.Visible; BorderOpacitySlider.Value = fsSimpleMarkerSymbol.OutlineColor.GetOpacity(); } else { BorderOpacitySlider.Visibility = System.Windows.Visibility.Collapsed; } } #endregion } }
void FillColorSelector_ColorPicked(object sender, ColorChosenEventArgs e) { FillSymbol fillSymbol = Symbol as FillSymbol; if (fillSymbol != null) { #region FSS.SFS if (fillSymbol is FSS.SimpleFillSymbol) { ((FSS.SimpleFillSymbol)fillSymbol).Color = e.Color; onCurrentSymbolChanged(); } #endregion #region FSS.PFS else if (fillSymbol is FSS.PictureFillSymbol) { FSS.PictureFillSymbol pfs = fillSymbol as FSS.PictureFillSymbol; SolidColorBrush brush = pfs.Color as SolidColorBrush; if (brush != null) { brush.Color = e.Color; onCurrentSymbolChanged(); } } #endregion #region Default else { SolidColorBrush brush = fillSymbol.Fill as SolidColorBrush; if (brush != null) { brush.Color = e.Color; onCurrentSymbolChanged(); } } #endregion } else { #region Mapping Core Marker ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = Symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (markerSymbol != null) { SolidColorBrush sb = markerSymbol.Color as SolidColorBrush; if (sb != null) { sb.Color = e.Color; onCurrentSymbolChanged(); } } #endregion else { #region Client SMS ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol = Symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol; if (simpleMarkerSymbol != null) { SolidColorBrush sb = simpleMarkerSymbol.Color as SolidColorBrush; if (sb != null) { sb.Color = e.Color; onCurrentSymbolChanged(); } } #endregion #region FSS.SMS else { FSS.SimpleMarkerSymbol sms = Symbol as FSS.SimpleMarkerSymbol; if (sms != null) { SolidColorBrush sb = sms.Color as SolidColorBrush; if (sb != null) { sb.Color = e.Color; onCurrentSymbolChanged(); } } } #endregion } } }
void OpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (Symbol is ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol) { ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol symbol = (ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol)Symbol; symbol.Opacity = e.NewValue; onCurrentSymbolChanged(); } else if (Symbol is FSS.SimpleMarkerSymbol) { FSS.SimpleMarkerSymbol symbol = (FSS.SimpleMarkerSymbol)Symbol; if (symbol.Color != null) { symbol.Color.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } else if (Symbol is FSS.SimpleLineSymbol) { FSS.SimpleLineSymbol symbol = (FSS.SimpleLineSymbol)Symbol; if (symbol.Color != null) { symbol.Color.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } else if (Symbol is FSS.SimpleFillSymbol) { FSS.SimpleFillSymbol symbol = (FSS.SimpleFillSymbol)Symbol; if (symbol.Color != null) { symbol.Color = Color.FromArgb(Convert.ToByte(255 * e.NewValue), symbol.Color.R, symbol.Color.G, symbol.Color.B); onCurrentSymbolChanged(); } } else if (Symbol is SimpleMarkerSymbol) { SimpleMarkerSymbol symbol = (SimpleMarkerSymbol)Symbol; if (symbol.Color != null) { symbol.Color.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } else if (Symbol is LineSymbol) { LineSymbol symbol = (LineSymbol)Symbol; if (symbol.Color != null) { symbol.Color.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } else if (Symbol is FillSymbol) { FillSymbol symbol = (FillSymbol)Symbol; if (symbol.Fill != null) { symbol.Fill.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } }
private static void SetImagePropertiesFromJson(DependencyObject o, DependencyPropertyChangedEventArgs args) { Symbol symbol = o as Symbol; string json = GetJson(symbol); if (string.IsNullOrEmpty(json)) { return; } SolidColorBrush selectionColor = new SolidColorBrush(Colors.Cyan); FS.PictureFillSymbol pfs = o as FS.PictureFillSymbol; if (pfs != null) { FS.PictureFillSymbol pfsN = Symbol.FromJson(json) as FS.PictureFillSymbol; if (pfsN != null) { #region Copy Properties pfs.Source = pfsN.Source; //internal properties - for documentation //pfs.Angle = pfsN.Angle; //pfs.XOffset = pfsN.XOffset; //pfs.YOffset = pfsN.YOffset; //pfs.XScale = pfsN.XScale; //pfs.YScale = pfsN.YScale; pfs.BorderBrush = pfsN.BorderBrush; pfs.BorderThickness = pfsN.BorderThickness; pfs.BorderStyle = pfsN.BorderStyle; pfs.Width = pfsN.Width; pfs.Height = pfsN.Height; pfs.Color = pfsN.Color; pfs.Opacity = 0.75; pfs.SelectionColor = selectionColor; #endregion } return; } FS.PictureMarkerSymbol pms = o as FS.PictureMarkerSymbol; if (pms != null) { FS.PictureMarkerSymbol pmsN = Symbol.FromJson(json) as FS.PictureMarkerSymbol; if (pmsN != null) { #region Copy Properties pms.Source = pmsN.Source; pms.Width = pmsN.Width; pms.Height = pmsN.Height; pms.XOffsetFromCenter = pmsN.XOffsetFromCenter; pms.YOffsetFromCenter = pmsN.YOffsetFromCenter; pms.Color = pmsN.Color; pms.Opacity = pmsN.Opacity; pms.Angle = pmsN.Angle; pms.SelectionColor = selectionColor; #endregion Dictionary <string, object> jsonObject = new ESRI.ArcGIS.Client.Utils.JavaScriptSerializer().DeserializeObject(json) as Dictionary <string, object>; if (jsonObject != null) { if (jsonObject.ContainsKey("imageData")) { SetImageData(pms, jsonObject["imageData"] as string); } else if (jsonObject.ContainsKey("url")) { SetImageUrl(pms, jsonObject["url"] as string); } } } return; } FS.SimpleFillSymbol sfs = o as FS.SimpleFillSymbol; if (sfs != null) { FS.SimpleFillSymbol sfsN = Symbol.FromJson(json) as FS.SimpleFillSymbol; if (sfsN != null) { #region Copy Properties sfs.Fill = sfsN.Fill; sfs.Style = sfsN.Style; sfs.Color = sfsN.Color; sfs.BorderBrush = sfsN.BorderBrush; sfs.BorderThickness = sfsN.BorderThickness; sfs.BorderStyle = sfsN.BorderStyle; sfs.SelectionColor = selectionColor; #endregion } return; } FS.SimpleLineSymbol sls = o as FS.SimpleLineSymbol; if (sls != null) { FS.SimpleLineSymbol slsN = Symbol.FromJson(json) as FS.SimpleLineSymbol; if (slsN != null) { #region CopyProperties sls.Style = slsN.Style; sls.Color = slsN.Color; sls.Width = slsN.Width; sls.SelectionColor = selectionColor; #endregion } return; } FS.SimpleMarkerSymbol sms = o as FS.SimpleMarkerSymbol; if (sms != null) { FS.SimpleMarkerSymbol smsN = Symbol.FromJson(json) as FS.SimpleMarkerSymbol; if (smsN != null) { #region Copy properties sms.Style = smsN.Style; sms.Color = smsN.Color; sms.Size = smsN.Size; sms.XOffsetFromCenter = smsN.XOffsetFromCenter; sms.YOffsetFromCenter = smsN.YOffsetFromCenter; sms.Angle = smsN.Angle; sms.OutlineColor = smsN.OutlineColor; sms.OutlineThickness = smsN.OutlineThickness; sms.OutlineStyle = smsN.OutlineStyle; sms.SelectionColor = selectionColor; #endregion } return; } }