Beispiel #1
0
        public object Clone(Subsystem s)
        {
            if (this.pnd != null)
            {
                SubsystemEditor se = new SubsystemEditor(this.pnd, s);

                Hashtable ht = new Hashtable();

                for (int i = 0; i < this.pneEditor.Objects.Count; i++)
                {
                    if (this.pneEditor.Objects[i] is ConnectableControl && this.pneEditor.Objects[i] is ICloneable)
                    {
                        ConnectableControl cc = (ConnectableControl)((ICloneable)this.pneEditor.Objects[i]).Clone();
                        ht.Add(this.pneEditor.Objects[i], cc);
                        if (!(cc is Input) && !(cc is Output))
                        {
                            cc.Index = this.pnd.InstanceCounter.GetAndIncreaseInstanceCount(cc);
                        }
                        else
                        {
                            cc.Index = ((ConnectableControl)this.pneEditor.Objects[i]).Index;
                        }
                        se.alDeserializedObjects.Add(cc);
                    }
                    else if (this.pneEditor.Objects[i] is DescriptionLabel && this.pneEditor.Objects[i] is ICloneable)
                    {
                        DescriptionLabel dl = (DescriptionLabel)((ICloneable)this.pneEditor.Objects[i]).Clone();
                        ht.Add(this.pneEditor.Objects[i], dl);
                        dl.Index = ((DescriptionLabel)this.pneEditor.Objects[i]).Index;
                        se.alDeserializedObjects.Add(dl);
                    }
                }

                for (int i = 0; i < this.pneEditor.Connections.Count; i++)
                {
                    Connection cn = (Connection)this.pneEditor.Connections[i];
                    cn = (Connection)cn.Clone((ConnectableControl)ht[cn.From], (ConnectableControl)ht[cn.To]);
                    se.alDeserializedConnections.Add(cn);
                }

                foreach (object o in se.alDeserializedObjects)
                {
                    if (o is Subsystem)
                    {
                        Subsystem ss = (Subsystem)o;
                        ss.SuppresDeserializationCall();
                    }
                }

                se.RestoreControlsAndConnections();

                foreach (object o in se.alDeserializedObjects)
                {
                    if (o is Subsystem)
                    {
                        Subsystem ss = (Subsystem)o;
                        ss.EnableDeserializationCall();
                    }
                }

                return(se);
            }

            return(null);
        }
Beispiel #2
0
        public void FillInConnectionMatrices(object[,] oa, ArrayList alObjects, ArrayList alChilds)
        {
            foreach (Connection cn in this.Connections)
            {
                if (cn.From is Place && alObjects.Contains(cn.From))
                {
                    if (cn.To is Transition && alChilds.Contains(cn.To))
                    {
                        oa[alChilds.IndexOf(cn.To), alObjects.IndexOf(cn.From)] = cn.Weight;
                    }
                }
                else if (cn.From is Transition && alObjects.Contains(cn.From))
                {
                    if (cn.To is Place && alChilds.Contains(cn.To))
                    {
                        oa[alChilds.IndexOf(cn.To), alObjects.IndexOf(cn.From)] = cn.Weight;
                    }
                    if (cn.To is Subsystem)
                    {
                        // Find next connectable control
                        Subsystem s = (Subsystem)cn.To;

                        ArrayList alToControls = new ArrayList();
                        ArrayList alWeights    = new ArrayList();
                        s.GetBaseControlConnectedToInputPort(alToControls, alWeights, cn.ToPort);

                        foreach (ConnectableControl cc in alToControls)
                        {
                            if (alChilds.Contains(cc))
                            {
                                oa[alChilds.IndexOf(cc), alObjects.IndexOf(cn.From)] = alWeights[alToControls.IndexOf(cc)];
                            }
                        }
                    }
                }
                else if (cn.From is Subsystem)
                {
                    if (cn.To is Transition)
                    {
                        // Find next connectable control
                        Subsystem s = (Subsystem)cn.From;

                        ArrayList alFromControls = new ArrayList();
                        ArrayList alWeights      = new ArrayList();
                        s.GetBaseControlConnectedToOutputPort(alFromControls, alWeights, cn.FromPort);

                        foreach (ConnectableControl cc in alFromControls)
                        {
                            if (alObjects.Contains(cc))
                            {
                                oa[alChilds.IndexOf(cn.To), alObjects.IndexOf(cc)] = cn.Weight;
                            }
                        }
                    }
                }

                //Walk through all subsystems and add connections weights to matrix
                foreach (object o in this.Objects)
                {
                    if (o is Subsystem)
                    {
                        Subsystem s = (Subsystem)o;
                        s.FillInConnectionMatrices(oa, alObjects, alChilds);
                    }
                }
            }
        }
