Beispiel #1
0
        private void QueryBound(IPointCollection pts, ITransformation displayTransform, out double minx, out double miny,
                                out double maxx, out double maxy)
        {
            IPoint        point;
            IPoint        point1;
            int           i;
            double        x;
            double        y;
            double        num;
            double        num1;
            double        num2;
            double        num3;
            double        num4;
            double        num5 = 0;
            List <double> nums = new List <double>();

            for (i = 0; i < pts.PointCount - 1; i++)
            {
                point  = pts.Point[i];
                point1 = pts.Point[i + 1];
                x      = point.X - point1.X;
                y      = point.Y - point1.Y;
                double num6 = Math.Sqrt(x * x + y * y);
                num5 = num5 + num6;
                nums.Add(num6);
            }
            double    num7     = 1;
            IEnvelope envelope = (pts as IGeometry).Envelope;
            double    map      = this.PointsToMap(displayTransform, 50) * num7;

            minx = envelope.XMin;
            miny = envelope.YMin;
            maxx = envelope.XMax;
            maxy = envelope.YMax;
            double item = num5;

            for (i = 0; i < pts.PointCount - 1; i++)
            {
                point  = pts.Point[i];
                point1 = pts.Point[i + 1];
                num    = item / num5;
                num1   = LabelSymbol.azimuth(point, point1);
                num2   = num1 + 270;
                num3   = map * Math.Cos(num2 / 180 * 3.14159265358979) * num;
                num4   = map * Math.Sin(num2 / 180 * 3.14159265358979) * num;
                maxx   = (maxx > point.X + num3 ? maxx : point.X + num3);
                maxy   = (maxy > point.Y + num4 ? maxy : point.Y + num4);
                minx   = (minx < point.X + num3 ? minx : point.X + num3);
                miny   = (miny < point.Y + num4 ? miny : point.Y + num4);
                num2   = num1 + 90;
                num3   = map * Math.Cos(num2 / 180 * 3.14159265358979) * num;
                num4   = map * Math.Sin(num2 / 180 * 3.14159265358979) * num;
                maxx   = (maxx > point.X + num3 ? maxx : point.X + num3);
                maxy   = (maxy > point.Y + num4 ? maxy : point.Y + num4);
                minx   = (minx < point.X + num3 ? minx : point.X + num3);
                miny   = (miny < point.Y + num4 ? miny : point.Y + num4);
                item   = item - nums[i];
            }
            int pointCount = pts.PointCount;

            point  = pts.Point[pointCount - 2];
            point1 = pts.Point[pointCount - 1];
            double num8 = LabelSymbol.azimuth(point, point1);
            double map1 = this.PointsToMap(displayTransform, 60) * num7;
            double num9 = map1 * Math.Cos(0.523598775598299);

            if (num9 <= nums[pointCount - 2])
            {
                double item1 = nums[pointCount - 2] - num9;
                x    = point.X + item1 * Math.Cos(num8 / 180 * 3.14159265358979);
                y    = point.Y + item1 * Math.Sin(num8 / 180 * 3.14159265358979);
                num  = num9 / num5;
                num1 = num8;
                num2 = num1 + 270;
                num3 = map * Math.Cos(num2 / 180 * 3.14159265358979) * num;
                num4 = map * Math.Sin(num2 / 180 * 3.14159265358979) * num;
                maxx = (maxx > x + num3 ? maxx : x + num3);
                maxy = (maxy > y + num4 ? maxy : y + num4);
                minx = (minx < x + num3 ? minx : x + num3);
                miny = (miny < y + num4 ? miny : y + num4);
                num2 = num1 + 90;
                num3 = map * Math.Cos(num2 / 180 * 3.14159265358979) * num;
                num4 = map * Math.Sin(num2 / 180 * 3.14159265358979) * num;
                maxx = (maxx > x + num3 ? maxx : x + num3);
                maxy = (maxy > y + num4 ? maxy : y + num4);
                minx = (minx < x + num3 ? minx : x + num3);
                miny = (miny < y + num4 ? miny : y + num4);
            }
            double num10 = num8 + 30 - 180;
            double num11 = map1 * Math.Cos(num10 / 180 * 3.14159265358979);
            double num12 = map1 * Math.Sin(num10 / 180 * 3.14159265358979);

            maxx  = (maxx > point1.X + num11 ? maxx : point1.X + num11);
            maxy  = (maxy > point1.Y + num12 ? maxy : point1.Y + num12);
            minx  = (minx < point1.X + num11 ? minx : point1.X + num11);
            miny  = (miny < point1.Y + num12 ? miny : point1.Y + num12);
            num10 = num8 - 30 + 180;
            num11 = map1 * Math.Cos(num10 / 180 * 3.14159265358979);
            num12 = map1 * Math.Sin(num10 / 180 * 3.14159265358979);
            maxx  = (maxx > point1.X + num11 ? maxx : point1.X + num11);
            maxy  = (maxy > point1.Y + num12 ? maxy : point1.Y + num12);
            minx  = (minx < point1.X + num11 ? minx : point1.X + num11);
            miny  = (miny < point1.Y + num12 ? miny : point1.Y + num12);
        }
