Beispiel #1
0
        internal CoPointClass LineToPoint(string string_5)
        {
            CoPointClass class2 = new CoPointClass();

            if (string_5 == null)
            {
                return(class2);
            }
            string[] strArray = string_5.Split(new char[] { this.Separator });
            if (strArray.Length > 1)
            {
                double result = 0.0;
                double.TryParse(strArray[0], out result);
                double num2 = 0.0;
                double.TryParse(strArray[1], out num2);
                class2.X = result;
                class2.Y = num2;
                return(class2);
            }
            if (strArray.Length > 2)
            {
                double num3 = 0.0;
                double.TryParse(strArray[2], out num3);
                class2.Z = num3;
                return(class2);
            }
            return(null);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // An collection of COM cars.
            ArrayList carArray = new ArrayList();

            // Create some comparable COM cars.
            Random r = new Random();

            for (int i = 0; i < 10; i++)
            {
                carArray.Add(new CarClass());
                int newID = r.Next(50) + 100;
                ((CarClass)(carArray[i])).SetCarID((short)newID);
            }

            // Print cars as is...
            Console.WriteLine("***** The unordered COM cars *****");
            for (int i = 0; i < carArray.Count; i++)
            {
                Console.WriteLine("Car #{0} has ID {1}", i,
                                  ((CarClass)(carArray[i])).GetCarID());
            }

            // Now sort the COM objects.
            Console.WriteLine("\n\n***** The ordered COM cars *****");
            carArray.Sort();
            // Print sorted cars...
            for (int i = 0; i < carArray.Count; i++)
            {
                Console.WriteLine("Car #{0} has ID {1}", i,
                                  ((CarClass)(carArray[i])).GetCarID());
            }

            // Test the clone!
            Console.WriteLine("\n***** Testing ICloneable *****");
            CoPointClass p1 = new CoPointClass();

            p1.X = 100;
            p1.Y = 100;
            Console.WriteLine("P1.x = {0} P1.x = {1}", p1.X, p1.Y);

            // Make a clone.
            CoPointClass p2 = (CoPointClass)p1.Clone();

            Console.WriteLine("P2.x = {0} P2.x = {1}", p2.X, p2.Y);

            // This change should not effect P1.
            p2.X = 500;
            p2.Y = 987;

            Console.WriteLine("P1.x = {0} P1.x = {1}", p1.X, p1.Y);
            Console.WriteLine("P2.x = {0} P2.x = {1}", p2.X, p2.Y);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            // An collection of COM cars.
            ArrayList carArray = new ArrayList();

            // Create some comparable COM cars.
            Random r = new Random();
            for(int i = 0; i < 10; i++)
            {
                carArray.Add(new CarClass());
                int newID = r.Next(50)+100;
                ((CarClass)(carArray[i])).SetCarID((short)newID);
            }

            // Print cars as is...
            Console.WriteLine("***** The unordered COM cars *****");
            for(int i = 0; i < carArray.Count; i++)
            {
                Console.WriteLine("Car #{0} has ID {1}", i,
                    ((CarClass)(carArray[i])).GetCarID());
            }

            // Now sort the COM objects.
            Console.WriteLine("\n\n***** The ordered COM cars *****");
            carArray.Sort();
            // Print sorted cars...
            for(int i = 0; i < carArray.Count; i++)
            {
                Console.WriteLine("Car #{0} has ID {1}", i,
                    ((CarClass)(carArray[i])).GetCarID());
            }

            // Test the clone!
            Console.WriteLine("\n***** Testing ICloneable *****");
            CoPointClass p1 = new CoPointClass();
            p1.X = 100;
            p1.Y = 100;
            Console.WriteLine("P1.x = {0} P1.x = {1}", p1.X, p1.Y);

            // Make a clone.
            CoPointClass p2 = (CoPointClass)p1.Clone();
            Console.WriteLine("P2.x = {0} P2.x = {1}", p2.X, p2.Y);

            // This change should not effect P1.
            p2.X = 500;
            p2.Y = 987;

            Console.WriteLine("P1.x = {0} P1.x = {1}", p1.X, p1.Y);
            Console.WriteLine("P2.x = {0} P2.x = {1}", p2.X, p2.Y);
        }
