public static Color GetDefaultSymbolFillColor(this GraphicsLayer layer)
        {
            Symbol symbol = layer.GetDefaultSymbol();

            SolidColorBrush solidColorBrush;

            FSS.SimpleMarkerSymbol fsSimpleMarkerSymbol;
            if ((fsSimpleMarkerSymbol = symbol as FSS.SimpleMarkerSymbol) != null)
            {
                if ((solidColorBrush = fsSimpleMarkerSymbol.Color as SolidColorBrush) != null)
                {
                    return(solidColorBrush.Color);
                }
            }
            else
            {
                FillSymbol fillSymbol = symbol as FillSymbol;
                if (fillSymbol != null)
                {
                    solidColorBrush = fillSymbol.Fill as SolidColorBrush;
                    if (solidColorBrush != null)
                    {
                        return(solidColorBrush.Color);
                    }
                }
            }
            return(Colors.Transparent);
        }
        public static void ChangeDefaultSymbolBorderColor(this GraphicsLayer layer, Brush borderBrush)
        {
            Symbol symbol = layer.GetDefaultSymbol();

            FSS.SimpleMarkerSymbol fsSimpleMarkerSymbol;
            if ((fsSimpleMarkerSymbol = symbol as FSS.SimpleMarkerSymbol) != null)
            {
                fsSimpleMarkerSymbol.OutlineColor = borderBrush;
            }
            else
            {
                FillSymbol fillSymbol = symbol as FillSymbol;
                if (fillSymbol != null)
                {
                    fillSymbol.BorderBrush = borderBrush;
                }
                else
                {
                    LineSymbol lineSymbol = symbol as LineSymbol;
                    if (lineSymbol != null)
                    {
                        lineSymbol.Color = borderBrush;
                    }
                }
            }
        }
        public static void DecreaseDefaultSymbolBorderWidth(this GraphicsLayer layer)
        {
            Symbol symbol = layer.GetDefaultSymbol();

            FSS.SimpleMarkerSymbol fsSimpleMarkerSymbol;
            if ((fsSimpleMarkerSymbol = symbol as FSS.SimpleMarkerSymbol) != null && fsSimpleMarkerSymbol.OutlineThickness > 0)
            {
                fsSimpleMarkerSymbol.OutlineThickness--;
            }
            else
            {
                FillSymbol fillSymbol = symbol as FillSymbol;
                if (fillSymbol != null)
                {
                    if (fillSymbol.BorderThickness > 0) // make sure it isn't -ve
                    {
                        double newSize = fillSymbol.BorderThickness - 1;
                        fillSymbol.BorderThickness = newSize;
                    }
                }
                else
                {
                    LineSymbol lineSymbol = symbol as LineSymbol;
                    if (lineSymbol != null)
                    {
                        if (lineSymbol.Width > 0)// make sure it isn't -ve
                        {
                            double newSize = lineSymbol.Width - 1;
                            lineSymbol.Width = newSize;
                        }
                    }
                }
            }
        }
        public static void IncreaseDefaultSymbolBorderWidth(this GraphicsLayer layer)
        {
            Symbol symbol = layer.GetDefaultSymbol();

            FSS.SimpleMarkerSymbol fsSimpleMarkerSymbol;
            if ((fsSimpleMarkerSymbol = symbol as FSS.SimpleMarkerSymbol) != null)
            {
                fsSimpleMarkerSymbol.OutlineThickness++;
            }
            else
            {
                FillSymbol fillSymbol = symbol as FillSymbol;
                if (fillSymbol != null)
                {
                    double newSize = fillSymbol.BorderThickness + 1;
                    fillSymbol.BorderThickness = newSize;
                }
                else
                {
                    LineSymbol lineSymbol = symbol as LineSymbol;
                    if (lineSymbol != null)
                    {
                        double newSize = lineSymbol.Width + 1;
                        lineSymbol.Width = newSize;
                    }
                }
            }
        }
        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
        }
