Example #1
0
 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);
             }
         }
     }
 }
        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
        }
Example #3
0
        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;
                 }
             }
         }
     }
 }
Example #6
0
        private static MarkerSymbol cloneMarkerSymbol(MarkerSymbol symbol)
        {
            if (symbol == null)
            {
                return(null);
            }

            ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol imageFillSymbol = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol;
            if (imageFillSymbol != null)
            {
                ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol ifs = new ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol()
                {
                    Color           = CloneBrush(imageFillSymbol.Color),
                    ControlTemplate = imageFillSymbol.ControlTemplate,
                    OffsetX         = imageFillSymbol.OffsetX,
                    OffsetY         = imageFillSymbol.OffsetY,
                    OriginX         = imageFillSymbol.OriginX,
                    OriginY         = imageFillSymbol.OriginY,
                    Opacity         = imageFillSymbol.Opacity,
                    Size            = imageFillSymbol.Size,
                    ImageData       = imageFillSymbol.ImageData,
                    Source          = imageFillSymbol.Source,
                    Fill            = CloneBrush(imageFillSymbol.Fill),
                    CursorName      = imageFillSymbol.CursorName,
                };
                return(ifs);
            }

            ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol ms = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol;
            if (ms != null)
            {
                ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol marSymb = new ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol()
                {
                    DisplayName     = ms.DisplayName,
                    Offset          = new Point(ms.Offset.X, ms.Offset.Y),
                    Color           = CloneBrush(ms.Color),
                    ControlTemplate = ms.ControlTemplate,
                    OffsetX         = ms.OffsetX,
                    OffsetY         = ms.OffsetY,
                    OriginX         = ms.OriginX,
                    OriginY         = ms.OriginY,
                    Opacity         = ms.Opacity,
                    Size            = ms.Size,
                };
                return(marSymb);
            }

            ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol = symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol;
            if (simpleMarkerSymbol != null)
            {
                ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol sms = new ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol()
                {
                    Color           = CloneBrush(simpleMarkerSymbol.Color),
                    ControlTemplate = simpleMarkerSymbol.ControlTemplate,
                    Size            = simpleMarkerSymbol.Size,
                    // Simple marker symbol doesn't allow setting OffsetX, OffsetY
                };
                return(sms);
            }

            TextSymbol textSymbol = symbol as TextSymbol;

            if (textSymbol != null)
            {
                TextSymbol ts = new TextSymbol()
                {
                    ControlTemplate = textSymbol.ControlTemplate,
                    FontFamily      = textSymbol.FontFamily,
                    FontSize        = textSymbol.FontSize,
                    Foreground      = CloneBrush(textSymbol.Foreground),
                    OffsetX         = textSymbol.OffsetX,
                    OffsetY         = textSymbol.OffsetY,
                    Text            = textSymbol.Text,
                };
                return(ts);
            }

            PictureMarkerSymbol pictureMarkerSymbol = symbol as PictureMarkerSymbol;

            if (pictureMarkerSymbol != null)
            {
                PictureMarkerSymbol pictMs = new PictureMarkerSymbol()
                {
                    ControlTemplate = pictureMarkerSymbol.ControlTemplate,
                    Height          = pictureMarkerSymbol.Height,
                    OffsetX         = pictureMarkerSymbol.OffsetX,
                    OffsetY         = pictureMarkerSymbol.OffsetY,
                    Opacity         = pictureMarkerSymbol.Opacity,
                    Source          = pictureMarkerSymbol.Source,
                    Width           = pictureMarkerSymbol.Width,
                };
                return(pictMs);
            }

            MarkerSymbol markerS = new MarkerSymbol()
            {
                ControlTemplate = symbol.ControlTemplate,
                OffsetX         = symbol.OffsetX,
                OffsetY         = symbol.OffsetY,
            };

            return(markerS);
        }
        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);
                }
            }
        }
Example #8
0
        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
                }
            }
        }
Example #9
0
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
        private static MarkerSymbol cloneMarkerSymbol(MarkerSymbol symbol)
        {
            if (symbol == null)
                return null;

            ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol imageFillSymbol = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol;
            if (imageFillSymbol != null)
            {
                ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol ifs = new ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol()
                {
                    Color = CloneBrush(imageFillSymbol.Color),
                    ControlTemplate = imageFillSymbol.ControlTemplate,
                    OffsetX = imageFillSymbol.OffsetX,
                    OffsetY = imageFillSymbol.OffsetY,
                    OriginX = imageFillSymbol.OriginX,
                    OriginY = imageFillSymbol.OriginY,
                    Opacity = imageFillSymbol.Opacity,
                    Size = imageFillSymbol.Size,
                    ImageData = imageFillSymbol.ImageData,
                    Source = imageFillSymbol.Source,
                    Fill = CloneBrush(imageFillSymbol.Fill),
                    CursorName = imageFillSymbol.CursorName,
                };
                return ifs;
            }

            ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol ms = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol;
            if (ms != null)
            {
                ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol marSymb = new ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol()
                {
                    DisplayName = ms.DisplayName,
                    Offset = new Point(ms.Offset.X, ms.Offset.Y),
                    Color = CloneBrush(ms.Color),
                    ControlTemplate = ms.ControlTemplate,
                    OffsetX = ms.OffsetX,
                    OffsetY = ms.OffsetY,
                    OriginX = ms.OriginX,
                    OriginY = ms.OriginY,
                    Opacity = ms.Opacity,
                    Size = ms.Size,
                };
                return marSymb;
            }

            ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol = symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol;
            if (simpleMarkerSymbol != null)
            {
                ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol sms = new ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol()
                {
                    Color = CloneBrush(simpleMarkerSymbol.Color),
                    ControlTemplate = simpleMarkerSymbol.ControlTemplate,
                    Size = simpleMarkerSymbol.Size,
                    // Simple marker symbol doesn't allow setting OffsetX, OffsetY
                };
                return sms;
            }

            TextSymbol textSymbol = symbol as TextSymbol;
            if (textSymbol != null)
            {
                TextSymbol ts = new TextSymbol()
                {
                    ControlTemplate = textSymbol.ControlTemplate,
                    FontFamily = textSymbol.FontFamily,
                    FontSize = textSymbol.FontSize,
                    Foreground = CloneBrush(textSymbol.Foreground),
                    OffsetX = textSymbol.OffsetX,
                    OffsetY = textSymbol.OffsetY,
                    Text = textSymbol.Text,
                };
                return ts;
            }

            PictureMarkerSymbol pictureMarkerSymbol = symbol as PictureMarkerSymbol;
            if (pictureMarkerSymbol != null)
            {
                PictureMarkerSymbol pictMs = new PictureMarkerSymbol()
                {
                    ControlTemplate = pictureMarkerSymbol.ControlTemplate,
                    Height = pictureMarkerSymbol.Height,
                    OffsetX = pictureMarkerSymbol.OffsetX,
                    OffsetY = pictureMarkerSymbol.OffsetY,
                    Opacity = pictureMarkerSymbol.Opacity,
                    Source = pictureMarkerSymbol.Source,
                    Width = pictureMarkerSymbol.Width,
                };
                return pictMs;
            }

            MarkerSymbol markerS = new MarkerSymbol()
            {
                ControlTemplate = symbol.ControlTemplate,
                OffsetX = symbol.OffsetX,
                OffsetY = symbol.OffsetY,
            };
            return markerS;
        }