Beispiel #1
0
        protected override SegmentedList <PointDouble> CreateShape(SegmentedList <PointDouble> tracePoints)
        {
            RectDouble  num5;
            PointDouble a    = tracePoints[0];
            PointDouble b    = tracePoints[tracePoints.Count - 1];
            PointDouble num3 = new PointDouble(b.X - a.X, b.Y - a.Y);
            double      num4 = Math.Sqrt((num3.X * num3.X) + (num3.Y * num3.Y));

            if ((base.ModifierKeys & Keys.Shift) != Keys.None)
            {
                PointDouble center = new PointDouble((a.X + b.X) / 2.0, (a.Y + b.Y) / 2.0);
                double      num7   = num4 / 2.0;
                num5 = RectDouble.FromCenter(center, (double)(num7 * 2.0));
            }
            else
            {
                num5 = RectDoubleUtil.FromPixelPoints(a, b);
            }
            PdnGraphicsPath path = new PdnGraphicsPath();

            path.AddEllipse(num5.ToGdipRectangleF());
            using (Matrix matrix = new Matrix())
            {
                path.Flatten(matrix, 0.1f);
            }
            SegmentedList <PointDouble> list = new SegmentedList <PointDouble>(path.PathPoints.Select <PointF, PointDouble>(pt => pt.ToDoublePoint()), 7);

            path.Dispose();
            return(list);
        }
Beispiel #2
0
        protected override SegmentedList <PointDouble> CreateShape(SegmentedList <PointDouble> tracePoints)
        {
            RectDouble        num3;
            double            num6;
            double            num7;
            PointDouble       a           = tracePoints[0];
            PointDouble       b           = tracePoints[tracePoints.Count - 1];
            SelectionDrawMode mode        = base.ToolSettings.Selection.DrawMode.Value;
            double            num4        = base.ToolSettings.Selection.DrawWidth.Value;
            double            num5        = base.ToolSettings.Selection.DrawHeight.Value;
            MeasurementUnit   sourceUnits = base.ToolSettings.Selection.DrawUnits.Value;

            switch (mode)
            {
            case SelectionDrawMode.FixedRatio:
            case SelectionDrawMode.FixedSize:
                num6 = Math.Abs(num4);
                num7 = Math.Abs(num5);
                break;

            default:
                num6 = num4;
                num7 = num5;
                break;
            }
            switch (mode)
            {
            case SelectionDrawMode.Normal:
                if ((base.ModifierKeys & Keys.Shift) == Keys.None)
                {
                    num3 = RectDoubleUtil.FromPixelPoints(a, b);
                    break;
                }
                num3 = RectDoubleUtil.FromPixelPointsConstrained(a, b);
                break;

            case SelectionDrawMode.FixedRatio:
                try
                {
                    double num13 = b.X - a.X;
                    double num14 = b.Y - a.Y;
                    double num15 = num13 / num6;
                    double num16 = Math.Sign(num15);
                    double num17 = num14 / num7;
                    double num18 = Math.Sign(num17);
                    double num19 = num6 / num7;
                    if (num15 < num17)
                    {
                        double x      = a.X;
                        double y      = a.Y;
                        double right  = a.X + num13;
                        double bottom = a.Y + (num18 * Math.Abs((double)(num13 / num19)));
                        num3 = RectDouble.FromEdges(x, y, right, bottom);
                    }
                    else
                    {
                        double left  = a.X;
                        double top   = a.Y;
                        double num26 = a.X + (num16 * Math.Abs((double)(num14 * num19)));
                        double num27 = a.Y + num14;
                        num3 = RectDouble.FromEdges(left, top, num26, num27);
                    }
                }
                catch (ArithmeticException)
                {
                    num3 = new RectDouble(a.X, a.Y, 0.0, 0.0);
                }
                break;

            case SelectionDrawMode.FixedSize:
            {
                double width  = Document.ConvertMeasurement(num6, sourceUnits, base.Document.DpuUnit, base.Document.DpuX, MeasurementUnit.Pixel);
                double height = Document.ConvertMeasurement(num7, sourceUnits, base.Document.DpuUnit, base.Document.DpuY, MeasurementUnit.Pixel);
                num3 = new RectDouble(b.X, b.Y, width, height);
                break;
            }

            default:
                throw ExceptionUtil.InvalidEnumArgumentException <SelectionDrawMode>(mode, "drawMode");
            }
            RectDouble num8  = RectDouble.Intersect(num3, base.Document.Bounds());
            RectDouble num10 = num8.Int32Bound;

            if (num8.HasPositiveArea)
            {
                SegmentedList <PointDouble> list = new SegmentedList <PointDouble>(5, 7)
                {
                    new PointDouble(num10.Left, num10.Top),
                    new PointDouble(num10.Right, num10.Top),
                    new PointDouble(num10.Right, num10.Bottom),
                    new PointDouble(num10.Left, num10.Bottom)
                };
                list.Add(list[0]);
                return(list);
            }
            return(new SegmentedList <PointDouble>(0, 7));
        }