Example #1
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));
        }