示例#1
0
        private ShapeRenderData CreateRenderDataImpl(ShapeRenderParameters renderParams, Func <ShapeRenderParameters, ShapeRenderData> onCreate)
        {
            Validate.IsNotNull <ShapeRenderParameters>(renderParams, "renderParams");
            VerifyRenderSettingValues(this.RenderSettingPaths, renderParams.SettingValues);
            if (((!renderParams.StartPoint.IsFinite || !renderParams.EndPoint.IsFinite) || ((this.options.Elide == ShapeElideOption.ZeroWidthOrZeroHeight) && !RectDouble.FromCorners(renderParams.StartPoint, renderParams.EndPoint).HasPositiveArea)) || ((this.options.Elide == ShapeElideOption.ZeroWidthAndZeroHeight) && (renderParams.StartPoint == renderParams.EndPoint)))
            {
                return(new ShapeRenderData(Geometry.Empty));
            }
            ShapeRenderData renderData         = onCreate(renderParams);
            RectDouble      bounds             = RectDouble.FromCorners(renderParams.StartPoint, renderParams.EndPoint);
            Matrix3x2Double alignmentTransform = GetAlignmentTransform(renderData.Guide.Bounds, bounds);

            return(ShapeRenderData.Transform(renderData, alignmentTransform));
        }
示例#2
0
        protected sealed override ShapeRenderData OnCreateRenderData(ShapeRenderParameters renderParams)
        {
            ShapeDrawType type                 = (ShapeDrawType)renderParams.SettingValues[ToolSettings.Null.Shapes.DrawType.Path];
            RectDouble    bounds               = RectDouble.FromCorners(renderParams.StartPoint, renderParams.EndPoint);
            Geometry      guideGeometry        = this.OnCreateGuideGeometry(bounds, renderParams.SettingValues);
            Geometry      interiorFillGeometry = null;

            if ((type & ShapeDrawType.Interior) == ShapeDrawType.Interior)
            {
                interiorFillGeometry = this.OnCreateInteriorFillGeometry(bounds, renderParams.SettingValues);
            }
            Geometry outlineDrawGeometry = null;
            Geometry outlineFillGeometry = null;

            if ((type & ShapeDrawType.Outline) == ShapeDrawType.Outline)
            {
                outlineDrawGeometry = this.OnCreateOutlineDrawGeometry(bounds, renderParams.SettingValues);
                outlineFillGeometry = this.OnCreateOutlineFillGeometry(bounds, renderParams.SettingValues);
            }
            return(new ShapeRenderData(guideGeometry, interiorFillGeometry, outlineDrawGeometry, outlineFillGeometry));
        }
示例#3
0
        private Geometry CreateLineCurveGeometry(ShapeRenderParameters renderParams)
        {
            Geometry  geometry;
            CurveType type = (CurveType)renderParams.SettingValues[ToolSettings.Null.Shapes.CurveType.Path];

            if (renderParams.HasPropertyValues && renderParams.PropertyValues.Any <KeyValuePair <object, object> >())
            {
                RectDouble         num      = RectDouble.FromCorners(renderParams.StartPoint, renderParams.EndPoint);
                List <PointDouble> source   = new List <PointDouble>();
                PointDouble[]      numArray = this.GetInitialControlPointValues(renderParams).ToArrayEx <PointDouble>();
                bool flag = false;
                for (int i = 0; i < this.controlPointPropertyNames.Length; i++)
                {
                    object controlPointPropertyName = this.GetControlPointPropertyName(i);
                    Pair <double, double> pair      = (Pair <double, double>)renderParams.PropertyValues[controlPointPropertyName];
                    if ((pair.First != numArray[i].X) || (pair.Second != numArray[i].Y))
                    {
                        flag = true;
                    }
                    PointDouble num3 = new PointDouble(pair.First, pair.Second);
                    PointDouble item = new PointDouble(((num3.X - num.X) * renderParams.TransformScale.X) + num.X, ((num3.Y - num.Y) * renderParams.TransformScale.Y) + num.Y);
                    source.Add(item);
                }
                if (!flag)
                {
                    geometry = new LineGeometry(renderParams.StartPoint, renderParams.EndPoint).EnsureFrozen <LineGeometry>();
                }
                else
                {
                    PathSegment segment;
                    if (type != CurveType.Spline)
                    {
                        if (type != CurveType.Bezier)
                        {
                            throw ExceptionUtil.InvalidEnumArgumentException <CurveType>(type, "curveType");
                        }
                    }
                    else
                    {
                        PathGeometry         geometry1   = new PathGeometry();
                        PathFigureCollection collection1 = new PathFigureCollection(1);
                        PathFigure           figure1     = new PathFigure {
                            StartPoint = source[0],
                            IsClosed   = false
                        };
                        PathSegmentCollection collection2 = new PathSegmentCollection(1);
                        collection2.Add(new PolyCurveSegment(new ListSegment <PointDouble>(source, 1, source.Count - 1)));
                        figure1.Segments = collection2;
                        collection1.Add(figure1);
                        geometry1.Figures = collection1;
                        geometry          = geometry1;
                        goto Label_0271;
                    }
                    if (source.Count == 4)
                    {
                        segment = new BezierSegment(source[1], source[2], source[3]);
                    }
                    else
                    {
                        segment = new PolyBezierSegment(new ListSegment <PointDouble>(source, 1, source.Count - 1));
                    }
                    PathGeometry         geometry2   = new PathGeometry();
                    PathFigureCollection collection3 = new PathFigureCollection(1);
                    PathFigure           figure2     = new PathFigure {
                        StartPoint = source[0],
                        IsClosed   = false
                    };
                    PathSegmentCollection collection4 = new PathSegmentCollection(1);
                    collection4.Add(segment);
                    figure2.Segments = collection4;
                    collection3.Add(figure2);
                    geometry2.Figures = collection3;
                    geometry          = geometry2;
                }
            }
            else
            {
                geometry = new LineGeometry(renderParams.StartPoint, renderParams.EndPoint);
            }
Label_0271:
            return(geometry.EnsureFrozen <Geometry>());
        }
示例#4
0
        protected sealed override ShapeRenderData OnCreateImageRenderData(ShapeRenderParameters renderParams)
        {
            RectDouble bounds = RectDouble.FromCorners(renderParams.StartPoint, renderParams.EndPoint);

            return(new ShapeRenderData(this.OnCreateImageGeometry(bounds, renderParams.SettingValues)));
        }