private void элементToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView.SelectedNode != null) { SeSchemaItem newssi = new SeSchemaItem(); TreeNode newTreeNode = new TreeNode(); newTreeNode.Text = newssi.ToString(); newTreeNode.Tag = newssi; treeView.SelectedNode.Nodes.Add(newTreeNode); if (treeView.SelectedNode.Tag is SeSchema) { SeSchema seSchema = (SeSchema)treeView.SelectedNode.Tag; newssi.Parent = seSchema; seSchema.SchemaItems.Add(newssi); } else if (treeView.SelectedNode.Tag is SeSchemaItem) { SeSchemaItem ssi = (SeSchemaItem)treeView.SelectedNode.Tag; if (ssi.SchemaItemsChildren == null) { ssi.SchemaItemsChildren = new List <SeSchemaItem>(); } newssi.Parent = ssi; ssi.SchemaItemsChildren.Add(newssi); } } else { MessageBox.Show("Для добавления нового элемента или схемы нажмите на ветку TreeView");//? } }
private void Button_Add_Click(object sender, EventArgs e) { if (treeView.SelectedNode != null) { SeSchemaItem newssi = new SeSchemaItem(); TreeNode newTreeNode = new TreeNode(); newTreeNode.Text = newssi.ToString(); newTreeNode.Tag = newssi; newTreeNode.ImageIndex = 1; treeView.SelectedNode.Nodes.Add(newTreeNode); if (treeView.SelectedNode.Tag is SeSchema) { SeSchema seSchema = (SeSchema)treeView.SelectedNode.Tag; newssi.Parent = seSchema; seSchema.SchemaItems.Add(newssi); } else if (treeView.SelectedNode.Tag is SeSchemaItem) { SeSchemaItem ssi = (SeSchemaItem)treeView.SelectedNode.Tag; if (ssi.SchemaItemsChildren == null) { ssi.SchemaItemsChildren = new List <SeSchemaItem>(); } newssi.Parent = ssi; ssi.SchemaItemsChildren.Add(newssi); } } else { MessageBox.Show("Для добавления нового элемента нажмите на ветку дерева"); } //UpdateTreeView(treeView1.Nodes); }
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { this.Cursor = Cursors.WaitCursor; treeView.BeginUpdate(); listView.Clear(); label_Ref.Text = ""; if (e.Node.Tag is SeSchemaItem) { //заполнение propertyGrid propertyGrid.SelectedObject = e.Node.Tag; //заполнение listView SeSchemaItem ssi = (SeSchemaItem)e.Node.Tag; if (ssi.Type == "") { var ssiOfType = ssi.FindElementOfType(); if (ssiOfType != null) { label_Ref.Text = "Упоминания:"; listView.Items.Add(ssiOfType.Name); listView.Items[listView.Items.Count - 1].Tag = ssiOfType; } } //изменение ComboBox при нажатии на разные схемы TreeNode tn = e.Node; while (tn.Parent.Tag is SeSchemaItem) { tn = tn.Parent; } if (tn.Parent.Tag is SeSchema && tn.Parent.Index < comboBox_SchemaList.Items.Count) { comboBox_SchemaList.SelectedIndex = tn.Parent.Index; } //обновление каждой дочерней ветки if (e.Node.Nodes != null) { foreach (TreeNode treenode in e.Node.Nodes) { SeSchemaItem ssichild = (SeSchemaItem)treenode.Tag; treenode.Text = ssichild.ToString(); } } } else if (e.Node.Tag is SeSchema) { comboBox_SchemaList.Refresh(); propertyGrid.SelectedObject = e.Node.Tag; if (e.Node.Index < comboBox_SchemaList.Items.Count) { comboBox_SchemaList.SelectedIndex = e.Node.Index; } } else { } treeView.EndUpdate(); this.Cursor = Cursors.Default; }
public void UpdateNode() { //treeView1.BeginUpdate(); if (treeView.SelectedNode.Tag is SeSchemaItem) { SeSchemaItem ssi = (SeSchemaItem)treeView.SelectedNode.Tag; treeView.SelectedNode.Text = ssi.ToString(); } else if (treeView.SelectedNode.Tag is SeSchema) { SeSchema ss = (SeSchema)treeView.SelectedNode.Tag; treeView.SelectedNode.Text = ss.ToString(); } //treeView1.EndUpdate(); }
private void listView_MouseClick(object sender, MouseEventArgs e) { if (listView.SelectedItems.Count != 0) { SeSchemaItem ssi = (SeSchemaItem)listView.SelectedItems[0].Tag; propertyGrid.SelectedObject = ssi; TreeNode[] treenodesParent = treeView.Nodes.Find(ssi.GetSchema(ssi).ToString(), false); TreeNode[] treenodes = treenodesParent[0].Nodes.Find(ssi.ToString() + ssi.Parent.ToString(), true); TreeNode eachTn = treenodes[0]; while (eachTn.Parent.Tag is SeSchemaItem) { eachTn.Parent.Expand(); eachTn = eachTn.Parent; } treeView.Focus(); treeView.SelectedNode = treenodes[0]; } }