public void DrawGlyphRun(float baselineOriginX, float baselineOriginY, Graphics.Direct2D.MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ClientDrawingEffect clientDrawingEffect)
        {
            using (PathGeometry pathGeometry = _factory.CreatePathGeometry())
            {
                using (GeometrySink sink = pathGeometry.Open())
                {
                    glyphRun.FontFace.GetGlyphRunOutline(
                        glyphRun.EmSize,
                        glyphRun.GlyphIndices,
                        glyphRun.GlyphAdvances,
                        glyphRun.GlyphOffsets,
                        glyphRun.IsSideways,
                        glyphRun.BidiLevel != 0,
                        sink);
                    sink.Close();
                }

                CustomGeometrySink customSink = new CustomGeometrySink();
                pathGeometry.Stream(customSink);
                customSink.Close();
                System.Diagnostics.Debug.WriteLine(customSink.ToString());

                Matrix3x2 matrix = new Matrix3x2(1, 0, 0, 1, baselineOriginX, baselineOriginY);
                using (TransformedGeometry transformedGeometry = _factory.CreateTransformedGeometry(pathGeometry, matrix))
                {
                    _renderTarget.DrawGeometry(_outlineBrush, 5, transformedGeometry);
                    _renderTarget.FillGeometry(_fillBrush, transformedGeometry);
                }
            }
        }
Beispiel #2
0
        public Geometry CreateGeometry(Direct2DFactory factory)
        {
            PathGeometry geometry = factory.CreatePathGeometry();

            //using (GeometrySink sink = geometry.Open())
            //{
            //    sink.BeginFigure(Project(this._points[0]), FigureBegin.Hollow);
            //    for (int index = 1; index < this._points.Length; ++index)
            //    {
            //        sink.AddLine(Project(this._points[index]));
            //    }
            //    sink.EndFigure(FigureEnd.Open);
            //    sink.Close();
            //}
            List <Geometry> list = new List <Geometry>();

            //list.Add(geometry);

            for (int index = 0; index < _points.Length; ++index)
            {
                EllipseGeometry ellipse = factory.CreateEllipseGeometry(new Ellipse(Project(_points[index]), 5, 5));
                list.Add(ellipse);
            }

            GeometryGroup group = factory.CreateGeometryGroup(FillMode.Winding, list.ToArray());

            return(group);
        }
Beispiel #3
0
        private void CreateGeometries(Direct2DFactory factory)
        {
            Ellipse circle1 = new Ellipse(75, 75, 50, 50);

            this._circleGeometry1 = factory.CreateEllipseGeometry(circle1);

            Ellipse circle2 = new Ellipse(125, 75, 50, 50);

            this._circleGeometry2 = factory.CreateEllipseGeometry(circle2);
            // Union
            this._geometryUnion = factory.CreatePathGeometry();
            using (GeometrySink sink = this._geometryUnion.Open())
            {
                this._circleGeometry1.CombineWithGeometry(this._circleGeometry2, CombineMode.Union, Matrix3x2.Identity, 0.25f, sink);
                sink.Close();
            }
            // Intersect
            this._geometryIntersect = factory.CreatePathGeometry();
            using (GeometrySink sink = this._geometryIntersect.Open())
            {
                this._circleGeometry1.CombineWithGeometry(this._circleGeometry2, CombineMode.Intersect, Matrix3x2.Identity, 0.25f, sink);
                sink.Close();
            }
            // Xor
            this._geometryXor = factory.CreatePathGeometry();
            using (GeometrySink sink = this._geometryXor.Open())
            {
                this._circleGeometry1.CombineWithGeometry(this._circleGeometry2, CombineMode.Xor, Matrix3x2.Identity, 0.25f, sink);
                sink.Close();
            }
            // Exclude
            this._geometryExclude = factory.CreatePathGeometry();
            using (GeometrySink sink = this._geometryExclude.Open())
            {
                this._circleGeometry1.CombineWithGeometry(this._circleGeometry2, CombineMode.Exclude, Matrix3x2.Identity, 0.25f, sink);
                sink.Close();
            }
        }
