Esempio n. 1
0
 private void OnNodeSelected(TreeNode selectedNode)
 {
     if (AttributeHandler.CheckIfHasAttributes(selectedNode.Text))
     {
         btnEditNode.Enabled = true;
     }
     else
     {
         btnEditNode.Enabled = false;
     }
 }
Esempio n. 2
0
        private void OnEditNodeStarted(TreeNode selectedNode)
        {
            var       topMargin  = 20;
            const int leftMargin = 35;

            var attributes = AttributeHandler.ParseStringOnAttributes(selectedNode.Text);

            pnlAttributes.Controls.Clear();
            _visualAttributeItems.Clear();
            foreach (AttributeItem t in attributes)
            {
                var textBox = new TextBox();
                var label   = new Label
                {
                    Parent   = pnlAttributes,
                    Top      = topMargin,
                    Text     = t.Key,
                    Left     = leftMargin,
                    AutoSize = true
                };
                textBox.Left      = leftMargin;
                textBox.Parent    = pnlAttributes;
                textBox.Top       = topMargin + 20;
                textBox.Text      = t.Value;
                textBox.Width     = 450;
                textBox.MaxLength = 82;

                textBox.KeyPress += (sender, e) =>
                {
                    if (e.KeyChar == '"')
                    {
                        e.Handled = true;
                    }
                };

                topMargin += 60;

                var visualAttributeItem = new VisualAttributeItem(textBox, label);
                _visualAttributeItems.Add(visualAttributeItem);
            }
        }
Esempio n. 3
0
        private void OnSaveAttributes(TreeNode selectedNode)
        {
            string endPart;

            if (selectedNode.Text.EndsWith("/>"))
            {
                endPart = " />";
            }
            else
            {
                endPart = ">";
            }
            var parts = selectedNode.Text.Split(' ');

            var attributes = new List <AttributeItem>();

            foreach (var visualAttributeItem in _visualAttributeItems)
            {
                var attribute = new AttributeItem(visualAttributeItem.KeyLabel.Text, visualAttributeItem.ValueTextBox.Text);
                attributes.Add(attribute);
            }

            selectedNode.Text = parts[0] + @" " + AttributeHandler.TransformAttributesListToString(attributes) + endPart;
        }