Exemple #1
0
 public TreeNode AddClass(TreeNode parent, Class cls)
 {
     TreeNode node =  AddNode(cls.IsAbstract ? NodeType.Abstract : NodeType.Class, parent, cls.Name, new TreeNodeMetaData()
     {
         Class = cls
     }, cls.Accessibility);
     foreach (var ctor in cls.Constructors)
     {
         AddNode(NodeType.Constructor, node, "Constructor", new TreeNodeMetaData()
         {
             Constructor = ctor
         }, ctor.Accessibility, null, ctor.Parameters);
     }
     return node;
 }
Exemple #2
0
        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();
        }
Exemple #3
0
 public AddCtor(Class cls)
 {
     InitializeComponent();
     Class = cls;
 }