Пример #1
0
 private void Subsystem_ParentChanged(object sender, EventArgs e)
 {
     if (this.Parent is PetriNetEditor)
     {
         if (this.seSubsystemEditor == null)
         {
             this.seSubsystemEditor = new SubsystemEditor(((PetriNetEditor)this.Parent).Document, this);
         }
         else
         {
             if (this.bSuppresDeserializationCall != true)
             {
                 this.seSubsystemEditor.RestoreAfterDeserialization(((PetriNetEditor)this.Parent).Document, this);
             }
         }
     }
 }
Пример #2
0
        // Constructor for Deserialization
        #region public Subsystem(SerializationInfo info, StreamingContext context) : base(info, context)
        public Subsystem(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
            this.UpdateStyles();

            this.AllowResizing  = true;
            this.Paint         += new PaintEventHandler(Subsystem_Paint);
            this.MouseUp       += new MouseEventHandler(Subsystem_MouseUp);
            this.Resize        += new EventHandler(Subsystem_Resize);
            this.DoubleClick   += new EventHandler(Subsystem_DoubleClick);
            this.ParentChanged += new EventHandler(Subsystem_ParentChanged);

            this.Location          = (Point)info.GetValue("location", typeof(Point));
            this.seSubsystemEditor = (SubsystemEditor)info.GetValue("editor", typeof(SubsystemEditor));

            // To set region, call resize
//			this.Transition_Resize(this, EventArgs.Empty);
        }
Пример #3
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);
        }