public object Clone() { DescriptionLabel dl = new DescriptionLabel(); dl.Location = this.Location; dl.Text = this.Text; dl.TextColor = this.TextColor; dl.Size = this.Size; // Change default size if (this.Parent != null && this.Parent is EditorSurface) { EditorSurface es = (EditorSurface)this.Parent; dl.DefaultSize = new Size((int)(this.Width / es.Zoom), (int)(this.Height / es.Zoom)); } else if (this.Parent == null) { dl.DefaultSize = this.DefaultSize; } dl.BackColor = this.BackColor; dl.Font = this.Font; return(dl); }
public int CompareTo(object o) { if (o is DescriptionLabel) { DescriptionLabel dl = (DescriptionLabel)o; return(this.iIndex.CompareTo(dl.Index)); } throw new ArgumentException("Invalid argument"); }
public int Compare(object x, object y) { if (x is PetriNetDocument && y is Place) { return(-1); } else if (y is PetriNetDocument && x is Place) { return(1); } else if (x is PetriNetDocument && y is Transition) { return(-1); } else if (y is PetriNetDocument && x is Transition) { return(1); } else if (x is PetriNetDocument && y is Connection) { return(-1); } else if (y is PetriNetDocument && x is Connection) { return(1); } else if (x is PetriNetDocument && y is DescriptionLabel) { return(-1); } else if (y is PetriNetDocument && x is DescriptionLabel) { return(1); } else if (x is PetriNetDocument && y is Subsystem) { return(-1); } else if (y is PetriNetDocument && x is Subsystem) { return(1); } else if (x is PetriNetDocument && y is Input) { return(-1); } else if (y is PetriNetDocument && x is Input) { return(1); } else if (x is PetriNetDocument && y is Output) { return(-1); } else if (y is PetriNetDocument && x is Output) { return(1); } else if (x is Place && y is Transition) { return(-1); } else if (y is Place && x is Transition) { return(1); } else if (x is Place && y is Connection) { return(-1); } else if (y is Place && x is Connection) { return(1); } else if (x is Place && y is DescriptionLabel) { return(-1); } else if (y is Place && x is DescriptionLabel) { return(1); } else if (x is Place && y is Subsystem) { return(-1); } else if (y is Place && x is Subsystem) { return(1); } else if (x is Place && y is Input) { return(-1); } else if (y is Place && x is Input) { return(1); } else if (x is Place && y is Output) { return(-1); } else if (y is Place && x is Output) { return(1); } else if (x is Place && y is Place) { Place px = (Place)x; return(px.CompareTo(y)); } else if (x is Transition && y is Connection) { return(-1); } else if (y is Transition && x is Connection) { return(1); } else if (x is Transition && y is DescriptionLabel) { return(-1); } else if (y is Transition && x is DescriptionLabel) { return(1); } else if (x is Transition && y is Subsystem) { return(-1); } else if (y is Transition && x is Subsystem) { return(1); } else if (x is Transition && y is Input) { return(-1); } else if (y is Transition && x is Input) { return(1); } else if (x is Transition && y is Output) { return(-1); } else if (y is Transition && x is Output) { return(1); } else if (x is Transition && y is Transition) { Transition tx = (Transition)x; return(tx.CompareTo(y)); } else if (x is Connection && y is Subsystem) { return(1); } else if (y is Connection && x is Subsystem) { return(-1); } else if (x is Connection && y is Input) { return(1); } else if (y is Connection && x is Input) { return(-1); } else if (x is Connection && y is Output) { return(1); } else if (y is Connection && x is Output) { return(-1); } else if (x is Connection && y is DescriptionLabel) { return(-1); } else if (y is Connection && x is DescriptionLabel) { return(1); } else if (x is Subsystem && y is DescriptionLabel) { return(-1); } else if (y is Subsystem && x is DescriptionLabel) { return(1); } else if (x is Subsystem && y is Input) { return(-1); } else if (y is Subsystem && x is Input) { return(1); } else if (x is Subsystem && y is Output) { return(-1); } else if (y is Subsystem && x is Output) { return(1); } else if (x is Subsystem && y is Subsystem) { Subsystem sx = (Subsystem)x; return(sx.CompareTo(y)); } else if (x is Input && y is Output) { return(-1); } else if (y is Input && x is Output) { return(1); } else if (x is Input && y is DescriptionLabel) { return(-1); } else if (y is Input && x is DescriptionLabel) { return(1); } else if (x is Input && y is Input) { Input ix = (Input)x; return(ix.CompareTo(y)); } else if (x is Output && y is DescriptionLabel) { return(-1); } else if (y is Output && x is DescriptionLabel) { return(1); } else if (x is Output && y is Output) { Output ox = (Output)x; return(ox.CompareTo(y)); } else if (x is DescriptionLabel && y is DescriptionLabel) { DescriptionLabel dlx = (DescriptionLabel)x; return(dlx.CompareTo(y)); } return(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); }
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); }