void DeleteUniqueValueButton_Click(object sender, RoutedEventArgs e)
        {
            if (UniqueValueConfigItems == null)
            {
                return;
            }

            UniqueValueConfigControl uniqueValueConfigControl = UniqueValueConfigItems.SelectedItem as UniqueValueConfigControl;

            if (uniqueValueConfigControl == null || uniqueValueConfigControl.UniqueValue == null)
            {
                return;
            }

            if (UniqueValueRenderer != null)
            {
                UniqueValueRenderer.Infos.Remove(uniqueValueConfigControl.UniqueValue);
            }

            int prevIndex = UniqueValueConfigItems.SelectedIndex;

            UniqueValueConfigItems.Items.Remove(uniqueValueConfigControl);

            if (prevIndex > 0 && prevIndex <= UniqueValueConfigItems.Items.Count) // Remember .. we have a default symbol item at the top
            {
                UniqueValueConfigItems.SelectedIndex = prevIndex;                 // preserve selected item
            }
        }
        private void bindList()
        {
            if (UniqueValueConfigItems != null)
            {
                if (UniqueValueRenderer != null)
                {
                    // Add the default symbol config control
                    DefaultSymbolConfigControl defaultSymbolConfigControl = new DefaultSymbolConfigControl()
                    {
                        Symbol = UniqueValueRenderer.DefaultSymbol,
                        SymbolConfigProvider = SymbolConfigProvider,
                        GeometryType         = GeometryType,
                    };
                    defaultSymbolConfigControl.DefaultSymbolModified += new EventHandler <SymbolSelectedEventArgs>(defaultSymbolConfigControl_DefaultSymbolModified);
                    UniqueValueConfigItems.Items.Add(defaultSymbolConfigControl);
                    UniqueValueConfigItems.SelectedItem = defaultSymbolConfigControl;

                    foreach (UniqueValueInfo uniqueValueInfo in UniqueValueRenderer.Infos)
                    {
                        UniqueValueConfigControl uniqueValueConfigControl = createNewUniqueValueConfigControl(uniqueValueInfo);
                        UniqueValueConfigItems.Items.Add(uniqueValueConfigControl);
                    }
                }
            }
        }
        void UniqueValueConfigItems_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (UniqueValueConfigItems == null)
            {
                return;
            }

            UniqueValueConfigControl configControl = UniqueValueConfigItems.SelectedItem as UniqueValueConfigControl;

            if (configControl != null)
            {
                OnCurrentUniqueValueChanged(new CurrentUniqueValueChangedEventArgs()
                {
                    UniqueValue = configControl.UniqueValue,
                });
                return;
            }
            else
            {
                DefaultSymbolConfigControl defaultConfigControl = UniqueValueConfigItems.SelectedItem as DefaultSymbolConfigControl;
                if (defaultConfigControl != null)
                {
                    OnDefaultClassBreakBeingConfigured(new DefaultClassBreakBeingConfiguredEventArgs()
                    {
                        DefaultSymbol = defaultConfigControl.Symbol,
                    });
                    return;
                }
            }
        }
        public void DeleteCurrentSelectedUniqueValue()
        {
            if (UniqueValueConfigItems == null)
            {
                return;
            }

            UniqueValueConfigControl uniqueValueConfigControl = UniqueValueConfigItems.SelectedItem as UniqueValueConfigControl;

            if (uniqueValueConfigControl == null || uniqueValueConfigControl.UniqueValue == null)
            {
                return;
            }

            if (UniqueValueRenderer != null)
            {
                UniqueValueRenderer.Infos.Remove(uniqueValueConfigControl.UniqueValue);
            }

            int prevIndex = UniqueValueConfigItems.SelectedIndex;

            UniqueValueConfigItems.Items.Remove(uniqueValueConfigControl);

            if (prevIndex > 0 && prevIndex < UniqueValueConfigItems.Items.Count) // Remember .. we have a default symbol item at the top
            {
                UniqueValueConfigItems.SelectedIndex = prevIndex;                // preserve selected item
            }
        }
        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;
                        }
                    }
                }
            }
        }
        private UniqueValueConfigControl createNewUniqueValueConfigControl(UniqueValueInfo uniqueValueInfo)
        {
            UniqueValueConfigControl uniqueValueConfigControl = new UniqueValueConfigControl()
            {
                UniqueValue          = uniqueValueInfo,
                SymbolConfigProvider = SymbolConfigProvider,
                GeometryType         = GeometryType,
            };

            uniqueValueConfigControl.UniqueValueModified += uniqueValueConfigControl_UniqueValueModified;
            return(uniqueValueConfigControl);
        }
        void uniqueValueConfigControl_UniqueValueModified(object sender, EventArgs e)
        {
            if (UniqueValueConfigItems != null)
            {
                UniqueValueConfigControl control = sender as UniqueValueConfigControl;
                if (control != null && UniqueValueConfigItems.SelectedItem == control && control.UniqueValue != null)
                {
                    if (SymbolConfigControl != null)
                    {
                        SymbolConfigControl.Symbol = control.UniqueValue.Symbol;
                    }
                }
            }

            OnUniqueValueRendererModified(EventArgs.Empty);
        }
        void ValueTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (UniqueValueConfigItems == null)
            {
                return;
            }

            UniqueValueConfigControl uniqueValueConfigControl = UniqueValueConfigItems.SelectedItem as UniqueValueConfigControl;

            if (uniqueValueConfigControl == null || uniqueValueConfigControl.UniqueValue == null)
            {
                return;
            }

            uniqueValueConfigControl.UpdateUniqueValue(ValueTextBox.Text);

            OnUniqueValueRendererModified(EventArgs.Empty);
        }
        public void AddNewUniqueValue(object newValue, FieldType fieldType)
        {
            if (UniqueValueRenderer == null)
            {
                return;
            }

            UniqueValueInfo newUniqueValue = new UniqueValueInfoObj()
            {
                SerializedValue                        = newValue,
                Symbol                                 = UniqueValueRenderer.DefaultSymbol != null?UniqueValueRenderer.DefaultSymbol.CloneSymbol() : UniqueValueRenderer.GetDefaultSymbolClone(GeometryType),
                                             FieldType = fieldType,
            };

            UniqueValueConfigControl uniqueValueConfigControl = createNewUniqueValueConfigControl(newUniqueValue);

            UniqueValueRenderer.Infos.Add(newUniqueValue);

            if (UniqueValueConfigItems != null)
            {
                UniqueValueConfigItems.Items.Add(uniqueValueConfigControl);
                UniqueValueConfigItems.SelectedItem = uniqueValueConfigControl;
            }
        }
        void UniqueValueConfigItems_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (UniqueValueConfigItems == null)
            {
                return;
            }

            if (PreviousUniqueValueButton != null)
            {
                PreviousUniqueValueButton.IsEnabled = UniqueValueConfigItems.SelectedIndex > 0;
            }

            if (NextUniqueValueButton != null)
            {
                // remember .. the first item in the list is the default symbol
                if (UniqueValueRenderer != null)
                {
                    NextUniqueValueButton.IsEnabled = UniqueValueConfigItems.SelectedIndex < UniqueValueRenderer.Infos.Count;
                }
            }

            UniqueValueConfigControl uniqueValueConfigControl = UniqueValueConfigItems.SelectedItem as UniqueValueConfigControl;

            if (uniqueValueConfigControl != null)
            {
                if (uniqueValueConfigControl.UniqueValue == null)
                {
                    return;
                }

                if (DeleteUniqueValueButton != null)
                {
                    DeleteUniqueValueButton.IsEnabled = true;
                }

                if (SymbolConfigControl != null && uniqueValueConfigControl.UniqueValue != null)
                {
                    SymbolConfigControl.Symbol = uniqueValueConfigControl.UniqueValue.Symbol;
                }

                if (ValueTextBox != null)
                {
                    ValueTextBox.IsEnabled = true;
                    if (uniqueValueConfigControl.UniqueValue.Value != null)
                    {
                        ValueTextBox.TextChanged -= ValueTextBox_TextChanged;
                        ValueTextBox.Text         = uniqueValueConfigControl.UniqueValue.Value.ToString();
                        ValueTextBox.TextChanged += ValueTextBox_TextChanged;
                    }
                }
            }
            else
            {
                DefaultSymbolConfigControl defaultSymbolConfigControl = UniqueValueConfigItems.SelectedItem as DefaultSymbolConfigControl;
                if (defaultSymbolConfigControl != null)
                {
                    if (SymbolConfigControl != null)
                    {
                        SymbolConfigControl.Symbol = defaultSymbolConfigControl.Symbol;
                    }

                    if (DeleteUniqueValueButton != null)
                    {
                        DeleteUniqueValueButton.IsEnabled = false;
                    }

                    if (ValueTextBox != null)
                    {
                        ValueTextBox.IsEnabled    = false;
                        ValueTextBox.TextChanged -= ValueTextBox_TextChanged;
                        ValueTextBox.Text         = "";
                        ValueTextBox.TextChanged += ValueTextBox_TextChanged;
                    }
                }
            }
        }
 private UniqueValueConfigControl createNewUniqueValueConfigControl(UniqueValueInfo uniqueValueInfo)
 {
     UniqueValueConfigControl uniqueValueConfigControl = new UniqueValueConfigControl()
     {
         UniqueValue = uniqueValueInfo,
         SymbolConfigProvider = SymbolConfigProvider,
         GeometryType = GeometryType,
     };
     uniqueValueConfigControl.UniqueValueModified += uniqueValueConfigControl_UniqueValueModified;
     return uniqueValueConfigControl;
 }