Exemplo n.º 1
0
 private void cbxElementType_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ElementValueDict != null)
     {
         ComboBox          typeBox      = cbxElementType;
         ScriptElementType selectedType = (ScriptElementType)Enum.Parse(typeof(ScriptElementType), typeBox.SelectedItem.ToString().Replace(" ", ""));
         string            elementValue = ElementValueDict[selectedType];
         txtDefaultValue.Text = elementValue;
     }
 }
Exemplo n.º 2
0
        public frmAddElement(string elementName, ScriptElementType elementType, string elementValue)
        {
            InitializeComponent();
            cbxElementType.DataSource = Enum.GetValues(typeof(ScriptElementType)).Descriptions();
            Text                         = "edit element";
            lblHeader.Text               = "edit element";
            txtElementName.Text          = elementName;
            cbxElementType.SelectedIndex = cbxElementType.Items.IndexOf(elementType.Description());
            txtDefaultValue.Text         = elementValue;

            _isEditMode          = true;
            _editingVariableName = elementName;
        }
Exemplo n.º 3
0
        private void uiBtnNew_Click(object sender, EventArgs e)
        {
            //create element editing form
            frmAddElement addElementForm = new frmAddElement();

            addElementForm.ScriptElements = ScriptElements;

            ExpandUserElementNode();

            //validate if user added element
            if (addElementForm.ShowDialog() == DialogResult.OK)
            {
                ScriptElementType addElementFormType = (ScriptElementType)Enum.Parse(typeof(ScriptElementType),
                                                                                     addElementForm.cbxElementType.SelectedItem.ToString().Replace(" ", ""));

                //add newly edited node
                AddUserElementNode(_userElementParentNode, addElementForm.txtElementName.Text, addElementFormType,
                                   addElementForm.txtDefaultValue.Text);
            }
        }
Exemplo n.º 4
0
        private void AddUserElementNode(TreeNode parentNode, string elementName, ScriptElementType elementType, string elementText)
        {
            //add new node and sort
            var childNode = new TreeNode(elementName);

            if (elementText == string.Empty)
            {
                elementText = _emptyValue;
            }

            TreeNode elementTypeNode = new TreeNode("TypeNode");

            elementTypeNode.Text = _leadingType + elementType.Description();
            TreeNode elementValueNode = new TreeNode("ValueNode");

            elementValueNode.Text = _leadingValue + elementText;

            childNode.Nodes.Add(elementTypeNode);
            childNode.Nodes.Add(elementValueNode);

            parentNode.Nodes.Add(childNode);
            tvScriptElements.Sort();
            ExpandUserElementNode();
        }
Exemplo n.º 5
0
        private void tvScriptElements_DoubleClick(object sender, EventArgs e)
        {
            //handle double clicks outside
            if (tvScriptElements.SelectedNode == null)
            {
                return;
            }

            //if parent was selected return
            if (tvScriptElements.SelectedNode.Parent == null)
            {
                //user selected top parent
                return;
            }

            //top node check
            var topNode = GetSelectedTopNode();

            if (topNode.Text != "My Task Elements")
            {
                return;
            }

            string            elementName, elementValue;
            ScriptElementType elementType;
            TreeNode          parentNode;

            if (tvScriptElements.SelectedNode.Nodes.Count == 0)
            {
                parentNode  = tvScriptElements.SelectedNode.Parent;
                elementName = tvScriptElements.SelectedNode.Parent.Text;
                elementType = (ScriptElementType)Enum.Parse(typeof(ScriptElementType), tvScriptElements.SelectedNode.Parent.Nodes[0].Text
                                                            .Replace(_leadingType, "").Replace(_emptyType, "").Replace(" ", ""));
                elementValue = tvScriptElements.SelectedNode.Parent.Nodes[1].Text.Replace(_leadingValue, "").Replace(_emptyValue, "");
            }
            else
            {
                parentNode  = tvScriptElements.SelectedNode;
                elementName = tvScriptElements.SelectedNode.Text;
                elementType = (ScriptElementType)Enum.Parse(typeof(ScriptElementType), tvScriptElements.SelectedNode.Nodes[0].Text
                                                            .Replace(_leadingType, "").Replace(_emptyType, "").Replace(" ", ""));
                elementValue = tvScriptElements.SelectedNode.Nodes[1].Text.Replace(_leadingValue, "").Replace(_emptyValue, "");
            }

            //create element editing form
            frmAddElement addElementForm = new frmAddElement(elementName, elementType, elementValue);

            addElementForm.ScriptElements = ScriptElements;

            ExpandUserElementNode();

            //validate if user added element
            if (addElementForm.ShowDialog() == DialogResult.OK)
            {
                //remove parent
                parentNode.Remove();

                ScriptElementType addElementFormType = (ScriptElementType)Enum.Parse(typeof(ScriptElementType),
                                                                                     addElementForm.cbxElementType.SelectedItem.ToString().Replace(" ", ""));

                //add newly edited node
                AddUserElementNode(_userElementParentNode, addElementForm.txtElementName.Text, addElementFormType,
                                   addElementForm.txtDefaultValue.Text);
            }
        }