private void дублироватьToolStripMenuItem_Click(object sender, EventArgs e) { Element el = Program.getElementById(curTempTabPage.TreeView.SelectedNode.Name, curTempTabPage.Id); Element dublEl = null; if (el is null) { return; } if (el.Parent is null) { return; } switch (el.GetType().ToString()) { case "VisualTemplate.Signal": Signal s = el as Signal; dublEl = (Signal)s.Clone(); el.Parent.Signals.Add((Signal)dublEl); dublEl.restoreParent(el.Parent); Program.addToTree(dublEl, curTempTabPage.TreeView, curTempTabPage.Id, curTempTabPage.TreeView.SelectedNode.Parent); //curTempTabPage.TreeView.SelectedNode.Expand(); break; case "VisualTemplate.Cycle": Cycle c = el as Cycle; dublEl = (Cycle)c.Clone(); el.Parent.Cycles.Add((Cycle)dublEl); dublEl.restoreParent(el.Parent); Program.addToTree(dublEl, curTempTabPage.TreeView, curTempTabPage.Id, curTempTabPage.TreeView.SelectedNode.Parent); //curTempTabPage.TreeView.SelectedNode.Expand(); break; } }
private void bt_Past_Click(object sender, EventArgs e) { Element el = Program.getElementById(treeView1.SelectedNode.Name); Element copyEl = null; //switch (el.GetType().ToString()) //{ // case "VisualTemplate.Signal": // Signal s = el as Signal; // //s.Add((Signal)Program.bufSignal.Clone()); // break; // case "VisualTemplate.Cycle": // Cycle c = el as Cycle; // c.Add((Signal)Program.bufSignal.Clone()); // //treeView1.Nodes.Clear(); // //Program.addToTree(Program.t, treeView1); // //treeView1.ExpandAll(); // break; //} if (Program.bufElem.GetType().ToString() == "VisualTemplate.Signal") { Signal bs = Program.bufElem as Signal; copyEl = (Signal)bs.Clone(); el.Add((Signal)copyEl); } else if (Program.bufElem.GetType().ToString() == "VisualTemplate.Cycle") { Cycle bc = Program.bufElem as Cycle; copyEl = (Cycle)bc.Clone(); el.Add((Cycle)copyEl); Program.newVarsInDic((Cycle)copyEl); } Program.addToTree(copyEl, treeView1, treeView1.SelectedNode); // treeView1.Nodes.Clear(); // Program.addToTree(Program.t, treeView1); // treeView1.Nodes[0].Expand(); // treeView1.ExpandAll(); }
private void pastToolStripButton1_Click(object sender, EventArgs e) { Element el = Program.getElementById(curTempTabPage.TreeView.SelectedNode.Name, curTempTabPage.Id); Element copyEl = null; if (curTempTabPage.TreeView.SelectedNode.Name == "0") { if (Program.bufElem.GetType().ToString() == "VisualTemplate.Cycle") { Cycle bc = Program.bufElem as Cycle; copyEl = (Cycle)bc.Clone(); curTempTabPage.Template.Cycles.Add((Cycle)copyEl); Program.newVarsInDic((Cycle)copyEl); Program.addToTree(copyEl, curTempTabPage.TreeView, curTempTabPage.Id, curTempTabPage.TreeView.SelectedNode); curTempTabPage.TreeView.SelectedNode.Expand(); return; } } if (el is null) { return; } if (Program.bufElem.GetType().ToString() == "VisualTemplate.Signal") { Signal bs = Program.bufElem as Signal; copyEl = (Signal)bs.Clone(); el.Add((Signal)copyEl); } else if (Program.bufElem.GetType().ToString() == "VisualTemplate.Cycle") { Cycle bc = Program.bufElem as Cycle; copyEl = (Cycle)bc.Clone(); el.Add((Cycle)copyEl); Program.newVarsInDic((Cycle)copyEl); } Program.addToTree(copyEl, curTempTabPage.TreeView, curTempTabPage.Id, curTempTabPage.TreeView.SelectedNode); curTempTabPage.TreeView.SelectedNode.Expand(); }