private void cmNsAddClass_Click(object sender, EventArgs e) { NodeType nodeType = (NodeType) ((ToolStripMenuItem) sender).Tag; AddClass ac = new AddClass(nodeType, Tree.GetNamespace(tvProject.SelectedNode)); if (ac.ShowDialog(this) == DialogResult.OK) { if (nodeType != NodeType.Interface) { Class cls = new Class() { Accessibility = ac.Accessibility, Name = ac.ClassName, Namespace = Tree.GetNamespace(tvProject.SelectedNode), IsAbstract = nodeType == NodeType.Abstract }; if(ac.DefaultCtor) cls.Constructors.Add(new Constructor() {Accessibility = ac.Accessibility, Class = cls}); cls.Namespace.Classes.Add(cls); Program.Db.Class.Add(cls); Program.Db.SaveChanges(); Tree.AddClass(tvProject.SelectedNode, cls); } else { Interface intf = new Interface() { Accessibility = ac.Accessibility, Name = ac.ClassName, Namespace = Tree.GetNamespace(tvProject.SelectedNode) }; intf.Namespace.Interfaces.Add(intf); Program.Db.Interfaces.Add(intf); Program.Db.SaveChanges(); Tree.AddInterface(tvProject.SelectedNode, intf); } tvProject.SelectedNode.Expand(); } ac.Dispose(); }
public TreeNode AddInterface(TreeNode parent, Interface intf) { TreeNode node = AddNode(NodeType.Interface, parent, intf.Name, new TreeNodeMetaData() { Interface = intf }, intf.Accessibility); return node; }