Beispiel #1
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            DisableControls();
            TreeNodeTag nodeTag = e.Node.Tag as TreeNodeTag;

            if (nodeTag != null)
            {
                if (nodeTag.NodeType.IsValueType || nodeTag.Value is String)
                {
                    if (nodeTag.PropertiesInfo.CanWrite)
                    {
                        chosenNode             = e.Node;
                        propertyBox.Enabled    = true;
                        propertyButton.Enabled = true;
                        if (nodeTag.Value is int)
                        {
                            numericUpDown.Value   = (int)nodeTag.Value;
                            numericUpDown.Enabled = true;
                        }
                        else if (nodeTag.Value is String)
                        {
                            textBox.Text    = nodeTag.Value.ToString();
                            textBox.Enabled = true;
                        }
                        else if (nodeTag.Value is bool)
                        {
                            if ((bool)nodeTag.Value)
                            {
                                boolComboBox.SelectedIndex = 0;
                            }
                            else
                            {
                                boolComboBox.SelectedIndex = 1;
                            }
                            boolComboBox.Enabled = true;
                        }
                        else if (nodeTag.Value is double)
                        {
                            doubleBox.Text    = nodeTag.Value.ToString();
                            doubleBox.Enabled = true;
                        }
                        else
                        {
                            foreach (var item in Enum.GetValues(nodeTag.Value.GetType()))
                            {
                                enumComboBox.Items.Add(item);
                                if (item.Equals(nodeTag.Value))
                                {
                                    enumComboBox.SelectedIndex = enumComboBox.Items.IndexOf(item);
                                }
                            }
                            enumComboBox.Enabled = true;
                        }
                    }
                }
            }
        }
 private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     selectedNode = e.Node.Tag as TreeNodeTag;
 }
Beispiel #3
0
 private void propertyButton_Click(object sender, EventArgs e)
 {
     if (chosenNode != null)
     {
         TreeNodeTag nodeTag   = (TreeNodeTag)chosenNode.Tag;
         TreeNodeTag parentTag = (TreeNodeTag)chosenNode.Parent.Tag;
         chosenNode.Name = nodeTag.PropertiesInfo.Name + " = ";
         if (nodeTag.Value is int)
         {
             chosenNode.Name += numericUpDown.Value.ToString(CultureInfo.InvariantCulture);
             nodeTag.PropertiesInfo.SetValue(parentTag.Value, (int)numericUpDown.Value);
             nodeTag.Value = numericUpDown.Value;
         }
         else if (nodeTag.Value is String)
         {
             chosenNode.Name += textBox.Text;
             nodeTag.PropertiesInfo.SetValue(parentTag.Value, textBox.Text);
             nodeTag.Value = textBox.Text;
         }
         else if (nodeTag.Value is bool)
         {
             if (boolComboBox.SelectedIndex == 0)
             {
                 chosenNode.Name += "True";
                 nodeTag.PropertiesInfo.SetValue(parentTag.Value, true);
                 nodeTag.Value = true;
             }
             else
             {
                 chosenNode.Name += "False";
                 nodeTag.PropertiesInfo.SetValue(parentTag.Value, false);
                 nodeTag.Value = false;
             }
         }
         else if (nodeTag.Value is double)
         {
             double temp;
             try
             {
                 temp = double.Parse(doubleBox.Text);
             }
             catch
             {
                 MessageBox.Show("Incorrect value");
                 return;
             }
             chosenNode.Name += temp.ToString(CultureInfo.InvariantCulture);
             nodeTag.PropertiesInfo.SetValue(parentTag.Value, temp);
             nodeTag.Value = temp;
         }
         else
         {
             var item = enumComboBox.Items[enumComboBox.SelectedIndex];
             chosenNode.Name += item.ToString();
             nodeTag.PropertiesInfo.SetValue(parentTag.Value, item);
             nodeTag.Value = item;
         }
     }
     DisableControls();
     RefreshTree();
 }
Beispiel #4
0
 private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     selectedNode = e.Node.Tag as TreeNodeTag;
 }