コード例 #1
0
        public static bool LoadListFromXMLFile(out List <BoxPosition> boxPositions, string filename)
        {
            boxPositions = new List <BoxPosition>();
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(filename);

                XmlElement eltBoxPositions = xmlDoc.DocumentElement;
                foreach (XmlNode nodeBP in eltBoxPositions.ChildNodes)
                {
                    if (nodeBP is XmlElement eltBoxPosition)
                    {
                        string sPosition   = eltBoxPosition.Attributes["Position"].Value;
                        string sAxisLength = eltBoxPosition.Attributes["AxisLength"].Value;
                        string sAxisWidth  = eltBoxPosition.Attributes["AxisWidth"].Value;
                        boxPositions.Add(new BoxPosition(Vector3D.Parse(sPosition), HalfAxis.Parse(sAxisLength), HalfAxis.Parse(sAxisWidth)));
                    }
                }
            }
            catch (Exception /*ex*/)
            {
                return(false);
            }
            return(true);
        }
コード例 #2
0
ファイル: BoxPosition.cs プロジェクト: maoguoxus/StackBuilder
        public static BoxPosition Parse(string s)
        {
            string[] sArray       = s.Split('|');
            var      v            = Vector3D.Parse(sArray[0]);
            string   sOrientation = sArray[1];

            sOrientation = sOrientation.Trim();
            sOrientation = sOrientation.TrimStart('(');
            sOrientation = sOrientation.TrimEnd(')');
            string[] vOrientation = sOrientation.Split(',');
            return(new BoxPosition(v, HalfAxis.Parse(vOrientation[0]), HalfAxis.Parse(vOrientation[1])));
        }
コード例 #3
0
ファイル: Layer2D.cs プロジェクト: SaraMh/StackBuilder
        public static LayerDesc Parse(string value)
        {
            Regex r = new Regex(@"(?<name>|(?<axis>))", RegexOptions.Singleline);
            Match m = r.Match(value);

            if (m.Success)
            {
                string         patternName = m.Result("${name}");
                HalfAxis.HAxis axis        = HalfAxis.Parse(m.Result("${axis}"));
                return(new LayerDesc(patternName, axis));
            }
            else
            {
                throw new Exception("Failed to parse LayerDesc");
            }
        }
コード例 #4
0
        public static LayerDesc Parse(string value)
        {
            Regex r = new Regex(@"(?<name>.*)\|(?<axis>.*)\|(?<swap>.*)", RegexOptions.Singleline);
            Match m = r.Match(value);

            if (m.Success)
            {
                string         patternName = m.Result("${name}");
                HalfAxis.HAxis axis        = HalfAxis.Parse(m.Result("${axis}"));
                bool           swapped     = string.Equals("t", m.Result("${swap}"), StringComparison.CurrentCultureIgnoreCase);
                return(new LayerDescBox(patternName, axis, swapped));
            }
            else
            {
                throw new Exception("Failed to parse LayerDesc");
            }
        }