Esempio n. 1
0
        public static IEnumerable <Vector> ToIEnumerableVectorList(this List <Dictionary <string, string> > Source)
        {
            List <Vector> Result = new List <Vector>();

            foreach (Dictionary <string, string> elem in Source)
            {
                string XValue;
                string YValue;
                double X = 0, Y = 0;

                elem.TryGetValue(ComXLabel, out XValue);
                elem.TryGetValue(ComYLabel, out YValue);

                if (XValue != null && XValue.Length > 1)
                {
                    if (XValue.Contains("."))
                    {
                        XValue = XValue.Replace(".", ",");
                    }

                    double.TryParse(XValue, out X);
                }

                if (YValue != null && YValue.Length > 1)
                {
                    if (YValue.Contains("."))
                    {
                        YValue = YValue.Replace(".", ",");
                    }

                    double.TryParse(YValue, out Y);
                }

                Vector VectorElem = new Vector(X / ScaleX, Y / ScaleY);
                Result.Add(VectorElem);
            }

            return(Result);
        }
Esempio n. 2
0
        public static IEnumerable <Node> ToIEnumerableNodeList(this List <Dictionary <string, string> > Source, ref double[] BoundingBox)
        {
            List <Node> Result = new List <Node>();
            string      IdValue;
            string      XValue;
            string      YValue;
            string      OValue;
            double      X = 0, Y = 0, O = 0;

            Source[0].TryGetValue(ComXLabel, out XValue);
            Source[0].TryGetValue(ComYLabel, out YValue);

            BoundingBox[0] = BoundingBox[0] - 5;
            BoundingBox[1] = BoundingBox[1] - 5;
            BoundingBox[2] = BoundingBox[2] + 5;
            BoundingBox[3] = BoundingBox[3] + 5;
            if (XValue != null && XValue.Length > 1)
            {
                if (XValue.Contains("."))
                {
                    XValue = XValue.Replace(".", ",");
                }

                double.TryParse(XValue, out X);
            }

            if (YValue != null && YValue.Length > 1)
            {
                if (YValue.Contains("."))
                {
                    YValue = YValue.Replace(".", ",");
                }

                double.TryParse(YValue, out Y);
            }

            BoundingBox[2] = X / ScaleX;
            BoundingBox[0] = X / ScaleX;
            BoundingBox[3] = Y / ScaleY;
            BoundingBox[1] = Y / ScaleY;

            foreach (Dictionary <string, string> elem in Source)
            {
                elem.TryGetValue(UniqIDLabel, out IdValue);
                elem.TryGetValue(ComXLabel, out XValue);
                elem.TryGetValue(ComYLabel, out YValue);
                elem.TryGetValue(ComOrientationLabel, out OValue);
                if (IdValue == null)
                {
                    IdValue = "";
                }

                if (XValue != null && XValue.Length > 1)
                {
                    if (XValue.Contains("."))
                    {
                        XValue = XValue.Replace(".", ",");
                    }

                    double.TryParse(XValue, out X);
                }

                if (YValue != null && YValue.Length > 1)
                {
                    if (YValue.Contains("."))
                    {
                        YValue = YValue.Replace(".", ",");
                    }

                    double.TryParse(YValue, out Y);
                }

                if (OValue != null && OValue.Length > 1)
                {
                    if (OValue.Contains("."))
                    {
                        OValue = OValue.Replace(".", ",");
                    }

                    double.TryParse(OValue, out O);
                }

                if ((X / ScaleX) > BoundingBox[2])
                {
                    BoundingBox[2] = X / ScaleX;
                }
                else if ((X / ScaleX) < BoundingBox[0])
                {
                    BoundingBox[0] = X / ScaleX;
                }
                if ((Y / ScaleY) > BoundingBox[3])
                {
                    BoundingBox[3] = Y / ScaleY;
                }
                else if ((Y / ScaleY) < BoundingBox[1])
                {
                    BoundingBox[1] = Y / ScaleY;
                }
                Result.Add(new Node(IdValue, X / ScaleX, Y / ScaleY, O));
            }

            BoundingBox[0] = BoundingBox[0] - 5;
            BoundingBox[1] = BoundingBox[1] - 5;
            BoundingBox[2] = BoundingBox[2] + 5;
            BoundingBox[3] = BoundingBox[3] + 5;

            return(Result);
        }