private void AttributeTree_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F2)
            {
                if (AttributeTree.SelectedNode != null)
                {
                    AttributeTree.StartLabelEdit();
                }
            }
            else if (e.KeyCode == Keys.Delete)
            {
                TreeNode selectedNode = AttributeTree.SelectedNode;
                if (selectedNode == null || selectedNode == addAttributeNode || selectedNode.IsAddParameterNode())
                {
                    return;
                }

                if (selectedNode.Parent == null)
                {
                    _attributes.Remove((Attribute)selectedNode.Tag);
                    IsDirty = true;

                    AttributeTree.Nodes.Remove(selectedNode);
                }
                else
                {
                    TreeNode  attributeNode = selectedNode.Parent;
                    Attribute attribute     = (Attribute)attributeNode.Tag;
                    attribute.Parameters.Remove((AttributeParameter)selectedNode.Tag);
                    IsDirty = true;

                    attributeNode.Nodes.Remove(selectedNode);
                    SetParameterIcons(attributeNode.Nodes);
                }
            }
        }
        private void AttributeTree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (e.Node == addAttributeNode)
            {
                string newAttributeLabel = e.Label;
                e.CancelEdit = true;

                Attribute attribute = new Attribute(_store)
                {
                    Name = newAttributeLabel
                };
                _attributes.Add(attribute);
                IsDirty = true;

                TreeNode newAttribute = AttributeTree.Nodes.Insert(AttributeTree.Nodes.Count - 1, newAttributeLabel);
                newAttribute.Tag = attribute;
                TreeNode addParameter = CreateAddParameterNode(newAttribute);
                newAttribute.Expand();

                AttributeTree.BeginInvoke((Action)(() =>
                {
                    AttributeTree.SelectedNode = addParameter;
                    AttributeTree.StartLabelEdit();
                }));
            }
            else if (e.Node.IsAddParameterNode())
            {
                TreeNode  addParameter      = e.Node;
                TreeNode  attributeNode     = e.Node.Parent;
                Attribute attribute         = attributeNode.Tag as Attribute;
                string    newParameterLabel = e.Label;
                e.CancelEdit = true;

                AttributeParameter parameter = null;
                NamedPropertyEvaluation(newParameterLabel,
                                        (value) =>
                {
                    newParameterLabel = value;
                    parameter         = new AttributeParameter(_store)
                    {
                        Value = value
                    };
                },
                                        (name, value) =>
                {
                    newParameterLabel = string.Format("{0} = {1}", name, value);
                    parameter         = new AttributeParameter(_store)
                    {
                        Name = name, Value = value
                    };
                }
                                        );
                attribute.Parameters.Add(parameter);
                IsDirty = true;

                TreeNode newParameter = addParameter.Parent.Nodes.Insert(addParameter.Parent.Nodes.Count - 1, newParameterLabel);
                newParameter.Tag = parameter;
                SetParameterIcons(attributeNode.Nodes);

                AttributeTree.BeginInvoke((Action)(() =>
                {
                    AttributeTree.SelectedNode = addParameter;
                    AttributeTree.StartLabelEdit();
                }));
            }
            else
            {
                if (e.Node.Tag is Attribute)
                {
                    ((Attribute)e.Node.Tag).Name = e.Label;
                    e.Node.Text = e.Label;
                }
                else if (e.Node.Tag is AttributeParameter)
                {
                    AttributeParameter property = (AttributeParameter)e.Node.Tag;
                    NamedPropertyEvaluation(e.Label,
                                            (value) =>
                    {
                        e.Node.Text    = value;
                        property.Name  = null;
                        property.Value = value;
                    },
                                            (name, value) =>
                    {
                        e.Node.Text    = string.Format("{0} = {1}", name, value);
                        property.Name  = name;
                        property.Value = value;
                    }
                                            );
                }
                IsDirty = true;
            }
        }