Beispiel #2
0
        private void Draw(Graphics g, Utility.POINTAPI[] ctrlpts)
        {
            int           i;
            double        num  = 0;
            List <double> nums = new List <double>();

            for (i = 0; i < (int)ctrlpts.Length - 1; i++)
            {
                double num1 = (double)(ctrlpts[i].x - ctrlpts[i + 1].x);
                double num2 = (double)(ctrlpts[i].y - ctrlpts[i + 1].y);
                double num3 = Math.Sqrt(num1 * num1 + num2 * num2);
                num = num + num3;
                nums.Add(num3);
            }
            double num4 = 50;

            PointF[] pointFArray  = new PointF[(int)ctrlpts.Length];
            PointF[] pointFArray1 = new PointF[(int)ctrlpts.Length];
            double   item         = num;

            for (i = 0; i < (int)ctrlpts.Length - 1; i++)
            {
                double num5 = item / num;
                double num6 = LabelSymbol.azimuth((double)ctrlpts[i].x, (double)ctrlpts[i].y,
                                                  (double)ctrlpts[i + 1].x, (double)ctrlpts[i + 1].y);
                double num7   = num6 + 270;
                double num8   = num4 * Math.Cos(num7 / 180 * 3.14159265358979) * num5;
                double num9   = num4 * Math.Sin(num7 / 180 * 3.14159265358979) * num5;
                PointF pointF = new PointF();
                pointFArray[i].X  = (float)((double)ctrlpts[i].x + num8);
                pointFArray[i].Y  = (float)((double)ctrlpts[i].y + num9);
                num7              = num6 + 90;
                num8              = num4 * Math.Cos(num7 / 180 * 3.14159265358979) * num5;
                num9              = num4 * Math.Sin(num7 / 180 * 3.14159265358979) * num5;
                pointFArray1[i].X = (float)((double)ctrlpts[i].x + num8);
                pointFArray1[i].Y = (float)((double)ctrlpts[i].y + num9);
                item              = item - nums[i];
            }
            int    length = (int)ctrlpts.Length;
            double num10  = LabelSymbol.azimuth((double)ctrlpts[length - 2].x, (double)ctrlpts[length - 2].y,
                                                (double)ctrlpts[length - 1].x, (double)ctrlpts[length - 1].y);
            double num11 = 30;
            double num12 = num10 + 30 - 180;
            double num13 = num11 * Math.Cos(num12 / 180 * 3.14159265358979);
            double num14 = num11 * Math.Sin(num12 / 180 * 3.14159265358979);

            pointFArray[length - 1].X = (float)((double)ctrlpts[length - 1].x + num13);
            pointFArray[length - 1].Y = (float)((double)ctrlpts[length - 1].y + num14);
            double num15 = (double)ctrlpts[length - 1].x + num13 + num13;
            double num16 = (double)ctrlpts[length - 1].y + num14 + num14;

            num12 = num10 - 30 + 180;
            num13 = num11 * Math.Cos(num12 / 180 * 3.14159265358979);
            num14 = num11 * Math.Sin(num12 / 180 * 3.14159265358979);
            pointFArray1[length - 1].X = (float)((double)ctrlpts[length - 1].x + num13);
            pointFArray1[length - 1].Y = (float)((double)ctrlpts[length - 1].y + num14);
            double num17 = (double)ctrlpts[length - 1].x + num13 + num13;
            double num18 = (double)ctrlpts[length - 1].y + num14 + num14;

            g.DrawLine(Pens.Black, (float)ctrlpts[length - 1].x, (float)ctrlpts[length - 1].y, (float)num15,
                       (float)num16);
            g.DrawLine(Pens.Black, (float)ctrlpts[length - 1].x, (float)ctrlpts[length - 1].y, (float)num17,
                       (float)num18);
            if (length <= 2)
            {
                g.DrawLines(Pens.Red, pointFArray);
                g.DrawLines(Pens.Green, pointFArray1);
            }
            else
            {
                g.DrawCurve(Pens.Red, pointFArray);
                g.DrawCurve(Pens.Green, pointFArray1);
            }
        }
