Ejemplo n.º 1
0
        public override object Clone()
        {
            PlaceControl pc = new PlaceControl();

            pc.Location = this.Location;
            pc.NameID   = this.NameID;
            pc.Tokens   = this.Tokens;
            return(pc);
        }
Ejemplo n.º 2
0
        public ToolBox()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            #region Initialize TreeView
            TreeNode tnSimpleRoot = new TreeNode("Simple  ", 10, 10);
            tnSimpleRoot.NodeFont  = new Font(this.Font, FontStyle.Bold);
            tnSimpleRoot.BackColor = SystemColors.ControlDark;
            tnSimpleRoot.ForeColor = Color.White;

            TreeNode tn = new TreeNode("Input", 0, 0);
            Place    p  = new PlaceInput();
            PetriNetEditorMergeModule pnemm = new PetriNetEditorMergeModule(p);
            tn.Tag = pnemm;
            tnSimpleRoot.Nodes.Add(tn);

            tn     = new TreeNode("Operation", 1, 1);
            p      = new PlaceOperation();
            pnemm  = new PetriNetEditorMergeModule(p);
            tn.Tag = pnemm;
            tnSimpleRoot.Nodes.Add(tn);

            tn     = new TreeNode("Resource", 2, 2);
            p      = new PlaceResource();
            pnemm  = new PetriNetEditorMergeModule(p);
            tn.Tag = pnemm;
            tnSimpleRoot.Nodes.Add(tn);

            tn     = new TreeNode("Control", 3, 3);
            p      = new PlaceControl();
            pnemm  = new PetriNetEditorMergeModule(p);
            tn.Tag = pnemm;
            tnSimpleRoot.Nodes.Add(tn);

            tn     = new TreeNode("Output", 4, 4);
            p      = new PlaceOutput();
            pnemm  = new PetriNetEditorMergeModule(p);
            tn.Tag = pnemm;
            tnSimpleRoot.Nodes.Add(tn);

            tn = new TreeNode("Transition", 5, 5);
            Transition t = new Transition();
            pnemm  = new PetriNetEditorMergeModule(t);
            tn.Tag = pnemm;
            tnSimpleRoot.Nodes.Add(tn);

            tn = new TreeNode("Label", 6, 6);
            DescriptionLabel dl = new DescriptionLabel();
            pnemm  = new PetriNetEditorMergeModule(dl);
            tn.Tag = pnemm;
            tnSimpleRoot.Nodes.Add(tn);

            TreeNode tnAdvancedRoot = new TreeNode("Advanced  ", 10, 10);
            tnAdvancedRoot.NodeFont  = new Font(this.Font, FontStyle.Bold);
            tnAdvancedRoot.BackColor = SystemColors.ControlDark;
            tnAdvancedRoot.ForeColor = Color.White;

            tn = new TreeNode("Subsystem block", 7, 7);
            Subsystem s = new Subsystem();
            pnemm  = new PetriNetEditorMergeModule(s);
            tn.Tag = pnemm;
            tnAdvancedRoot.Nodes.Add(tn);

            tn = new TreeNode("In", 8, 8);
            Input i = new Input();
            pnemm  = new PetriNetEditorMergeModule(i);
            tn.Tag = pnemm;
            tnAdvancedRoot.Nodes.Add(tn);

            tn = new TreeNode("Out", 9, 9);
            Output o = new Output();
            pnemm  = new PetriNetEditorMergeModule(o);
            tn.Tag = pnemm;
            tnAdvancedRoot.Nodes.Add(tn);

            tn = new TreeNode("Resource-operation", 2, 2);
            Transition t1 = new Transition();
            pnemm = new PetriNetEditorMergeModule();
            pnemm.Add(t1);
            PlaceOperation po = new PlaceOperation();
            po.Location = new Point(150, 0);
            pnemm.Add(po);
            PlaceResource pr = new PlaceResource();
            pr.Tokens   = 1;
            pr.Location = new Point(150, 100);
            pnemm.Add(pr);
            Transition t2 = new Transition();
            t2.Location = new Point(300, 0);
            pnemm.Add(t2);
            Connection cn = new Connection(t1, po, 1, 1, new Point(t1.Width, (int)(t1.Height / 2)), new Point(0, (int)(po.Height / 2)), 1, true);
            pnemm.Add(cn);
            cn = new Connection(po, t2, 1, 1, new Point(po.Width, (int)(po.Height / 2)), new Point(0, (int)(t2.Height / 2)), 1, true);
            pnemm.Add(cn);
            cn = new Connection(t2, pr, 1, 1, new Point(t2.Width, (int)(3 * t2.Height / 4)), new Point(pr.Width, (int)(pr.Height / 2)), 1, true);
            pnemm.Add(cn);
            cn = new Connection(pr, t1, 1, 1, new Point(0, (int)(pr.Height / 2)), new Point(0, (int)(3 * t1.Height / 4)), 1, true);
            pnemm.Add(cn);
            tn.Tag = pnemm;
            tnAdvancedRoot.Nodes.Add(tn);

            tvToolBox.BeginUpdate();
            tvToolBox.Nodes.Add(tnSimpleRoot);
            tvToolBox.Nodes.Add(tnAdvancedRoot);

            tvToolBox.ExpandAll();

            tvToolBox.EndUpdate();
            tvToolBox.Refresh();
            #endregion

            tvToolBox.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.tvToolBox_BeforeSelect);
            tvToolBox.Click        += new EventHandler(tvToolBox_Click);
            tvToolBox.MouseDown    += new MouseEventHandler(tvToolBox_MouseDown);

            //Workaround HScroll bug
            TreeViewHelper.DisableHScroller(this.tvToolBox.Handle);
            TreeViewHelper.EnableHScroller(this.tvToolBox.Handle);
        }