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); } } } }
private static void OnColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { MarkerSymbol dp = d as MarkerSymbol; if (dp != null) { dp.OnPropertyChanged("Color"); } }
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 }
/// <summary> /// Modifies the source data before passing it to the target for display in the UI. /// </summary> /// <param name="value">The source data being passed to the target.</param> /// <param name="targetType">The <see cref="T:System.Type"/> of data expected by the target dependency property.</param> /// <param name="parameter">An optional parameter to be used in the converter logic.</param> /// <param name="culture">The culture of the conversion.</param> /// <returns> /// The value to be passed to the target dependency property. /// </returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { MarkerSymbol symbol = (MarkerSymbol)value; if (symbol != null) { return(new Point(symbol.OriginX, symbol.OriginY)); } return(new Point(0, 0)); }
private static void OnOriginYChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { MarkerSymbol symbol = d as MarkerSymbol; if (d == null) { return; } symbol.setOffset(); }
private void setNonSerializablePropertiesOfSymbolToNull() { // Control templates cannot be serialized Symbol.ControlTemplate = null; // Set all brushes to null - we can't serialize brushes ImageFillSymbol imageFillSymbol = Symbol as ImageFillSymbol; if (imageFillSymbol != null) { imageFillSymbol.Fill = null; imageFillSymbol.Color = null; } else { ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = Symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (markerSymbol != null) { markerSymbol.Color = null; } else { FillSymbol fillSymbol = Symbol as FillSymbol; if (fillSymbol != null) { fillSymbol.BorderBrush = null; fillSymbol.Fill = null; } else { LineSymbol lineSymbol = Symbol as LineSymbol; if (lineSymbol != null) { lineSymbol.Color = null; } } } } }
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 SymbolConfigProvider_GetSymbolForResourceDictionary(object sender, GetSymbolsForResourceDictionaryCompletedEventArgs e) { if (e.Symbols == null) { return; } if (Symbols != null) { try { Symbols.Items.Clear(); foreach (SymbolDescription symbolDescription in e.Symbols) { if (symbolDescription == null || symbolDescription.Symbol == null) { continue; } Symbol symbol = symbolDescription.Symbol; double size = 50; ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (markerSymbol != null) { if (!double.IsNaN(markerSymbol.Size)) { size = markerSymbol.Size; } } else if (symbol is FillSymbol || symbol is LineSymbol) { size = 25; } else if (symbol is ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol) { ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol = symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol; if (simpleMarkerSymbol != null && !double.IsNaN(simpleMarkerSymbol.Size)) { size = simpleMarkerSymbol.Size; } } else if (symbol is ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol) { ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol sms = symbol as ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol; if (sms != null && !double.IsNaN(sms.Size)) { size = sms.Size; } } SymbolDisplay disp = new SymbolDisplay() { Symbol = symbolDescription.Symbol, Width = size, Height = size, IsHitTestVisible = false // Set to false to prevent mouseover and selection effects }; // Wrap symbol display in a grid to allow cursor and tooltip Grid symbolGrid = new Grid() { Cursor = Cursors.Hand, // Apply nearly transparent background so grid is hit-test visible Background = new SolidColorBrush(Color.FromArgb(1, 255, 255, 255)) }; symbolGrid.Children.Add(disp); Symbols.Items.Add(symbolGrid); } } catch (Exception ex) { Logger.Instance.LogError(ex); MessageBoxDialog.Show(ESRI.ArcGIS.Mapping.Controls.Resources.Strings.ErrorRetrievingSymbols + Environment.NewLine + ex.Message); } } }
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(); } } }