Beispiel #4
0
 protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
 {
     base.OnCreateDeviceIndependentResources(factory);
     this._pathGeometry = factory.CreatePathGeometry();
     using (GeometrySink sink = this._pathGeometry.Open())
     {
         sink.SetFillMode(FillMode.Winding);
         sink.BeginFigure(new PointF(20, 50), FigureBegin.Filled);
         sink.AddLine(new PointF(130, 50));
         sink.AddLine(new PointF(20, 130));
         sink.AddLine(new PointF(80, 0));
         sink.AddLine(new PointF(130, 130));
         sink.EndFigure(FigureEnd.Closed);
         sink.Close();
     }
 }
Beispiel #5
0
 protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
 {
     base.OnCreateDeviceIndependentResources(factory);
     this._pathGeometry = factory.CreatePathGeometry();
     using (GeometrySink sink = this._pathGeometry.Open())
     {
         sink.SetFillMode(FillMode.Winding);
         sink.BeginFigure(new PointF(20, 50), FigureBegin.Filled);
         sink.AddLine(new PointF(130, 50));
         sink.AddLine(new PointF(20, 130));
         sink.AddLine(new PointF(80, 0));
         sink.AddLine(new PointF(130, 130));
         sink.EndFigure(FigureEnd.Closed);
         sink.Close();
     }
 }
        public void DrawGlyphRun(float baselineOriginX, float baselineOriginY, Graphics.Direct2D.MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ClientDrawingEffect clientDrawingEffect)
        {
            using (PathGeometry pathGeometry = _factory.CreatePathGeometry())
            {
                using (GeometrySink sink = pathGeometry.Open())
                {
                    glyphRun.FontFace.GetGlyphRunOutline(
                        glyphRun.EmSize,
                        glyphRun.GlyphIndices,
                        glyphRun.GlyphAdvances,
                        glyphRun.GlyphOffsets,
                        glyphRun.IsSideways,
                        glyphRun.BidiLevel != 0,
                        sink);
                    sink.Close();
                }

                CustomGeometrySink customSink = new CustomGeometrySink();
                pathGeometry.Stream(customSink);
                customSink.Close();
                System.Diagnostics.Debug.WriteLine(customSink.ToString());

                SolidColorBrush brush = null;
                if (clientDrawingEffect != null)
                {
                    ColorDrawingEffect drawingEffect = clientDrawingEffect as ColorDrawingEffect;
                    if (drawingEffect != null)
                    {
                        brush = _renderTarget.CreateSolidColorBrush(drawingEffect.Color);
                    }
                }

                Matrix3x2 matrix = new Matrix3x2(1, 0, 0, 1, baselineOriginX, baselineOriginY);
                using (TransformedGeometry transformedGeometry = _factory.CreateTransformedGeometry(pathGeometry, matrix))
                {
                    _renderTarget.FillGeometry(brush == null ? _defaultBrush : brush, transformedGeometry);
                }
                if (brush != null)
                {
                    brush.Dispose();
                }
            }
        }
        public Geometry CreateGeometry(Direct2DFactory factory)
        {
            PathGeometry geometry = factory.CreatePathGeometry();

            using (GeometrySink sink = geometry.Open())
            {
                sink.BeginFigure(_points[0], FigureBegin.Hollow);
                sink.AddLines(_points);
                sink.EndFigure(FigureEnd.Open);
                sink.Close();
            }
            Geometry[] list = new Geometry[_points.Length + 1];
            list[0] = geometry;

            for (int index = 0; index < _points.Length; ++index)
            {
                list[index + 1] = factory.CreateEllipseGeometry(new Ellipse(_points[index], 5, 5));
            }
            GeometryGroup group = factory.CreateGeometryGroup(FillMode.Winding, list);

            return(group);
        }