示例#6
0
        private static UniqueValueRenderer createNewDefaultUniqueValueRenderer(GraphicsLayer graphicsLayer, IEnumerable <object> uniqueValues, FieldInfo attributeField, LinearGradientBrush defaultColorRampGradientBrush, IEnumerable <Symbol> existingSymbolSet)
        {
            Symbol defaultSymbol = graphicsLayer.GetDefaultSymbol();
            UniqueValueRenderer uniqueValueRenderer = new UniqueValueRenderer()
            {
                Field         = attributeField != null ? attributeField.Name : null,
                DefaultSymbol = defaultSymbol,
            };

            if (uniqueValues != null)
            {
                List <Symbol> symbols = new List <Symbol>();
                int           i       = 0;
                foreach (object uniqueValue in uniqueValues)
                {
                    Symbol symbol = null;
                    if (existingSymbolSet != null)
                    {
                        symbol = existingSymbolSet.ElementAtOrDefault(i);
                    }
                    if (symbol == null)
                    {
                        symbol = graphicsLayer.GetDefaultSymbolClone();
                    }
                    uniqueValueRenderer.Infos.Add(new UniqueValueInfoObj()
                    {
                        Symbol          = symbol,
                        SerializedValue = uniqueValue,
                        FieldType       = attributeField.FieldType,
                    });
                    symbols.Add(symbol);
                    i++;
                }
                if (defaultColorRampGradientBrush != null)
                {
                    if (existingSymbolSet == null) // apply the gradient brush, only if symbols have not been pre-defined
                    {
                        applyLinearGradientBrushToSymbolSet(symbols, defaultColorRampGradientBrush, defaultSymbol);
                    }
                }
            }
            return(uniqueValueRenderer);
        }
 private static UniqueValueRenderer createNewDefaultUniqueValueRenderer(GraphicsLayer graphicsLayer, IEnumerable<object> uniqueValues, FieldInfo attributeField, LinearGradientBrush defaultColorRampGradientBrush, IEnumerable<Symbol> existingSymbolSet)
 {
     Symbol defaultSymbol = graphicsLayer.GetDefaultSymbol();
     UniqueValueRenderer uniqueValueRenderer = new UniqueValueRenderer()
     {
         Field = attributeField != null ? attributeField.Name : null,
         DefaultSymbol = defaultSymbol,
     };
     if (uniqueValues != null)
     {
         List<Symbol> symbols = new List<Symbol>();
         int i = 0;
         foreach (object uniqueValue in uniqueValues)
         {
             Symbol symbol = null;
             if (existingSymbolSet != null)
                 symbol = existingSymbolSet.ElementAtOrDefault(i);
             if (symbol == null)
                 symbol = graphicsLayer.GetDefaultSymbolClone();
             uniqueValueRenderer.Infos.Add(new UniqueValueInfoObj()
             {
                 Symbol = symbol,
                 SerializedValue = uniqueValue,
                 FieldType = attributeField.FieldType,
             });
             symbols.Add(symbol);
             i++;
         }
         if (defaultColorRampGradientBrush != null)
         {
             if (existingSymbolSet == null) // apply the gradient brush, only if symbols have not been pre-defined
             {
                 applyLinearGradientBrushToSymbolSet(symbols, defaultColorRampGradientBrush, defaultSymbol);
             }
         }
     }
     return uniqueValueRenderer;
 }
        private void bindUIToLayer()
        {
            GraphicsLayer graphicsLayer = Layer as GraphicsLayer;

            if (graphicsLayer == null)
            {
                return;
            }

            #region Renderer Takes Precedence
            bindingToLayer = true;
            if (GraphicSymbolsTakePrecedence != null)
            {
                GraphicSymbolsTakePrecedence.IsChecked = !graphicsLayer.RendererTakesPrecedence;
            }
            bindingToLayer = false;
            #endregion

            GeometryType = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetGeometryType(graphicsLayer);

            ClassBreaksRenderer classBreaksRenderer = graphicsLayer.Renderer as ClassBreaksRenderer;
            if (classBreaksRenderer != null)
            {
                if (RendererOptionsContainerControl != null)
                {
                    ClassBreaksRendererOptionsConfigControl optionsConfigControl = new ClassBreaksRendererOptionsConfigControl()
                    {
                        ClassBreaksRenderer  = classBreaksRenderer,
                        SymbolConfigProvider = SymbolConfigProvider,
                        GeometryType         = GeometryType,
                    };

                    Binding b = new Binding("Foreground")
                    {
                        Source = this
                    };
                    optionsConfigControl.SetBinding(ClassBreaksRendererOptionsConfigControl.ForegroundProperty, b);

                    optionsConfigControl.RendererColorSchemeChanged += new EventHandler <GradientBrushChangedEventArgs>(optionsConfigControl_RendererColorSchemeChanged);
                    optionsConfigControl.RendererClassBreaksChanged += new EventHandler <RendererClassBreaksCountChangedEventArgs>(optionsConfigControl_RendererClassBreaksChanged);
                    RendererOptionsContainerControl.Content          = optionsConfigControl;
                }

                if (RendererOptionsContainerBorder != null)
                {
                    RendererOptionsContainerBorder.Visibility = Visibility.Visible;
                }

                if (CurrentSymbolLabel != null)
                {
                    CurrentSymbolLabel.Visibility = Visibility.Visible;
                }

                createClassBreaksRendererSymbolsConfigControl(classBreaksRenderer);
            }
            else
            {
                UniqueValueRenderer uniqueValueRenderer = graphicsLayer.Renderer as UniqueValueRenderer;
                if (uniqueValueRenderer != null)
                {
                    if (RendererOptionsContainerControl != null)
                    {
                        UniqueValueRendererOptionsConfigControl optionsConfigControl = new UniqueValueRendererOptionsConfigControl()
                        {
                            UniqueValueRenderer  = uniqueValueRenderer,
                            SymbolConfigProvider = SymbolConfigProvider,
                            GeometryType         = GeometryType,
                        };

                        Binding b = new Binding("Foreground")
                        {
                            Source = this
                        };
                        optionsConfigControl.SetBinding(UniqueValueRendererOptionsConfigControl.ForegroundProperty, b);

                        optionsConfigControl.RendererColorSchemeChanged += new EventHandler <GradientBrushChangedEventArgs>(optionsConfigControl_RendererColorSchemeChanged);
                        optionsConfigControl.NewUniqueValueAdded        += new EventHandler <NewUniqueValueInfoEventArgs>(optionsConfigControl_NewUniqueValueCreated);
                        optionsConfigControl.DeleteUniqueValueClicked   += new EventHandler(optionsConfigControl_DeleteUniqueValueClicked);
                        RendererOptionsContainerControl.Content          = optionsConfigControl;
                    }

                    if (RendererSymbolSetContainerControl != null)
                    {
                        UniqueValueRendererSymbolsConfigControl symbolsConfigControl = new UniqueValueRendererSymbolsConfigControl()
                        {
                            UniqueValueRenderer  = uniqueValueRenderer,
                            SymbolConfigProvider = SymbolConfigProvider,
                            GeometryType         = GeometryType,
                        };

                        Binding b = new Binding("Foreground")
                        {
                            Source = this
                        };
                        symbolsConfigControl.SetBinding(UniqueValueRendererSymbolsConfigControl.ForegroundProperty, b);

                        symbolsConfigControl.UniqueValueRendererModified      += new EventHandler <SelectedUniqueValueModificationEventArgs>(symbolsConfigControl_UniqueValueRendererModified);
                        symbolsConfigControl.CurrentUniqueValueChanged        += new EventHandler <CurrentUniqueValueChangedEventArgs>(symbolsConfigControl_CurrentUniqueValueChanged);
                        symbolsConfigControl.DefaultClassBreakBeingConfigured += new EventHandler <DefaultClassBreakBeingConfiguredEventArgs>(symbolsConfigControl_DefaultClassBreakBeingConfigured);
                        RendererSymbolSetContainerControl.Content              = symbolsConfigControl;
                    }

                    if (RendererOptionsContainerBorder != null)
                    {
                        RendererOptionsContainerBorder.Visibility = Visibility.Visible;
                    }

                    if (CurrentSymbolLabel != null)
                    {
                        CurrentSymbolLabel.Visibility = Visibility.Visible;
                    }
                }
                else
                {
                    // No renderer / simple renderer ... clear out the control
                    if (RendererOptionsContainerControl != null)
                    {
                        RendererOptionsContainerControl.Content = null;
                    }

                    if (RendererSymbolSetContainerControl != null)
                    {
                        ESRI.ArcGIS.Client.Symbols.Symbol defaultSymbol       = graphicsLayer.GetDefaultSymbol();
                        DefaultSymbolConfigControl        defaultSymbolConfig = new DefaultSymbolConfigControl()
                        {
                            Symbol = defaultSymbol,
                            SymbolConfigProvider = SymbolConfigProvider,
                            GeometryType         = GeometryType,
                        };

                        Binding b = new Binding("Foreground")
                        {
                            Source = this
                        };
                        defaultSymbolConfig.SetBinding(DefaultSymbolConfigControl.ForegroundProperty, b);

                        defaultSymbolConfig.DefaultSymbolModified += new EventHandler <SymbolSelectedEventArgs>(defaultSymbolConfig_DefaultSymbolModified);
                        RendererSymbolSetContainerControl.Content  = defaultSymbolConfig;
                        if (SymbolConfigControl != null)
                        {
                            SymbolConfigControl.Symbol = defaultSymbol;
                        }
                    }

                    if (CurrentSymbolLabel != null)
                    {
                        CurrentSymbolLabel.Visibility = Visibility.Collapsed;
                    }

                    if (RendererOptionsContainerBorder != null)
                    {
                        RendererOptionsContainerBorder.Visibility = Visibility.Collapsed;
                    }
                }
            }
        }
        public static void IncreaseDecreaseLayerSymbolSizeBy(this GraphicsLayer layer, int increaseDecreaseBy)
        {
            Symbol symbol = layer.GetDefaultSymbol();

            IncreaseDecreaseSymbolSizeBy(symbol, increaseDecreaseBy);
        }