Beispiel #4
0
        public void CreateMap()
        {
            try
            {
                string str2;
                string str3;
                int    num3;
                int    num4;
                this.arrayList_0.Clear();
                this.arrayList_1.Clear();
                this.arrayList_2.Clear();
                this.featureOIDMapCollection_0.Clear();
                ICoLayer[] layers = this.Layers;
                for (int i = 0; i < layers.Length; i++)
                {
                    this.arrayList_0.Add(null);
                    this.arrayList_1.Add(null);
                    this.arrayList_2.Add(null);
                }
                StreamReader reader = new StreamReader(this.string_0, Encoding.Default);
                string       str    = string.Empty;
                this.long_0            = 1L;
                this.dataFile.Position = 0L;
                this.dataFile.Map.Add(this.dataFile.Position);
                int  num2 = -1;
                bool flag = false;
                this.method_0(reader, "POINTBEGIN");
                while (!reader.EndOfStream)
                {
                    str2 = this.method_1(ref reader);
                    while (str2.Trim().Length <= 0)
                    {
                        str2 = this.method_1(ref reader);
                    }
                    if (str2.ToUpper().Trim() == "POINTEND")
                    {
                        goto Label_019F;
                    }
                    str3 = this.method_1(ref reader);
                    if (str != str3)
                    {
                        str  = str3;
                        num2 = this.FindLayerIndex(str, CoLayerType.Point);
                        if ((num2 != -1) && (this.arrayList_0[num2] == null))
                        {
                            this.arrayList_0[num2] = this.long_0 - 2L;
                        }
                    }
                    this.method_1(ref reader);
                    this.method_1(ref reader);
                    this.method_1(ref reader);
                }
                goto Label_01A2;
Label_019F:
                flag = true;
Label_01A2:
                if (!flag)
                {
                    this.WriteLog(string.Format(this.string_2, "POINTBEGIN", "POINTEND"));
                }
                flag = false;
                str  = string.Empty;
                this.method_0(reader, "LINEBEGIN");
Label_01D7:
                if (!reader.EndOfStream)
                {
                    str2 = this.method_1(ref reader);
                    while (str2.Trim().Length <= 0)
                    {
                        str2 = this.method_1(ref reader);
                    }
                    FeatureOIDMap map = this.method_2(str2);
                    if (str2.ToUpper().Trim() != "LINEEND")
                    {
                        str3 = this.method_1(ref reader);
                        if (str != str3)
                        {
                            str  = str3;
                            num2 = this.FindLayerIndex(str, CoLayerType.Line);
                            if ((num2 != -1) && (this.arrayList_0[num2] == null))
                            {
                                this.arrayList_0[num2] = this.long_0 - 2L;
                            }
                        }
                        this.method_1(ref reader);
                        this.method_1(ref reader);
                        num3 = 0;
                        int.TryParse(this.method_1(ref reader).Trim(), out num3);
                        num4 = 0;
                        while (num4 < num3)
                        {
                            string str4 = this.method_1(ref reader);
                            try
                            {
                                CoPointClass class2 = this.LineToPoint(str4);
                                map.PointArray.Add(class2);
                            }
                            catch (Exception exception1)
                            {
                                this.WriteLog(str4 + "\r\n" + exception1.ToString());
                            }
                            num4++;
                        }
                        goto Label_01D7;
                    }
                    flag = true;
                }
                if (!flag)
                {
                    this.WriteLog(string.Format(this.string_2, "LINEBEGIN", "LINEEND"));
                }
                flag = false;
                str  = string.Empty;
                this.method_0(reader, "POLYGONBEGIN");
                while (!reader.EndOfStream)
                {
                    str2 = this.method_1(ref reader);
                    while (str2.Trim().Length <= 0)
                    {
                        str2 = this.method_1(ref reader);
                    }
                    if (str2.ToUpper().Trim() == "POLYGONEND")
                    {
                        goto Label_04DF;
                    }
                    str3 = this.method_1(ref reader);
                    if (str != str3)
                    {
                        str  = str3;
                        num2 = this.FindLayerIndex(str, CoLayerType.Region);
                        if ((num2 != -1) && (this.arrayList_0[num2] == null))
                        {
                            this.arrayList_0[num2] = this.long_0 - 2L;
                        }
                    }
                    string str5 = this.method_1(ref reader);
                    str5 = this.method_1(ref reader);
                    if (this.LineToPoint(str5) == null)
                    {
                        str5 = this.method_1(ref reader);
                    }
                    num3 = 0;
                    int.TryParse(this.method_1(ref reader).Trim(), out num3);
                    switch (this.coLayerHead_0.Topo)
                    {
                    case 0:
                        goto Label_048F;

                    case 1:
                    {
                        int num6 = num3 / 8;
                        if ((num3 % 8) > 0)
                        {
                            num6++;
                        }
                        num4 = 0;
                        while (num4 < num6)
                        {
                            this.method_1(ref reader);
                            num4++;
                        }
                        continue;
                    }

                    default:
                    {
                        continue;
                    }
                    }
Label_045E:
                    num4 = 0;
                    while (num4 < num3)
                    {
                        this.method_1(ref reader);
                        num4++;
                    }
                    int.TryParse(this.method_1(ref reader).Trim(), out num3);
Label_048F:
                    if (num3 != 0)
                    {
                        goto Label_045E;
                    }
                }
                goto Label_04E2;
Label_04DF:
                flag = true;
Label_04E2:
                if (!flag)
                {
                    this.WriteLog(string.Format(this.string_2, "POLYGONBEGIN", "POLYGONEND"));
                }
                flag = false;
                str  = string.Empty;
                this.method_0(reader, "ANNOTATIONBEGIN");
                while (!reader.EndOfStream)
                {
                    str2 = this.method_1(ref reader);
                    while (str2.Trim().Length <= 0)
                    {
                        str2 = this.method_1(ref reader);
                    }
                    if (str2.ToUpper().Trim() == "ANNOTATIONEND")
                    {
                        goto Label_0621;
                    }
                    str3 = this.method_1(ref reader);
                    if (str != str3)
                    {
                        str  = str3;
                        num2 = this.FindLayerIndex(str, CoLayerType.Annotation);
                        if ((num2 != -1) && (this.arrayList_0[num2] == null))
                        {
                            this.arrayList_0[num2] = this.long_0 - 2L;
                        }
                    }
                    this.method_1(ref reader);
                    this.method_1(ref reader);
                    this.method_1(ref reader);
                    this.method_1(ref reader);
                    this.method_1(ref reader);
                    this.method_1(ref reader);
                    this.method_1(ref reader);
                    this.method_1(ref reader);
                    this.method_1(ref reader);
                }
                goto Label_0624;
Label_0621:
                flag = true;
Label_0624:
                if (!flag)
                {
                    this.WriteLog(string.Format(this.string_2, "ANNOTATIONBEGIN", "ANNOTATIONEND"));
                }
                flag = false;
                this.method_0(reader, "ATTRIBUTEBEGIN");
                while (!reader.EndOfStream)
                {
                    string str6 = this.method_1(ref reader);
                    while (str6.Trim().Length <= 0)
                    {
                        str6 = this.method_1(ref reader);
                    }
                    if (str6.Trim().ToUpper() == "ATTRIBUTEEND")
                    {
                        goto Label_073F;
                    }
                    num2 = this.FindLayerIndexByName(str6);
                    if (num2 != -1)
                    {
                        this.arrayList_1[num2] = this.long_0;
                    }
                    int num7 = 0;
                    for (string str7 = this.method_1(ref reader);
                         str7.Trim().ToUpper() != "TABLEEND";
                         str7 = this.method_1(ref reader))
                    {
                        if (str7.Trim().Length > 0)
                        {
                            num7++;
                        }
                    }
                    if (num2 != -1)
                    {
                        this.arrayList_2[num2] = num7;
                    }
                }
                goto Label_0742;
Label_073F:
                flag = true;
Label_0742:
                if (!flag)
                {
                    this.WriteLog(string.Format(this.string_2, "ATTRIBUTEBEGIN", "ATTRIBUTEEND"));
                }
                reader.Close();
                reader.Dispose();
                reader = null;
            }
            catch (Exception exception2)
            {
                this.WriteLog(exception2.ToString());
            }
        }
