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;
                        }
                    }
                }
            }
        }
Пример #2
0
        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
            }
        }