Beispiel #8
0
        public Geometry CreateGeometry(Direct2DFactory factory)
        {
            PathGeometry geometry = factory.CreatePathGeometry();

            using (GeometrySink sink = geometry.Open())
            {
                sink.BeginFigure(this._points[0], FigureBegin.Hollow);
                for (int index = 1; index < this._points.Length; ++index)
                {
                    sink.AddLine(this._points[index]);
                }
                sink.EndFigure(FigureEnd.Open);
                sink.Close();
            }
            return(geometry);
            //List<Geometry> list = new List<Geometry>();
            //for (int index = 0; index < this.Count; ++index)
            //{
            //    EllipseGeometry ellipse = factory.CreateEllipseGeometry(new Ellipse(this[index], 5, 5));
            //    list.Add(ellipse);
            //}
            //return factory.CreateGeometryGroup(FillMode.Winding, list.ToArray());
        }
Beispiel #9
0
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);
            this._leftMountainGeometry = factory.CreatePathGeometry();
            using (GeometrySink sink = this._leftMountainGeometry.Open())
            {
                sink.SetFillMode(FillMode.Winding);
                sink.BeginFigure(new PointF(346, 255), FigureBegin.Filled);
                sink.AddLines(
                    new PointF[] {
                    new PointF(267, 177),
                    new PointF(236, 192),
                    new PointF(212, 160),
                    new PointF(156, 255),
                    new PointF(346, 255)
                });
                sink.EndFigure(FigureEnd.Closed);
                sink.Close();
            }

            this._rightMountainGeometry = factory.CreatePathGeometry();
            using (GeometrySink sink = this._rightMountainGeometry.Open())
            {
                sink.SetFillMode(FillMode.Winding);
                sink.BeginFigure(new PointF(575, 263), FigureBegin.Filled);
                sink.AddLines(
                    new PointF[] {
                    new PointF(481, 146),
                    new PointF(449, 181),
                    new PointF(433, 159),
                    new PointF(401, 214),
                    new PointF(381, 199),
                    new PointF(323, 263),
                    new PointF(575, 263)
                });
                sink.EndFigure(FigureEnd.Closed);
                sink.Close();
            }

            this._sunGeometry = factory.CreatePathGeometry();
            using (GeometrySink sink = this._sunGeometry.Open())
            {
                sink.SetFillMode(FillMode.Winding);
                sink.BeginFigure(new PointF(270, 255), FigureBegin.Filled);
                sink.AddArc(
                    new ArcSegment(
                        new PointF(440, 255), // end point
                        new SizeF(85, 85),
                        0.0f,                 // rotation angle
                        SweepDirection.Clockwise,
                        ArcSize.Small));

                sink.EndFigure(FigureEnd.Closed);

                sink.BeginFigure(new PointF(299, 182), FigureBegin.Hollow);
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(299, 182),
                        new PointF(294, 176),
                        new PointF(285, 178)
                        ));
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(276, 179),
                        new PointF(272, 173),
                        new PointF(272, 173)
                        ));
                sink.EndFigure(FigureEnd.Open);

                sink.BeginFigure(
                    new PointF(354, 156),
                    FigureBegin.Hollow
                    );
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(354, 156),
                        new PointF(358, 149),
                        new PointF(354, 142)
                        ));
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(349, 134),
                        new PointF(354, 127),
                        new PointF(354, 127)
                        ));
                sink.EndFigure(FigureEnd.Open);

                sink.BeginFigure(
                    new PointF(322, 164),
                    FigureBegin.Hollow
                    );

                sink.AddBezier(
                    new BezierSegment(
                        new PointF(322, 164),
                        new PointF(322, 156),
                        new PointF(314, 152)
                        ));
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(306, 149),
                        new PointF(305, 141),
                        new PointF(305, 141)
                        ));
                sink.EndFigure(FigureEnd.Open);

                sink.BeginFigure(
                    new PointF(385, 164),
                    FigureBegin.Hollow
                    );
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(385, 164),
                        new PointF(392, 161),
                        new PointF(394, 152)
                        ));
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(395, 144),
                        new PointF(402, 141),
                        new PointF(402, 142)
                        ));
                sink.EndFigure(FigureEnd.Open);

                sink.BeginFigure(
                    new PointF(408, 182),
                    FigureBegin.Hollow
                    );
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(408, 182),
                        new PointF(416, 184),
                        new PointF(422, 178)
                        ));
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(428, 171),
                        new PointF(435, 173),
                        new PointF(435, 173)
                        ));
                sink.EndFigure(FigureEnd.Open);
                sink.Close();
            }
            this._riverGeometry = factory.CreatePathGeometry();
            using (GeometrySink sink = this._riverGeometry.Open())
            {
                sink.SetFillMode(FillMode.Winding);
                sink.BeginFigure(
                    new PointF(183, 392),
                    FigureBegin.Filled
                    );
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(238, 284),
                        new PointF(472, 345),
                        new PointF(356, 303)
                        ));
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(237, 261),
                        new PointF(333, 256),
                        new PointF(333, 256)
                        ));
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(335, 257),
                        new PointF(241, 261),
                        new PointF(411, 306)
                        ));
                sink.AddBezier(
                    new BezierSegment(
                        new PointF(574, 350),
                        new PointF(288, 324),
                        new PointF(296, 392)
                        ));
                sink.EndFigure(FigureEnd.Open);
                sink.Close();
            }
        }
