Ejemplo n.º 1
0
        public static LadderDiagramViewModel CreateLadderDiagramByXElement(XElement xEle, ProjectModel _projectmodel)
        {
            LadderDiagramViewModel result = new LadderDiagramViewModel(xEle.Attribute("Name").Value, _projectmodel);

            if (xEle.Attribute("IsMain") != null && xEle.Attribute("IsMain").Value == "True")
            {
                result.IsMainLadder = true;
            }
            else
            {
                result.IsMainLadder = false;
            }
            result.IsExpand = bool.Parse(xEle.Attribute("IsExpand").Value);
            result.InitNetworks();
            foreach (XElement netNode in xEle.Elements("Network"))
            {
                var net = CreateLadderNetworkByXElement(netNode, result);
                result.AppendNetwork(net);
                net.IsExpand = bool.Parse(netNode.Attribute("IsExpand").Value);
            }
            return(result);
        }