Beispiel #1
0
        /**********************************************************************************************//**
        * Event handler. Called by ComboBox_SelectType for selection changed events.
        *
        * \author  Ilan Hindy
        * \date    29/09/2016
        *
        * \param   sender  Source of the event.
        * \param   e       Selection changed event information.
        *
        **************************************************************************************************/

        private void ComboBox_SelectType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            FillComboBox(ComboBox_SelectValue, TypesUtility.GetPossibleValues((string)ComboBox_SelectType.SelectedItem));
            if (ComboBox_SelectValue.Items.Count != 0)
            {
                ComboBox_SelectValue.SelectedIndex = 0;
            }
        }
Beispiel #2
0
        /**********************************************************************************************//**
        * Event handler. Called by ListBox_Elements for selection changed events.
        *
        * \author  Ilan Hindy
        * \date    29/09/2016
        *
        * \param   sender  Source of the event.
        * \param   e       Selection changed event information.
        *
        **************************************************************************************************/

        private void ListBox_Elements_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (listOfAttributes)
            {
                Type      type;
                string    valueString;
                Attribute attribute;
                if (ListBox_Elements.SelectedItem == null)
                {
                    type        = typeof(string);
                    valueString = "";
                }
                else
                {
                    attribute   = ((List <Attribute>)list)[ListBox_Elements.SelectedIndex];
                    type        = attribute.Value.GetType();
                    valueString = attribute.GetValueToString();
                }
                if (type.IsEnum || type.Equals(typeof(bool)))
                {
                    FillComboBox(ComboBox_Replace_SelectValue, TypesUtility.GetPossibleValues(type.ToString()));
                    ComboBox_Replace_SelectValue.SelectedItem = valueString;
                    ComboBox_Replace_SelectValue.Visibility   = System.Windows.Visibility.Visible;
                    TextBox_Replace_AddValue.Visibility       = System.Windows.Visibility.Collapsed;
                    Button_Edit.Visibility         = System.Windows.Visibility.Collapsed;
                    Button_ReplaceValue.Visibility = System.Windows.Visibility.Visible;
                    return;
                }
                if (type.IsPrimitive || type.Equals(typeof(string)))
                {
                    TextBox_Replace_AddValue.Text           = valueString;
                    ComboBox_Replace_SelectValue.Visibility = System.Windows.Visibility.Collapsed;
                    TextBox_Replace_AddValue.Visibility     = System.Windows.Visibility.Visible;
                    Button_Edit.Visibility         = System.Windows.Visibility.Collapsed;
                    Button_ReplaceValue.Visibility = System.Windows.Visibility.Visible;
                    return;
                }
                ComboBox_Replace_SelectValue.Visibility = System.Windows.Visibility.Collapsed;
                TextBox_Replace_AddValue.Visibility     = System.Windows.Visibility.Collapsed;
                Button_Edit.Visibility         = System.Windows.Visibility.Visible;
                Button_ReplaceValue.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                if (ListBox_Elements.SelectedItem != null)
                {
                    TextBox_Replace_AddValue.Text = ((ListBoxItem)(ListBox_Elements.SelectedValue)).Content.ToString();
                }
                else
                {
                    TextBox_Replace_AddValue.Text = TypesUtility.GetDefault(list.GetType().GenericTypeArguments[0]).ToString();
                    TextBox_AddValue.Text         = TypesUtility.GetDefault(list.GetType().GenericTypeArguments[0]).ToString();
                }
            }
        }