Beispiel #3
0
        private void SubsystemEditor_CreateGUI(PetriNetDocument pnd, Subsystem ssOwner)
        {
            this.pnd     = pnd;
            this.ssOwner = ssOwner;

            Panel pnlEditorContainer = new Panel();

            pnlEditorContainer.AutoScroll = true;
            pnlEditorContainer.Dock       = DockStyle.Fill;

            this.pneEditor                         = new PetriNetEditor(pnd, pnd.InstanceCounter);
            this.pneEditor.AutoScroll              = true;
            this.pneEditor.AutoScrollMinSize       = new Size(3000, 3000);
            this.pneEditor.Size                    = new Size(3000, 3000);
            this.pneEditor.Location                = new Point(0, 0);
            this.pneEditor.ContentsChanged        += new EventHandler(pneEditor_ContentsChanged);
            this.pneEditor.SelectedObjectsChanged += new EventHandler(pneEditor_SelectedObjectsChanged);
            this.pneEditor.PropertiesChanged      += new EventHandler(pneEditor_PropertiesChanged);

            if (this.oDeserializedZoomLevel != null)
            {
                this.pneEditor.Zoom = (float)this.oDeserializedZoomLevel;
            }

            pnlEditorContainer.Controls.Add(pneEditor);
            this.Controls.Add(pnlEditorContainer);

            // Create the object that manages the docking state
            this.dmDockingManager = new Crownwood.Magic.Docking.DockingManager(this, Crownwood.Magic.Common.VisualStyle.IDE);
            this.dmDockingManager.InnerControl = pnlEditorContainer;
            this.dmDockingManager.OuterControl = tbToolBar;

            Crownwood.Magic.Docking.Content toolbox = dmDockingManager.Contents.Add(this.tbToolBox, "Toolbox", this.ilContent, 1);
            toolbox.AutoHideSize = new Size(200, 300);
            toolbox.DisplaySize  = new Size(200, 300);
            toolbox.FloatingSize = new Size(200, 300);
            Crownwood.Magic.Docking.Content properties = dmDockingManager.Contents.Add(this.piPropertiesInspector, "Properties", this.ilContent, 0);
            properties.AutoHideSize = new Size(200, 300);
            properties.DisplaySize  = new Size(200, 300);
            properties.FloatingSize = new Size(200, 300);
            Crownwood.Magic.Docking.WindowContent wc = dmDockingManager.AddContentWithState(toolbox, Crownwood.Magic.Docking.State.DockLeft);

            //dmDockingManager.AddContentToWindowContent(notePad2, wc);
            // Add a new WindowContent to the existing Zone already created
            this.dmDockingManager.AddContentToZone(properties, wc.ParentZone, 1);

            this.tbToolBox.EnabledToolbox = true;

            // Load layout
            if (File.Exists(Application.StartupPath + "\\layoutSubsystem.config.xml"))
            {
                this.dmDockingManager.LoadConfigFromFile(Application.StartupPath + "\\layoutSubsystem.config.xml");
            }

            // Initialize piPropertiesInspector
            this.piPropertiesInspector.SelectedObjectChanged += new EventHandler(piPropertiesInspector_SelectedObjectChanged);

            #region Initialize ToolBar control
            this.tbToolBar.Dock         = DockStyle.Top;
            this.tbToolBar.ButtonSize   = new Size(24, 24);
            this.tbToolBar.ImageList    = ilToolBar;
            this.tbToolBar.ButtonClick += new ToolBarButtonClickEventHandler(tbToolBar_ButtonClick);
            this.tbToolBar.Appearance   = ToolBarAppearance.Flat;

            this.tbbReset.Enabled    = false;
            this.tbbReset.ImageIndex = 3;
            this.tbToolBar.Buttons.Add(tbbReset);

            this.tbbStart.Enabled    = false;
            this.tbbStart.ImageIndex = 4;
            this.tbToolBar.Buttons.Add(tbbStart);

            this.tbbPause.Enabled    = false;
            this.tbbPause.ImageIndex = 5;
            this.tbToolBar.Buttons.Add(tbbPause);

            this.tbbStop.Enabled    = false;
            this.tbbStop.ImageIndex = 6;
            this.tbToolBar.Buttons.Add(tbbStop);

            this.tbbStep.Enabled    = false;
            this.tbbStep.ImageIndex = 7;
            this.tbToolBar.Buttons.Add(tbbStep);

            this.tbbSeparator4.Style = ToolBarButtonStyle.Separator;
            this.tbToolBar.Buttons.Add(tbbSeparator4);

            this.tbbUndo.ImageIndex   = 13;
            this.tbbUndo.ToolTipText  = "Undo";
            this.tbbUndo.Style        = ToolBarButtonStyle.DropDownButton;
            this.tbbUndo.DropDownMenu = this.cmUndo;
            this.tbToolBar.Buttons.Add(tbbUndo);

            this.tbbRedo.ImageIndex   = 14;
            this.tbbRedo.ToolTipText  = "Redo";
            this.tbbRedo.Style        = ToolBarButtonStyle.DropDownButton;
            this.tbbRedo.DropDownMenu = this.cmRedo;
            this.tbToolBar.Buttons.Add(tbbRedo);

            this.tbbSeparator2.Style = ToolBarButtonStyle.Separator;
            this.tbToolBar.Buttons.Add(tbbSeparator2);

//			this.tbbConflicts.ImageIndex = 8;
//			this.tbbConflicts.Style = ToolBarButtonStyle.ToggleButton;
//			this.tbToolBar.Buttons.Add(tbbConflicts);
//
//			this.tbbCircularWaits.ImageIndex = 9;
//			this.tbbCircularWaits.Style = ToolBarButtonStyle.ToggleButton;
//			this.tbToolBar.Buttons.Add(tbbCircularWaits);
//
//			this.tbbFireable.ImageIndex = 10;
//			this.tbbFireable.Style = ToolBarButtonStyle.ToggleButton;
//			this.tbbFireable.Pushed = true;
//			this.tbToolBar.Buttons.Add(tbbFireable);
//
//			this.tbbFired.ImageIndex = 11;
//			this.tbbFired.Style = ToolBarButtonStyle.ToggleButton;
//			this.tbbFired.Pushed = true;
//			this.tbToolBar.Buttons.Add(tbbFired);
//
//			this.tbbSeparator3.Style = ToolBarButtonStyle.Separator;
//			this.tbToolBar.Buttons.Add(tbbSeparator3);

            this.tbbZoom.ImageIndex   = 12;
            this.tbbZoom.Style        = ToolBarButtonStyle.DropDownButton;
            this.tbbZoom.DropDownMenu = this.cmZoom;
            this.tbToolBar.Buttons.Add(tbbZoom);
            this.Controls.Add(this.tbToolBar);
            #endregion

            // Initialize MenuControl
            this.mcMenuControl      = new Crownwood.Magic.Menus.MenuControl();
            this.mcMenuControl.Dock = DockStyle.Top;
            this.Controls.Add(mcMenuControl);

            #region Initialize this.mcFile

            mcFile = new Crownwood.Magic.Menus.MenuCommand("&File");

            mcFileExport          = new Crownwood.Magic.Menus.MenuCommand("&Export...");
            mcFileExport.Shortcut = Shortcut.CtrlE;
            mcFileExport.Click   += new EventHandler(mcFileExport_Click);
            mcFile.MenuCommands.Add(mcFileExport);

            mcFileSeparator1 = new Crownwood.Magic.Menus.MenuCommand("-");
            mcFile.MenuCommands.Add(mcFileSeparator1);

            mcFileClose        = new Crownwood.Magic.Menus.MenuCommand("&Close");
            mcFileClose.Click += new EventHandler(mcFileClose_Click);
            mcFile.MenuCommands.Add(mcFileClose);

            this.mcMenuControl.MenuCommands.Add(mcFile);

            #endregion

            #region Initialize this.mcEdit

            mcEdit = new Crownwood.Magic.Menus.MenuCommand("&Edit");

            mcEditUndo            = new Crownwood.Magic.Menus.MenuCommand("&Undo");
            mcEditUndo.Click     += new EventHandler(mcEditUndo_Click);
            mcEditUndo.ImageList  = ilMenu;
            mcEditUndo.ImageIndex = 4;
            mcEditUndo.Shortcut   = Shortcut.CtrlZ;
            mcEditUndo.Enabled    = false;
            mcEdit.MenuCommands.Add(mcEditUndo);

            mcEditRedo            = new Crownwood.Magic.Menus.MenuCommand("&Redo");
            mcEditRedo.Click     += new EventHandler(mcEditRedo_Click);
            mcEditRedo.ImageList  = ilMenu;
            mcEditRedo.ImageIndex = 5;
            mcEditRedo.Shortcut   = Shortcut.CtrlY;
            mcEditRedo.Enabled    = false;
            mcEdit.MenuCommands.Add(mcEditRedo);

            mcEditSeparator1 = new Crownwood.Magic.Menus.MenuCommand("-");
            mcEdit.MenuCommands.Add(mcEditSeparator1);

            mcEditCut            = new Crownwood.Magic.Menus.MenuCommand("Cu&t");
            mcEditCut.Click     += new EventHandler(mcEditCut_Click);
            mcEditCut.ImageList  = ilMenu;
            mcEditCut.ImageIndex = 6;
            mcEditCut.Shortcut   = Shortcut.CtrlX;
            mcEdit.MenuCommands.Add(mcEditCut);

            mcEditCopy            = new Crownwood.Magic.Menus.MenuCommand("&Copy");
            mcEditCopy.Click     += new EventHandler(mcEditCopy_Click);
            mcEditCopy.ImageList  = ilMenu;
            mcEditCopy.ImageIndex = 7;
            mcEditCopy.Shortcut   = Shortcut.CtrlC;
            mcEdit.MenuCommands.Add(mcEditCopy);

            mcEditPaste            = new Crownwood.Magic.Menus.MenuCommand("&Paste");
            mcEditPaste.Click     += new EventHandler(mcEditPaste_Click);
            mcEditPaste.ImageList  = ilMenu;
            mcEditPaste.ImageIndex = 8;
            mcEditPaste.Shortcut   = Shortcut.CtrlV;
            mcEdit.MenuCommands.Add(mcEditPaste);

            mcEditDelete            = new Crownwood.Magic.Menus.MenuCommand("&Delete");
            mcEditDelete.Click     += new EventHandler(mcEditDelete_Click);
            mcEditDelete.ImageList  = ilMenu;
            mcEditDelete.ImageIndex = 9;
            mcEditDelete.Shortcut   = Shortcut.Del;
            mcEdit.MenuCommands.Add(mcEditDelete);

            mcEditSeparator2 = new Crownwood.Magic.Menus.MenuCommand("-");
            mcEdit.MenuCommands.Add(mcEditSeparator2);

            mcEditCopyModel           = new Crownwood.Magic.Menus.MenuCommand("Copy &model");
            mcEditCopyModel.Click    += new EventHandler(mcEditCopyModel_Click);
            mcEditCopyModel.ImageList = ilMenu;
            //mcEditCopyModel.ImageIndex = 9;
            //mcEditCopyModel.Shortcut = Shortcut.Del;
            mcEdit.MenuCommands.Add(mcEditCopyModel);

            mcEditSeparator3 = new Crownwood.Magic.Menus.MenuCommand("-");
            mcEdit.MenuCommands.Add(mcEditSeparator3);

            mcEditGroup           = new Crownwood.Magic.Menus.MenuCommand("&Group");
            mcEditGroup.Click    += new EventHandler(mcEditGroup_Click);
            mcEditGroup.ImageList = ilMenu;
            //mcEditGroup.ImageIndex = 8;
            mcEditGroup.Shortcut = Shortcut.CtrlG;
            mcEdit.MenuCommands.Add(mcEditGroup);

            mcEditSeparator4 = new Crownwood.Magic.Menus.MenuCommand("-");
            mcEdit.MenuCommands.Add(mcEditSeparator4);

            mcEditSelectAll           = new Crownwood.Magic.Menus.MenuCommand("Select &All");
            mcEditSelectAll.Click    += new EventHandler(mcEditSelectAll_Click);
            mcEditSelectAll.ImageList = ilMenu;
            mcEditSelectAll.Shortcut  = Shortcut.CtrlA;
            mcEdit.MenuCommands.Add(mcEditSelectAll);

            this.mcMenuControl.MenuCommands.Add(mcEdit);

            #endregion

            #region Initialize this.mcView

            mcView = new Crownwood.Magic.Menus.MenuCommand("&View");

            foreach (Crownwood.Magic.Docking.Content c in this.dmDockingManager.Contents)
            {
                Crownwood.Magic.Menus.MenuCommand mc = new Crownwood.Magic.Menus.MenuCommand(c.Title);
                mc.Image  = c.ImageList.Images[c.ImageIndex];
                mc.Click += new EventHandler(mcViewContents_Click);
                mcView.MenuCommands.Add(mc);
            }

            this.mcMenuControl.MenuCommands.Add(mcView);

            #endregion


            #region Initialize ActionList
            // Initialize ActionList
            this.alMenuActionList.ImageList = this.ilMenu;

            this.aEditUndo.Checked    = false;
            this.aEditUndo.Enabled    = false;
            this.aEditUndo.Hint       = null;
            this.aEditUndo.Shortcut   = System.Windows.Forms.Shortcut.CtrlZ;
            this.aEditUndo.Tag        = null;
            this.aEditUndo.ImageIndex = 4;
            this.aEditUndo.Text       = mcEditUndo.Text;
            this.aEditUndo.Visible    = true;
            this.aEditUndo.Update    += new System.EventHandler(this.aEditUndo_Update);
            this.alMenuActionList.Actions.Add(this.aEditUndo);
            this.alMenuActionList.SetAction(this.mcEditUndo, this.aEditUndo);

            this.aEditRedo.Checked    = false;
            this.aEditRedo.Enabled    = false;
            this.aEditRedo.Hint       = null;
            this.aEditRedo.Shortcut   = System.Windows.Forms.Shortcut.CtrlY;
            this.aEditRedo.Tag        = null;
            this.aEditRedo.ImageIndex = 5;
            this.aEditRedo.Text       = mcEditRedo.Text;
            this.aEditRedo.Visible    = true;
            this.aEditRedo.Update    += new System.EventHandler(this.aEditRedo_Update);
            this.alMenuActionList.Actions.Add(this.aEditRedo);
            this.alMenuActionList.SetAction(this.mcEditRedo, this.aEditRedo);

            this.aEditDelete.Checked    = false;
            this.aEditDelete.Enabled    = false;
            this.aEditDelete.Hint       = null;
            this.aEditDelete.Shortcut   = System.Windows.Forms.Shortcut.Del;
            this.aEditDelete.Tag        = null;
            this.aEditDelete.ImageIndex = 9;
            this.aEditDelete.Text       = mcEditDelete.Text;
            this.aEditDelete.Visible    = true;
            this.aEditDelete.Update    += new System.EventHandler(this.aEditDelete_Update);
            this.alMenuActionList.Actions.Add(this.aEditDelete);
            this.alMenuActionList.SetAction(this.mcEditDelete, this.aEditDelete);

            this.aEditCut.Checked    = false;
            this.aEditCut.Enabled    = false;
            this.aEditCut.Hint       = null;
            this.aEditCut.Shortcut   = System.Windows.Forms.Shortcut.CtrlX;
            this.aEditCut.ImageIndex = 6;
            this.aEditCut.Tag        = null;
            this.aEditCut.Text       = mcEditCut.Text;
            this.aEditCut.Visible    = true;
            this.aEditCut.Update    += new System.EventHandler(this.aEditCut_Update);
            this.alMenuActionList.Actions.Add(this.aEditCut);
            this.alMenuActionList.SetAction(this.mcEditCut, this.aEditCut);

            this.aEditCopy.Checked    = false;
            this.aEditCopy.Enabled    = false;
            this.aEditCopy.Hint       = null;
            this.aEditCopy.Shortcut   = System.Windows.Forms.Shortcut.CtrlC;
            this.aEditCopy.ImageIndex = 7;
            this.aEditCopy.Tag        = null;
            this.aEditCopy.Text       = mcEditCopy.Text;
            this.aEditCopy.Visible    = true;
            this.aEditCopy.Update    += new System.EventHandler(this.aEditCopy_Update);
            this.alMenuActionList.Actions.Add(this.aEditCopy);
            this.alMenuActionList.SetAction(this.mcEditCopy, this.aEditCopy);

            this.aEditPaste.Checked    = false;
            this.aEditPaste.Enabled    = false;
            this.aEditPaste.Hint       = null;
            this.aEditPaste.Shortcut   = System.Windows.Forms.Shortcut.CtrlV;
            this.aEditPaste.ImageIndex = 8;
            this.aEditPaste.Tag        = null;
            this.aEditPaste.Text       = mcEditPaste.Text;
            this.aEditPaste.Visible    = true;
            this.aEditPaste.Update    += new System.EventHandler(this.aEditPaste_Update);
            this.alMenuActionList.Actions.Add(this.aEditPaste);
            this.alMenuActionList.SetAction(this.mcEditPaste, this.aEditPaste);

            this.aEditGroup.Checked    = false;
            this.aEditGroup.Enabled    = false;
            this.aEditGroup.Hint       = null;
            this.aEditGroup.Shortcut   = System.Windows.Forms.Shortcut.CtrlG;
            this.aEditGroup.ImageIndex = 12;
            this.aEditGroup.Tag        = null;
            this.aEditGroup.Text       = mcEditGroup.Text;
            this.aEditGroup.Visible    = true;
            this.aEditGroup.Update    += new System.EventHandler(this.aEditGroup_Update);
            this.alMenuActionList.Actions.Add(this.aEditGroup);
            this.alMenuActionList.SetAction(this.mcEditGroup, this.aEditGroup);

            #endregion

            // Initialize Undo/Redo context menus
            this.cmUndo.Popup += new EventHandler(cmUndo_Popup);
            this.cmRedo.Popup += new EventHandler(cmRedo_Popup);
        }