Exemplo n.º 1
0
 public void AddNail(NailItem nail, int segmentIndex)
 {
     if (segmentIndex < 0)
         this.nails.Insert(0, nail);
     else
         this.nails.Insert(segmentIndex, nail);
 }
Exemplo n.º 2
0
        public override void LoadFromXML(XmlElement xmlElement, LTSCanvas canvas)
        {
            if (canvas is PNCanvas)
            {
                PNCanvas myCanvas      = canvas as PNCanvas;
                string   startingState = xmlElement.GetAttribute("From");
                this.From = myCanvas.FindState(startingState);
                string endState = xmlElement.GetAttribute("To");
                this.To = myCanvas.FindState(endState);

                if (From is PNTransition)
                {
                    (From as PNTransition).OutputPlaces.Add(To as PNPlace);
                }
                else
                {
                    (To as PNTransition).InputPlaces.Add(From as PNPlace);
                }

                this.Weight = int.Parse(xmlElement.GetAttribute("Weight"));

                for (int i = 0; i < xmlElement.ChildNodes.Count - 1; i++)
                {
                    NailItem nail = new NailItem(this);
                    nail.LoadFromXml(xmlElement.ChildNodes[i] as XmlElement);
                    this.Nails.Add(nail);
                }

                this.Label.LoadFromXml(xmlElement.ChildNodes[xmlElement.ChildNodes.Count - 1] as XmlElement);
            }
        }
Exemplo n.º 3
0
        public virtual void LoadFromXML(XmlElement xmlElement, LTSCanvas canvas)
        {
            //string startingState = xmlElement.ChildNodes[0].InnerText;
            //this.from = canvas.FindState(startingState);
            //string endState = xmlElement.ChildNodes[1].InnerText;
            //this.to = canvas.FindState(endState);

            //this.Transition.Select = xmlElement.ChildNodes[2].InnerText;
            //this.Transition.Event = xmlElement.ChildNodes[3].InnerText;
            //this.Transition.ClockGuard = xmlElement.ChildNodes[4].InnerText;
            //this.Transition.Guard = xmlElement.ChildNodes[5].InnerText;
            //this.Transition.Program = xmlElement.ChildNodes[6].InnerText;
            //this.Transition.ClockReset = xmlElement.ChildNodes[7].InnerText;
            //this.Transition.Width = this.Transition.GetWidthOfLabel();

            //for (int i = 8; i < xmlElement.ChildNodes.Count - 1; i++)
            //{
            //    NailItem nail = new NailItem(this);
            //    nail.LoadFromXml(xmlElement.ChildNodes[i] as XmlElement);
            //    this.nails.Add(nail);
            //}

            //this.transition.LoadFromXml(xmlElement.ChildNodes[xmlElement.ChildNodes.Count - 1] as XmlElement);

            string startingState = xmlElement.SelectSingleNode("./" + FROM_NODE_NAME).InnerText;

            this.from = canvas.FindState(startingState);
            string endState = xmlElement.SelectSingleNode("./" + TO_NODE_NAME).InnerText;

            this.to = canvas.FindState(endState);

            this.Transition.Select     = xmlElement.SelectSingleNode("./" + SELECT_NODE_NAME).InnerText;
            this.Transition.Event      = xmlElement.SelectSingleNode("./" + EVENT_NODE_NAME).InnerText;
            this.Transition.ClockGuard = xmlElement.SelectSingleNode("./" + CLOCK_GUARD_NODE_NAME).InnerText;
            this.Transition.Guard      = xmlElement.SelectSingleNode("./" + GUARD_NODE_NAME).InnerText;
            this.Transition.Program    = xmlElement.SelectSingleNode("./" + PROGRAM_NODE_NAME).InnerText;
            this.Transition.ClockReset = xmlElement.SelectSingleNode("./" + CLOCK_RESET_NODE_NAME).InnerText;
            this.Transition.Width      = this.Transition.GetWidthOfLabel();

            XmlNodeList nails = xmlElement.SelectNodes("./" + NAIL_NODE_NAME);

            if (nails != null)
            {
                foreach (XmlElement xmlNail in nails)
                {
                    NailItem nail = new NailItem(this);
                    nail.LoadFromXml(xmlNail);
                    this.nails.Add(nail);
                }
            }

            this.transition.LoadFromXml((XmlElement)xmlElement.SelectSingleNode("./" + LABEL_NODE_NAME));
        }
Exemplo n.º 4
0
        public virtual void AddToCanvas(LTSCanvas canvas)
        {
            canvas.AddSingleLink(this);
            for (int i = 1; i < canvas.temporaryNails.Count; i++)
            {
                PointF p = canvas.temporaryNails[i];
                NailItem nailItem = new NailItem(this);
                nailItem.X = p.X;
                nailItem.Y = p.Y;
                canvas.AddSingleCanvasItem(nailItem);
                this.AddNail(nailItem, this.Nails.Count);
            }
            canvas.temporaryNails.Clear();

            this.FindLabelLocation();
            canvas.AddSingleCanvasItem(this.transition);
        }
Exemplo n.º 5
0
        public override void AddToCanvas(LTSCanvas canvas)
        {
            canvas.AddSingleLink(this);

            for (int i = 1; i < canvas.temporaryNails.Count; i++)
            {
                PointF p = canvas.temporaryNails[i];
                NailItem nailItem = new NailItem(this);
                nailItem.X = p.X;
                nailItem.Y = p.Y;
                canvas.AddSingleCanvasItem(nailItem);
                this.AddNail(nailItem, this.Nails.Count);
            }
            canvas.temporaryNails.Clear();

            FindLabelLocation();
            canvas.AddSingleCanvasItem(Label);
        }