Beispiel #10
0
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);
            this._leftMountainGeometry = factory.CreatePathGeometry();
            using (GeometrySink sink = this._leftMountainGeometry.Open())
            {
                sink.SetFillMode(FillMode.Winding);
                sink.BeginFigure(new PointF(346, 255), FigureBegin.Filled);
                sink.AddLines(
                    new PointF[] {
                        new PointF(267, 177),
                        new PointF(236, 192),
                        new PointF(212, 160),
                        new PointF(156, 255),
                        new PointF(346, 255)
                    });
                sink.EndFigure(FigureEnd.Closed);
                sink.Close();
            }

            this._rightMountainGeometry = factory.CreatePathGeometry();
            using (GeometrySink sink = this._rightMountainGeometry.Open())
            {
                sink.SetFillMode(FillMode.Winding);
                sink.BeginFigure(new PointF(575, 263), FigureBegin.Filled);
                sink.AddLines(
                    new PointF[] {
                        new PointF(481, 146),
                        new PointF(449, 181),
                        new PointF(433, 159),
                        new PointF(401, 214),
                        new PointF(381, 199),
                        new PointF(323, 263),
                        new PointF(575, 263)
                    });
                sink.EndFigure(FigureEnd.Closed);
                sink.Close();
            }

            this._sunGeometry = factory.CreatePathGeometry();
            using (GeometrySink sink = this._sunGeometry.Open())
            {
                sink.SetFillMode(FillMode.Winding);
                sink.BeginFigure(new PointF(270, 255), FigureBegin.Filled);
                sink.AddArc(
                    new ArcSegment(
                        new PointF(440, 255), // end point
                        new SizeF(85, 85),
                        0.0f, // rotation angle
                        SweepDirection.Clockwise,
                        ArcSize.Small));

                sink.EndFigure(FigureEnd.Closed);

                sink.BeginFigure(new PointF(299, 182), FigureBegin.Hollow);
                sink.AddBezier(
                    new BezierSegment(
                       new PointF(299, 182),
                       new PointF(294, 176),
                       new PointF(285, 178)
                       ));
                sink.AddBezier(
                   new BezierSegment(
                       new PointF(276, 179),
                       new PointF(272, 173),
                       new PointF(272, 173)
                       ));
                sink.EndFigure(FigureEnd.Open);

                sink.BeginFigure(
                    new PointF(354, 156),
                    FigureBegin.Hollow
                    );
                sink.AddBezier(
                   new BezierSegment(
                       new PointF(354, 156),
                       new PointF(358, 149),
                       new PointF(354, 142)
                       ));
                sink.AddBezier(
                   new BezierSegment(
                       new PointF(349, 134),
                       new PointF(354, 127),
                       new PointF(354, 127)
                       ));
                sink.EndFigure(FigureEnd.Open);

                sink.BeginFigure(
                    new PointF(322, 164),
                    FigureBegin.Hollow
                    );

                sink.AddBezier(
                   new BezierSegment(
                       new PointF(322, 164),
                       new PointF(322, 156),
                       new PointF(314, 152)
                       ));
                sink.AddBezier(
                   new BezierSegment(
                       new PointF(306, 149),
                       new PointF(305, 141),
                       new PointF(305, 141)
                       ));
                sink.EndFigure(FigureEnd.Open);

                sink.BeginFigure(
                    new PointF(385, 164),
                    FigureBegin.Hollow
                    );
                sink.AddBezier(
                   new BezierSegment(
                       new PointF(385, 164),
                       new PointF(392, 161),
                       new PointF(394, 152)
                       ));
                sink.AddBezier(
                   new BezierSegment(
                       new PointF(395, 144),
                       new PointF(402, 141),
                       new PointF(402, 142)
                       ));
                sink.EndFigure(FigureEnd.Open);

                sink.BeginFigure(
                    new PointF(408, 182),
                    FigureBegin.Hollow
                    );
                sink.AddBezier(
                   new BezierSegment(
                       new PointF(408, 182),
                       new PointF(416, 184),
                       new PointF(422, 178)
                       ));
                sink.AddBezier(
                   new BezierSegment(
                       new PointF(428, 171),
                       new PointF(435, 173),
                       new PointF(435, 173)
                       ));
                sink.EndFigure(FigureEnd.Open);
                sink.Close();
            }
            this._riverGeometry = factory.CreatePathGeometry();
            using (GeometrySink sink = this._riverGeometry.Open())
            {
                sink.SetFillMode(FillMode.Winding);
                sink.BeginFigure(
                    new PointF(183, 392),
                    FigureBegin.Filled
                    );
                sink.AddBezier(
                   new BezierSegment(
                       new PointF(238, 284),
                       new PointF(472, 345),
                       new PointF(356, 303)
                       ));
                sink.AddBezier(
                   new BezierSegment(
                       new PointF(237, 261),
                       new PointF(333, 256),
                       new PointF(333, 256)
                       ));
                sink.AddBezier(
                   new BezierSegment(
                       new PointF(335, 257),
                       new PointF(241, 261),
                       new PointF(411, 306)
                       ));
                sink.AddBezier(
                   new BezierSegment(
                       new PointF(574, 350),
                       new PointF(288, 324),
                       new PointF(296, 392)
                       ));
                sink.EndFigure(FigureEnd.Open);
                sink.Close();
            }
        }
