Ejemplo n.º 1
0
        private void RefreshButtons2()
        {
            XIMMappingItem item = _listViewCtrl.GetSelectedItem();

            this.buttonDelete.Enabled     = (item != null);
            this.buttonAddChild.Enabled   = (item != null && XIMHelper.IsComplex(item.Element.Type));
            this.buttonAddElement.Enabled = (item != null);
        }
Ejemplo n.º 2
0
        private void buttonAddChild_Click(object sender, EventArgs e)
        {
            // create new child
            XIMMappingItem item = _listViewCtrl.GetSelectedItem();

            if (item == null || !XIMHelper.IsComplex(item.Element.Type))
            {
                return;
            }

            FormElement frm = new FormElement(item.Element);

            if (frm.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            XmlElement ele = frm.Element;

            // expand old child
            if (listViewMain.SelectedItems.Count > 0)
            {
                XmlListViewItem <XIMMappingItem> xitem = listViewMain.SelectedItems[0] as XmlListViewItem <XIMMappingItem>;
                xitem.Checked = true;
            }

            // check if child with the same name is exist
            List <XIMMappingItem> list = _listViewCtrl.GetCurrentList();

            foreach (XIMMappingItem i in list)
            {
                if (i.Element.IsChildOf(item.Element) &&
                    i.Element.GetLastName() == ele.GetLastName())
                {
                    MessageBox.Show(this, "This element already exists.", "Warning",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            // insert new child
            XIMMappingItem citem = new XIMMappingItem(ele);
            int            index = list.IndexOf(item);

            list.Insert(index + 1, citem);

            // display new child
            _listViewCtrl.RefreshList(list);

            foreach (XmlListViewItem <XIMMappingItem> xi in listViewMain.Items)
            {
                if (xi.Item == citem)
                {
                    xi.Selected = true;
                    xi.EnsureVisible();
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public bool HasSelectedItem()
        {
            T t = GetSelectedItem();

            return(t != null && !XIMHelper.IsComplex(t.Element.Type));
        }