Beispiel #3
0
        private void Draw2(Graphics g, Utility.POINTAPI[] ctrlpts)
        {
            int           i;
            double        num;
            double        num1;
            double        num2;
            double        num3;
            double        num4;
            double        num5;
            double        num6;
            double        num7 = 0;
            List <double> nums = new List <double>();

            for (i = 0; i < (int)ctrlpts.Length - 1; i++)
            {
                num  = (double)(ctrlpts[i].x - ctrlpts[i + 1].x);
                num1 = (double)(ctrlpts[i].y - ctrlpts[i + 1].y);
                double num8 = Math.Sqrt(num * num + num1 * num1);
                num7 = num7 + num8;
                nums.Add(num8);
            }
            double referenceScale = 1;

            if ((this.m_trans.ReferenceScale == 0 ? false : this.m_trans.Units != esriUnits.esriUnknownUnits))
            {
                try
                {
                    referenceScale = this.m_trans.ReferenceScale / this.m_trans.ScaleRatio;
                }
                catch
                {
                }
            }
            double num9 = 50 * referenceScale;

            PointF[] x    = new PointF[(int)ctrlpts.Length];
            PointF[] y    = new PointF[(int)ctrlpts.Length];
            double   item = num7;

            for (i = 0; i < (int)ctrlpts.Length - 1; i++)
            {
                num2 = item / num7;
                num3 = LabelSymbol.azimuth((double)ctrlpts[i].x, (double)ctrlpts[i].y, (double)ctrlpts[i + 1].x,
                                           (double)ctrlpts[i + 1].y);
                num4   = num3 + 270;
                num5   = num9 * Math.Cos(num4 / 180 * 3.14159265358979) * num2;
                num6   = num9 * Math.Sin(num4 / 180 * 3.14159265358979) * num2;
                x[i].X = (float)((double)ctrlpts[i].x + num5);
                x[i].Y = (float)((double)ctrlpts[i].y + num6);
                num4   = num3 + 90;
                num5   = num9 * Math.Cos(num4 / 180 * 3.14159265358979) * num2;
                num6   = num9 * Math.Sin(num4 / 180 * 3.14159265358979) * num2;
                y[i].X = (float)((double)ctrlpts[i].x + num5);
                y[i].Y = (float)((double)ctrlpts[i].y + num6);
                item   = item - nums[i];
            }
            int    length = (int)ctrlpts.Length;
            double num10  = LabelSymbol.azimuth((double)ctrlpts[length - 2].x, (double)ctrlpts[length - 2].y,
                                                (double)ctrlpts[length - 1].x, (double)ctrlpts[length - 1].y);
            double num11 = 60 * referenceScale;
            double num12 = num11 * Math.Cos(0.523598775598299);

            if (num12 > nums[length - 2])
            {
                x[length - 1].X = x[length - 2].X;
                x[length - 1].Y = x[length - 2].Y;
                y[length - 1].X = y[length - 2].X;
                y[length - 1].Y = y[length - 2].Y;
            }
            else
            {
                double item1 = nums[length - 2] - num12;
                num             = (double)ctrlpts[length - 2].x + item1 * Math.Cos(num10 / 180 * 3.14159265358979);
                num1            = (double)ctrlpts[length - 2].y + item1 * Math.Sin(num10 / 180 * 3.14159265358979);
                num2            = num12 / num7;
                num3            = num10;
                num4            = num3 + 270;
                num5            = num9 * Math.Cos(num4 / 180 * 3.14159265358979) * num2;
                num6            = num9 * Math.Sin(num4 / 180 * 3.14159265358979) * num2;
                x[length - 1].X = (float)(num + num5);
                x[length - 1].Y = (float)(num1 + num6);
                num4            = num3 + 90;
                num5            = num9 * Math.Cos(num4 / 180 * 3.14159265358979) * num2;
                num6            = num9 * Math.Sin(num4 / 180 * 3.14159265358979) * num2;
                y[length - 1].X = (float)(num + num5);
                y[length - 1].Y = (float)(num1 + num6);
            }
            double num13 = num10 + 30 - 180;
            double num14 = num11 * Math.Cos(num13 / 180 * 3.14159265358979);
            double num15 = num11 * Math.Sin(num13 / 180 * 3.14159265358979);
            double num16 = (double)ctrlpts[length - 1].x + num14;
            double num17 = (double)ctrlpts[length - 1].y + num15;

            num13 = num10 - 30 + 180;
            num14 = num11 * Math.Cos(num13 / 180 * 3.14159265358979);
            num15 = num11 * Math.Sin(num13 / 180 * 3.14159265358979);
            double num18 = (double)ctrlpts[length - 1].x + num14;
            double num19 = (double)ctrlpts[length - 1].y + num15;

            System.Drawing.Color color = ColorTranslator.FromOle(this.m_pColor.RGB);
            Pen pen = new Pen(color, (float)this.m_widht);

            g.DrawLine(pen, (float)ctrlpts[length - 1].x, (float)ctrlpts[length - 1].y, (float)num16, (float)num17);
            g.DrawLine(pen, (float)ctrlpts[length - 1].x, (float)ctrlpts[length - 1].y, (float)num18, (float)num19);
            g.DrawLine(pen, (float)x[length - 1].X, (float)x[length - 1].Y, (float)num16, (float)num17);
            g.DrawLine(pen, (float)y[length - 1].X, (float)y[length - 1].Y, (float)num18, (float)num19);
            if (length <= 2)
            {
                g.DrawLines(pen, x);
                g.DrawLines(pen, y);
            }
            else
            {
                g.DrawCurve(pen, x);
                g.DrawCurve(pen, y);
            }
            pen.Dispose();
        }
Beispiel #4
0
        public static double azimuth(IPoint pt1, IPoint pt2)
        {
            double num = LabelSymbol.azimuth(pt1.X, pt1.Y, pt2.X, pt2.Y);

            return(num);
        }