Beispiel #11
0
        private void CreateGeometries(Direct2DFactory factory)
        {
            Ellipse circle1 = new Ellipse(75, 75, 50, 50);
            this._circleGeometry1 = factory.CreateEllipseGeometry(circle1);

            Ellipse circle2 = new Ellipse(125, 75, 50, 50);
            this._circleGeometry2 = factory.CreateEllipseGeometry(circle2);
            // Union
            this._geometryUnion = factory.CreatePathGeometry();
            using (GeometrySink sink = this._geometryUnion.Open())
            {
                this._circleGeometry1.CombineWithGeometry(this._circleGeometry2, CombineMode.Union, Matrix3x2.Identity, 0.25f, sink);
                sink.Close();
            }
            // Intersect
            this._geometryIntersect = factory.CreatePathGeometry();
            using (GeometrySink sink = this._geometryIntersect.Open())
            {
                this._circleGeometry1.CombineWithGeometry(this._circleGeometry2, CombineMode.Intersect, Matrix3x2.Identity, 0.25f, sink);
                sink.Close();
            }
            // Xor
            this._geometryXor = factory.CreatePathGeometry();
            using (GeometrySink sink = this._geometryXor.Open())
            {
                this._circleGeometry1.CombineWithGeometry(this._circleGeometry2, CombineMode.Xor, Matrix3x2.Identity, 0.25f, sink);
                sink.Close();
            }
            // Exclude
            this._geometryExclude = factory.CreatePathGeometry();
            using (GeometrySink sink = this._geometryExclude.Open())
            {
                this._circleGeometry1.CombineWithGeometry(this._circleGeometry2, CombineMode.Exclude, Matrix3x2.Identity, 0.25f, sink);
                sink.Close();
            }
        }