Exemplo n.º 6
0
        public override void LoadFromXML(XmlElement xmlElement, LTSCanvas canvas)
        {
            if (canvas is PNCanvas)
            {
                PNCanvas myCanvas = canvas as PNCanvas;
                string startingState = xmlElement.GetAttribute("From");
                this.From = myCanvas.FindState(startingState);
                string endState = xmlElement.GetAttribute("To");
                this.To = myCanvas.FindState(endState);

                if (From is PNTransition)
                    (From as PNTransition).OutputPlaces.Add(To as PNPlace);
                else
                    (To as PNTransition).InputPlaces.Add(From as PNPlace);

                this.Weight = int.Parse(xmlElement.GetAttribute("Weight"));

                for (int i = 0; i < xmlElement.ChildNodes.Count - 1; i++)
                {
                    NailItem nail = new NailItem(this);
                    nail.LoadFromXml(xmlElement.ChildNodes[i] as XmlElement);
                    this.Nails.Add(nail);
                }

                this.Label.LoadFromXml(xmlElement.ChildNodes[xmlElement.ChildNodes.Count - 1] as XmlElement);
            }
        }
Exemplo n.º 7
0
        private void Button_AddNewNail_Click(object sender, EventArgs e)
        {
            //Add from context menu
            Route route;
            PointF p = PointF.Empty;

            if (this.Button_AddNewNail.Checked)
            {
                //Add from menu bar
                route = (e as CanvasRouteEventArgs).CanvasItem;
                p = this.Canvas.LastMouseClickPosition;
            }
            else
            {
                //Add from context menu
                route = this.SelectedRoute;
                p = this.Canvas.lastRightClickPosition;
            }
            if (route != null)
            {
                NailItem nailItem = new NailItem(route);
                nailItem.X = p.X;
                nailItem.Y = p.Y;
                this.AddCanvasItem(nailItem);
                Canvas.Refresh();
                SetDirty();
            }
        }
Exemplo n.º 8
0
 public void AddNail(NailItem nail, int segmentIndex)
 {
     if (segmentIndex < 0)
         this.nails.Insert(0, nail);
     else
         this.nails.Insert(segmentIndex, nail);
 }
Exemplo n.º 9
0
        public virtual void LoadFromXML(XmlElement xmlElement, LTSCanvas canvas)
        {
            //string startingState = xmlElement.ChildNodes[0].InnerText;
            //this.from = canvas.FindState(startingState);
            //string endState = xmlElement.ChildNodes[1].InnerText;
            //this.to = canvas.FindState(endState);

            //this.Transition.Select = xmlElement.ChildNodes[2].InnerText;
            //this.Transition.Event = xmlElement.ChildNodes[3].InnerText;
            //this.Transition.ClockGuard = xmlElement.ChildNodes[4].InnerText;
            //this.Transition.Guard = xmlElement.ChildNodes[5].InnerText;
            //this.Transition.Program = xmlElement.ChildNodes[6].InnerText;
            //this.Transition.ClockReset = xmlElement.ChildNodes[7].InnerText;
            //this.Transition.Width = this.Transition.GetWidthOfLabel();

            //for (int i = 8; i < xmlElement.ChildNodes.Count - 1; i++)
            //{
            //    NailItem nail = new NailItem(this);
            //    nail.LoadFromXml(xmlElement.ChildNodes[i] as XmlElement);
            //    this.nails.Add(nail);
            //}

            //this.transition.LoadFromXml(xmlElement.ChildNodes[xmlElement.ChildNodes.Count - 1] as XmlElement);

            string startingState = xmlElement.SelectSingleNode("./" + FROM_NODE_NAME).InnerText;
            this.from = canvas.FindState(startingState);
            string endState = xmlElement.SelectSingleNode("./" + TO_NODE_NAME).InnerText;
            this.to = canvas.FindState(endState);

            this.Transition.Select = xmlElement.SelectSingleNode("./" + SELECT_NODE_NAME).InnerText;
            this.Transition.Event = xmlElement.SelectSingleNode("./" + EVENT_NODE_NAME).InnerText;
            this.Transition.ClockGuard = xmlElement.SelectSingleNode("./" + CLOCK_GUARD_NODE_NAME).InnerText;
            this.Transition.Guard = xmlElement.SelectSingleNode("./" + GUARD_NODE_NAME).InnerText;
            this.Transition.Program = xmlElement.SelectSingleNode("./" + PROGRAM_NODE_NAME).InnerText;
            this.Transition.ClockReset = xmlElement.SelectSingleNode("./" + CLOCK_RESET_NODE_NAME).InnerText;
            this.Transition.Width = this.Transition.GetWidthOfLabel();

            XmlNodeList nails = xmlElement.SelectNodes("./" + NAIL_NODE_NAME);
            if (nails != null)
            {
                foreach (XmlElement xmlNail in nails)
                {
                    NailItem nail = new NailItem(this);
                    nail.LoadFromXml(xmlNail);
                    this.nails.Add(nail);
                }
            }

            this.transition.LoadFromXml((XmlElement)xmlElement.SelectSingleNode("./" + LABEL_NODE_NAME));
        }