Ejemplo n.º 1
0
        private void updateSymbolConfigControlIfCurrentSelectedSymbol()
        {
            if (SymbolConfigControl == null || RendererSymbolSetContainerControl == null)
            {
                return;
            }

            ClassBreaksRendererSymbolsConfigControl symbolsConfigControl = RendererSymbolSetContainerControl.Content as ClassBreaksRendererSymbolsConfigControl;

            if (symbolsConfigControl != null)
            {
                Control selectedControl = symbolsConfigControl.GetCurrentSelectedConfigControl();
                ClassBreakConfigControl classBreaksConfigControl = selectedControl as ClassBreakConfigControl;
                if (classBreaksConfigControl != null)
                {
                    if (classBreaksConfigControl.ClassBreak != null)
                    {
                        SymbolConfigControl.Symbol = classBreaksConfigControl.ClassBreak.Symbol;
                    }
                }
                else
                {
                    DefaultSymbolConfigControl defaultConfigControl = selectedControl as DefaultSymbolConfigControl;
                    if (defaultConfigControl != null)
                    {
                        SymbolConfigControl.Symbol = defaultConfigControl.Symbol;
                    }
                }
            }
            else
            {
                UniqueValueRendererSymbolsConfigControl uniqueValueRendererConfigControl = RendererSymbolSetContainerControl.Content as UniqueValueRendererSymbolsConfigControl;
                if (uniqueValueRendererConfigControl != null)
                {
                    Control selectedControl = uniqueValueRendererConfigControl.GetCurrentSelectedConfigControl();
                    UniqueValueConfigControl uniqueValueConfigControl = selectedControl as UniqueValueConfigControl;
                    if (uniqueValueConfigControl != null)
                    {
                        if (uniqueValueConfigControl.UniqueValue != null)
                        {
                            SymbolConfigControl.Symbol = uniqueValueConfigControl.UniqueValue.Symbol;
                        }
                    }
                    else
                    {
                        DefaultSymbolConfigControl defaultConfigControl = selectedControl as DefaultSymbolConfigControl;
                        if (defaultConfigControl != null)
                        {
                            SymbolConfigControl.Symbol = defaultConfigControl.Symbol;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 void optionsConfigControl_DeleteUniqueValueClicked(object sender, EventArgs e)
 {
     if (RendererSymbolSetContainerControl != null)
     {
         UniqueValueRendererSymbolsConfigControl symbolsConfigControl = RendererSymbolSetContainerControl.Content as UniqueValueRendererSymbolsConfigControl;
         if (symbolsConfigControl != null)
         {
             symbolsConfigControl.DeleteCurrentSelectedUniqueValue();
         }
     }
 }
        void optionsConfigControl_RendererColorSchemeChanged(object sender, GradientBrushChangedEventArgs e)
        {
            GraphicsLayer graphicsLayer = Layer as GraphicsLayer;

            if (graphicsLayer == null)
            {
                return;
            }

            graphicsLayer.ApplyColorRampGradientBrushToRenderer(e.GradientBrush);

            ClassBreaksRendererOptionsConfigControl rendererOptions = sender as ClassBreaksRendererOptionsConfigControl;

            if (rendererOptions != null) // refresh the renderer on the config control
            {
                rendererOptions.ClassBreaksRenderer = graphicsLayer.Renderer as ClassBreaksRenderer;
            }
            else
            {
                UniqueValueRendererOptionsConfigControl uniqueValueRendererOptions = sender as UniqueValueRendererOptionsConfigControl;
                if (uniqueValueRendererOptions != null)
                {
                    uniqueValueRendererOptions.UniqueValueRenderer = graphicsLayer.Renderer as UniqueValueRenderer;
                }
            }

            if (RendererSymbolSetContainerControl != null)
            {
                ClassBreaksRendererSymbolsConfigControl rendererSymbols = RendererSymbolSetContainerControl.Content as ClassBreaksRendererSymbolsConfigControl;
                if (rendererSymbols != null)
                {
                    rendererSymbols.RefreshSymbols();
                }
                else
                {
                    UniqueValueRendererSymbolsConfigControl uniqueSymbols = RendererSymbolSetContainerControl.Content as UniqueValueRendererSymbolsConfigControl;
                    if (uniqueSymbols != null)
                    {
                        uniqueSymbols.RefreshSymbols();
                    }
                }
            }
        }
        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;
                }
            }
        }
        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;
                    }
                }
            }
        }