Beispiel #5
0
        public override int NextFeature()
        {
            ICoFeature feature = null;
            int        num3;
            Exception  exception;
            string     str7;
            Color      color;
            bool       flag;
            string     s    = string.Empty;
            string     str2 = string.Empty;
            string     str3 = string.Empty;

            string[] strArray = new string[0];
            switch (base.XpgisLayer.LayerType)
            {
            case CoLayerType.Point:
                goto Label_034A;

            case CoLayerType.Line:
            {
                feature = new CoPolylineFeature(base.XpgisLayer);
                s       = string.Empty;
                if (this.streamReader_0 == null)
                {
                    if (this.long_1 != 0L)
                    {
                        this.streamReader_0 = this.vctClass_0.CreateReader(this.long_1 - 1L);
                        this.long_3         = this.long_1 - 1L;
                        this.long_1         = 0L;
                    }
                    else
                    {
                        this.streamReader_0 = this.vctClass_0.CreateReader(this.long_0 - 1L);
                        this.long_3         = this.long_0 - 1L;
                    }
                }
                s = this.method_1(ref this.streamReader_0);
                while (s.Length <= 0)
                {
                    s = this.method_1(ref this.streamReader_0);
                }
                str2 = this.method_1(ref this.streamReader_0);
                if (this.vctClass_0.FindLayerIndex(str2, CoLayerType.Line) !=
                    this.vctClass_0.FindLayerIndexByName(base.XpgisLayer.Name))
                {
                    return(-1);
                }
                this.method_1(ref this.streamReader_0);
                this.method_1(ref this.streamReader_0);
                int num2 = 0;
                int.TryParse(this.method_1(ref this.streamReader_0), out num2);
                CoPointCollection points = new CoPointCollection();
                for (num3 = 0; num3 < num2; num3++)
                {
                    string str4 = this.method_1(ref this.streamReader_0);
                    try
                    {
                        CoPointClass class3 = this.vctClass_0.LineToPoint(str4);
                        points.Add(class3);
                    }
                    catch (Exception exception2)
                    {
                        exception = exception2;
                        this.vctClass_0.WriteLog(string.Format(this.string_0, this.long_3, "不能转换为坐标"));
                        this.streamReader_0.Close();
                        this.streamReader_0.Dispose();
                        this.streamReader_0 = null;
                        this.long_1         = this.long_3;
                        return(-2);
                    }
                }
                (feature as CoPolylineFeature).Points.Add(points);
                feature.OID = int.Parse(s);
                goto Label_0AA8;
            }

            case CoLayerType.Region:
            {
                int num4;
                feature = new CoPolygonFeature(base.XpgisLayer);
                s       = string.Empty;
                if (this.streamReader_0 == null)
                {
                    this.streamReader_0 = this.vctClass_0.CreateReader(this.long_0 - 1L);
                    this.long_3         = this.long_0 - 1L;
                }
                for (s = this.method_1(ref this.streamReader_0);
                     s.Length <= 0;
                     s = this.method_1(ref this.streamReader_0))
                {
                }
                str2 = this.method_1(ref this.streamReader_0);
                if (this.vctClass_0.FindLayerIndex(str2, CoLayerType.Region) !=
                    this.vctClass_0.FindLayerIndexByName(base.XpgisLayer.Name))
                {
                    return(-1);
                }
                this.method_1(ref this.streamReader_0);
                string str5 = this.method_1(ref this.streamReader_0);
                if (this.vctClass_0.LineToPoint(str5) == null)
                {
                    str5 = this.method_1(ref this.streamReader_0);
                }
                if (this.icoLayer_1.Parameter.Topo != 0)
                {
                    if (this.icoLayer_1.Parameter.Topo == 1)
                    {
                        this.vctClass_0.LineToPoint(str5);
                        num4 = 0;
                        int.TryParse(this.method_1(ref this.streamReader_0).Trim(), out num4);
                        int num5 = 0;
                        num5 = num4 / 8;
                        if ((num4 % 8) > 0)
                        {
                            num5++;
                        }
                        (feature as CoPolygonFeature).Points.Add(new CoPointCollection());
                        for (num3 = 0; num3 < num5; num3++)
                        {
                            foreach (
                                string str6 in
                                this.method_1(ref this.streamReader_0).Split(new char[] { this.vctClass_0.Separator })
                                )
                            {
                                int num7 = 0;
                                int.TryParse(str6.Trim(), out num7);
                                if (num7 != 0)
                                {
                                    CoPointCollection points3 = this.method_0(Math.Abs(num7));
                                    if (num7 > 0)
                                    {
                                        foreach (CoPointClass class4 in points3)
                                        {
                                            (feature as CoPolygonFeature).Points[
                                                (feature as CoPolygonFeature).Points.Count - 1].Add(class4);
                                        }
                                    }
                                    else if (num7 < 0)
                                    {
                                        for (int i = points3.Count - 1; i > -1; i--)
                                        {
                                            (feature as CoPolygonFeature).Points[
                                                (feature as CoPolygonFeature).Points.Count - 1].Add(points3[i]);
                                        }
                                    }
                                }
                                else
                                {
                                    (feature as CoPolygonFeature).Points.Add(new CoPointCollection());
                                }
                            }
                        }
                    }
                }
                else
                {
                    this.vctClass_0.LineToPoint(str5);
                    num4 = 0;
                    int.TryParse(this.method_1(ref this.streamReader_0).Trim(), out num4);
                    while (num4 > 0)
                    {
                        (feature as CoPolygonFeature).Points.Add(new CoPointCollection());
                        num3 = 0;
                        while (num3 < num4)
                        {
                            CoPointClass class4 = this.vctClass_0.LineToPoint(this.streamReader_0.ReadLine().Trim());
                            if (class4 == null)
                            {
                                this.vctClass_0.WriteLog(string.Format(this.string_0, this.long_3, "不能转换为坐标"));
                                this.streamReader_0.Close();
                                this.streamReader_0.Dispose();
                                this.streamReader_0 = null;
                                this.long_0         = this.long_3;
                                return(-2);
                            }
                            (feature as CoPolygonFeature).Points[(feature as CoPolygonFeature).Points.Count - 1].Add
                                (class4);
                            num3++;
                        }
                        int.TryParse(this.method_1(ref this.streamReader_0).Trim(), out num4);
                    }
                }
                goto Label_0AA8;
            }

            case CoLayerType.Annotation:
            {
                feature = new CoAnnotationFeature(base.XpgisLayer);
                s       = string.Empty;
                if (this.streamReader_0 == null)
                {
                    this.streamReader_0 = this.vctClass_0.CreateReader(this.long_0 - 1L);
                    this.long_3         = this.long_0 - 1L;
                }
                s = this.method_1(ref this.streamReader_0);
                while (s.Trim().Length <= 0)
                {
                    s = this.streamReader_0.ReadLine();
                }
                str2 = this.method_1(ref this.streamReader_0);
                if (this.vctClass_0.FindLayerIndex(str2, CoLayerType.Annotation) !=
                    this.vctClass_0.FindLayerIndexByName(base.XpgisLayer.Name))
                {
                    return(-1);
                }
                this.method_1(ref this.streamReader_0);
                str7  = this.method_1(ref this.streamReader_0).Trim();
                color = this.vctClass_0.LineToColor(this.method_1(ref this.streamReader_0).Trim());
                string[] strArray4 =
                    this.method_1(ref this.streamReader_0).Trim().Split(new char[] { this.vctClass_0.Separator });
                int num9 = 0;
                int.TryParse(strArray4[0].Trim(), out num9);
                uint num10 = 0;
                uint.TryParse(strArray4[1].Trim(), out num10);
                flag = false;
                string str8 = strArray4[2].Trim().ToUpper();
                if ((str8 == null) || (!(str8 == "T") && !(str8 == "Y")))
                {
                    flag = false;
                    break;
                }
                flag = true;
                break;
            }

            default:
                goto Label_0AA8;
            }
            float result = 8f;

            float.TryParse(this.method_1(ref this.streamReader_0).Trim(), out result);
            result /= 10f;
            float num12 = 8f;

            float.TryParse(this.method_1(ref this.streamReader_0).Trim(), out num12);
            num12 /= 8f;
            string str9 = this.method_1(ref this.streamReader_0).Trim();

            this.streamReader_0.ReadLine();
            CoPointClass item = this.vctClass_0.LineToPoint(this.method_1(ref this.streamReader_0).Trim());

            (feature as CoAnnotationFeature).Point.Add(item);
            (feature as CoAnnotationFeature).OID   = int.Parse(s);
            (feature as CoAnnotationFeature).Color = color;
            (feature as CoAnnotationFeature).Text  = str9;
            (feature as CoAnnotationFeature).Angle = 0.0;
            FontStyle regular = FontStyle.Regular;

            if (flag)
            {
                regular = FontStyle.Underline;
            }
            try
            {
                Font font = new Font(new FontFamily(str7), result, regular);
                (feature as CoAnnotationFeature).Font = font;
                goto Label_0AA8;
            }
            catch (Exception exception1)
            {
                exception = exception1;
                this.vctClass_0.WriteLog(string.Format(this.string_0, this.long_3, "不能转换为字体\r\n" + exception.ToString()));
                this.streamReader_0.Close();
                this.streamReader_0.Dispose();
                this.streamReader_0 = null;
                this.long_0         = this.long_3;
                return(-2);
            }
Label_034A:
            feature = new CoPointFeature(base.XpgisLayer);
            s       = string.Empty;
            if (this.streamReader_0 == null)
            {
                this.streamReader_0 = this.vctClass_0.CreateReader(this.long_0 - 1L);
                this.long_3         = this.long_0 - 1L;
            }
            s = this.method_1(ref this.streamReader_0);
            while (s.Length <= 0)
            {
                s = this.method_1(ref this.streamReader_0);
            }
            str2 = this.method_1(ref this.streamReader_0);
            if (this.vctClass_0.FindLayerIndex(str2, CoLayerType.Point) !=
                this.vctClass_0.FindLayerIndexByName(base.XpgisLayer.Name))
            {
                return(-1);
            }
            this.method_1(ref this.streamReader_0);
            this.method_1(ref this.streamReader_0);
            CoPointClass class2 = this.vctClass_0.LineToPoint(this.method_1(ref this.streamReader_0));

            if (class2 == null)
            {
                this.vctClass_0.WriteLog(string.Format(this.string_0, this.long_3, "不能转换为坐标"));
                this.streamReader_0.Close();
                this.streamReader_0.Dispose();
                this.streamReader_0 = null;
                this.long_0         = this.long_3;
                return(-2);
            }
            (feature as CoPointFeature).Point.Add(class2);
            feature.OID = int.Parse(s);
Label_0AA8:
            if (feature != null)
            {
                str3 = string.Empty;
                if (this.streamReader_1 == null)
                {
                    this.streamReader_1 = this.vctClass_0.CreateReader(this.long_2 - 1L);
                    this.long_4         = this.long_2 - 1L;
                }
                strArray = this.method_1(ref this.streamReader_1).Split(new char[] { this.vctClass_0.Separator });
                StringBuilder builder = new StringBuilder();
                string        str10   = string.Empty;
                for (num3 = 0; num3 < feature.Values.Length; num3++)
                {
                    ICoField field = feature.Layer.GetField(num3);
                    if (strArray.Length > feature.Values.Length)
                    {
                        if (strArray.Length > (num3 + 1))
                        {
                            feature.SetValue(num3, strArray[num3 + 1]);
                        }
                        else
                        {
                            str10 = feature.OID.ToString();
                            builder.Append(field.ToString() + ",");
                        }
                    }
                    else if (strArray.Length > num3)
                    {
                        feature.SetValue(num3, strArray[num3]);
                    }
                    else
                    {
                        str10 = feature.OID.ToString();
                        builder.Append(field.ToString() + ",");
                    }
                }
                if (str10.Length > 0)
                {
                    this.vctClass_0.WriteLog(string.Format("要素{0}的字段{1}没有找到属性。", str10, builder.ToString()));
                }
                base.XpgisLayer.AppendFeature(feature);
                this.int_0++;
                return(this.int_0);
            }
            return(-1);
        }