示例#1
0
        private void AddAttribute(object sender, EventArgs e)
        {
            if (attributeText.Text.Length == 0)
            {
                MessageBox.Show(this, "Please enter the name of an attribute to create", "Add Attribute", MessageBoxButtons.OK, MessageBoxIcon.Information);
                attributeText.Focus();
                return;
            }

            if (parent.HasAttribute(attributeText.Text))
            {
                MessageBox.Show(this, "The attribute you have specified already exists", "Add Attribute", MessageBoxButtons.OK, MessageBoxIcon.Information);
                attributeText.Focus();
                return;
            }

            // TODO: H: this doesn't display (need to update controls)
            parent.SetAttribute(attributeText.Text, "");

            AttributeWidget aw = new AttributeWidgetText(parent, attributeText.Text, ValidationManager);

            aw.Location = new Point(4, 0);
            aw.Width    = this.Width - 1;
            aw.Height   = 22;
            controls.Add(aw);

            controls.Sort(new AttributeWidgetSorter());

            FilterItems(attributeText.Text);
        }
示例#2
0
        protected override void ProcessUpdate()
        {
            int       y     = 4;
            ArrayList valid = new ArrayList();

            lock ( controls )
            {
                controls.Clear();

                AttributeWidget aw;
                foreach (string name in ValidationManager.GetDefinedAttributeNames(parent))
                {
                    valid.Add(name);

                    switch (ValidationManager.GetAttributeType(parent, name))
                    {
                    case AttributeType.Enumerated:
                        aw = new AttributeWidgetEnum(parent, name, ValidationManager);
                        break;

                    default:
                        aw = new AttributeWidgetText(parent, name, ValidationManager);
                        break;
                    }
                    aw.Location = new Point(4, y);
                    aw.Width    = this.Width - 1;
                    aw.Height   = 22;
                    controls.Add(aw);
                    y += aw.Height;
                    Application.DoEvents();
                }

                if (parent != null)
                {
                    foreach (XmlAttribute attr in parent.Attributes)
                    {
                        if (valid.Contains(attr.Name))
                        {
                            continue;
                        }

                        aw          = new AttributeWidgetText(parent, attr.Name, ValidationManager);
                        aw.Location = new Point(4, y);
                        aw.Width    = this.Width - 1;
                        aw.Height   = 22;
                        controls.Add(aw);
                        y += aw.Height;
                        Application.DoEvents();
                    }
                }

                controls.Sort(new AttributeWidgetSorter());
            }
        }