예제 #1
0
 private void AddShape(WpfStreamGeometryContext sgc, IGeometry geometry)
 {
     if (geometry is IPolygon)
     {
         AddShape(sgc, (IPolygon)geometry);
     }
     else if (geometry is ILineString)
     {
         AddShape(sgc, (ILineString)geometry);
     }
     //else if (geometry is IMultiLineString)
     //    AddShape(sgc, (IMultiLineString)geometry);
     else if (geometry is IPoint)
     {
         AddShape(sgc, (IPoint)geometry);
     }
     else if (geometry is IGeometryCollection)
     {
         AddShape(sgc, (IGeometryCollection)geometry);
     }
     else
     {
         throw new ArgumentException(
                   "Unrecognized Geometry class: " + geometry.GetType());
     }
 }
예제 #2
0
 private void AddShape(WpfStreamGeometryContext sgc, IGeometryCollection gc)
 {
     foreach (IGeometry geometry in gc.Geometries)
     {
         AddShape(sgc, geometry);
     }
 }
예제 #3
0
파일: VEdge.cs 프로젝트: KOpenMOS/Mos
 static void FillContexForPolyline(WStreamGeometryContext context, MPolyline poly)
 {
     for (PolylinePoint pp = poly.StartPoint.Next; pp != null; pp = pp.Next)
     {
         context.LineTo(Common.WpfPoint(pp.Point), true, false);
     }
 }
        public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
        {
            var start = new WpfPoint(point.X, point.Y - Size * 0.5);

            sgc.BeginFigure(start, true, true);
            sgc.ArcTo(start, new Size(Size, Size), 360, true, WpfSweepDirection.Clockwise, true, true);
        }
        public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
        {
            var x1 = point.X - Size / 2f;
            var x2 = point.X - Size / 4f;
            var x3 = point.X + Size / 4f;
            var x4 = point.X + Size / 2f;

            var y1 = point.Y - Size / 2f;
            var y2 = point.Y - Size / 4f;
            var y3 = point.Y + Size / 4f;
            var y4 = point.Y + Size / 2f;

            sgc.BeginFigure(new WpfPoint(x2, y1), true, true);
            sgc.PolyLineTo(new List <WpfPoint>(new[]
            {
                new WpfPoint(x3, y1),
                new WpfPoint(x3, y2),
                new WpfPoint(x4, y2),
                new WpfPoint(x4, y3),
                new WpfPoint(x3, y3),
                new WpfPoint(x3, y4),
                new WpfPoint(x2, y4),
                new WpfPoint(x2, y3),
                new WpfPoint(x1, y3),
                new WpfPoint(x1, y2),
                new WpfPoint(x2, y2),
                new WpfPoint(x2, y1)
            }), true, true);
        }
예제 #6
0
파일: VEdge.cs 프로젝트: KOpenMOS/Mos
 static void FillStreamGeometryContext(WStreamGeometryContext context, ICurve curve)
 {
     if (curve == null)
     {
         return;
     }
     FillContextForICurve(context, curve);
 }
예제 #7
0
        private void AddShape(WpfStreamGeometryContext sgc, ILinearRing linearRing, bool filled)
        {
            var coords = linearRing.Coordinates;

            WpfPoint[] wpfPoints;
            var        startPoint = TransformSequence(coords, out wpfPoints);

            sgc.BeginFigure(startPoint, filled, true);
            sgc.PolyLineTo(wpfPoints, true, true);
        }
예제 #8
0
파일: VEdge.cs 프로젝트: KOpenMOS/Mos
        WGeometry DefiningSourceArrowHead()
        {
            var streamGeometry = new WStreamGeometry();

            using (WStreamGeometryContext context = streamGeometry.Open())
            {
                AddArrow(context, Edge.GeometryEdge.Curve.Start, Edge.GeometryEdge.EdgeGeometry.SourceArrowhead.TipPosition, PathStrokeThickness);
                return(streamGeometry);
            }
        }
예제 #9
0
파일: VEdge.cs 프로젝트: KOpenMOS/Mos
        internal static WGeometry GetICurveWpfGeometry(ICurve curve)
        {
            var streamGeometry = new WStreamGeometry();

            using (WStreamGeometryContext context = streamGeometry.Open())
            {
                FillStreamGeometryContext(context, curve);
                return(streamGeometry);
            }
        }
예제 #10
0
        public void StreamGeometryTriangleExample(List <System.Windows.Point> arrPoints)
        {
            // Create a path to draw a geometry with.
            System.Windows.Shapes.Path myPath = new System.Windows.Shapes.Path();
            myPath.Stroke          = System.Windows.Media.Brushes.Black;
            myPath.StrokeThickness = 1;
            System.Windows.Media.Color cl = new System.Windows.Media.Color();
            byte[] arr = new byte[4];
            rand.NextBytes(arr);
            //cl.A =
            System.Windows.Media.Brush br = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(arr[0], arr[1], arr[2], arr[3]));
            #region для заполнение разкоментировать
            //  myPath.Fill = br;
            #endregion

            // Create a StreamGeometry to use to specify myPath.
            System.Windows.Media.StreamGeometry geometry = new System.Windows.Media.StreamGeometry();
            //   geometry.FillRule = System.Windows.Media.FillRule.EvenOdd;

            // Open a StreamGeometryContext that can be used to describe this StreamGeometry
            // object's contents.

            using (System.Windows.Media.StreamGeometryContext ctx = geometry.Open())
            {
                // Begin the triangle at the point specified. Notice that the shape is set to
                // be closed so only two lines need to be specified below to make the triangle.
                //ctx.BeginFigure(arrPoints[0], true /* is filled */, true /* is closed */);
                ctx.BeginFigure(arrPoints[0], true /* is filled */, false /* is closed */);
                for (int i = 1; i < arrPoints.Count; i++)
                {
                    ctx.LineTo(arrPoints[i], true /* is stroked */, false /* is smooth join */);
                }
                // Draw a line to the next specified point.
                //   ctx.LineTo(new System.Windows.Point(100, 100), true /* is stroked */, false /* is smooth join */);

                // Draw another line to the next specified point.
                //  ctx.LineTo(new System.Windows.Point(100, 50), true /* is stroked */, false /* is smooth join */);
            }

            // Freeze the geometry (make it unmodifiable)
            // for additional performance benefits.
            geometry.Freeze();

            // Specify the shape (triangle) of the Path using the StreamGeometry.
            myPath.Data = geometry;

            // Add path shape to the UI.
            StackPanel mainPanel = new StackPanel();
            Canvas     ss        = cv;
            ss.Children.Clear();
            ss.Children.Add(myPath);
        }
예제 #11
0
        private void AddShape(WpfStreamGeometryContext sgc, IPolygon p)
        {
            AddShape(sgc, p.Shell, true);
            var holes = p.Holes;

            if (holes != null)
            {
                foreach (ILinearRing hole in holes)
                {
                    AddShape(sgc, hole, true);
                }
            }
        }
        public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
        {
            var start   = new WpfPoint(point.X, (point.Y - Size / 2));
            var linesTo = new List <WpfPoint>(
                new[]
            {
                new WpfPoint((point.X + Size / 2), (point.Y + Size / 2)),
                new WpfPoint((point.X - Size / 2), (point.Y + Size / 2)),
                new WpfPoint((point.X), (point.Y - Size / 2))
            });

            sgc.BeginFigure(start, true, true);
            sgc.PolyLineTo(linesTo, true, true);
        }
        public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
        {
            var start      = new WpfPoint(point.X - 0.5 * Size, point.Y - 0.5 * Size);
            var polylineTo = new List <WpfPoint>(new[]
            {
                new WpfPoint(point.X + 0.5 * Size, point.Y - 0.5 * Size),
                new WpfPoint(point.X + 0.5 * Size, point.Y + 0.5 * Size),
                new WpfPoint(point.X - 0.5 * Size, point.Y + 0.5 * Size),
                start
            });

            sgc.BeginFigure(start, true, true);
            sgc.PolyLineTo(polylineTo, true, true);
        }
예제 #14
0
파일: VEdge.cs 프로젝트: KOpenMOS/Mos
        internal static WGeometry DefiningTargetArrowHead(EdgeGeometry edgeGeometry, double thickness)
        {
            if (edgeGeometry.TargetArrowhead == null || edgeGeometry.Curve == null)
            {
                return(null);
            }
            var streamGeometry = new WStreamGeometry();

            using (WStreamGeometryContext context = streamGeometry.Open())
            {
                AddArrow(context, edgeGeometry.Curve.End,
                         edgeGeometry.TargetArrowhead.TipPosition, thickness);
                return(streamGeometry);
            }
        }
 public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
 {
     sgc.BeginFigure(new WpfPoint((point.X), (point.Y - Size * 1 / 8)), true, true);
     sgc.PolyLineTo(new List <WpfPoint>(new[]
     {
         new WpfPoint((point.X + Size * 2 / 8), (point.Y - Size / 2)),
         new WpfPoint((point.X + Size / 2), (point.Y - Size / 2)),
         new WpfPoint((point.X + Size * 1 / 8), (point.Y)),
         new WpfPoint((point.X + Size / 2), (point.Y + Size / 2)),
         new WpfPoint((point.X + Size * 2 / 8), (point.Y + Size / 2)),
         new WpfPoint((point.X), (point.Y + Size * 1 / 8)),
         new WpfPoint((point.X - Size * 2 / 8), (point.Y + Size / 2)),
         new WpfPoint((point.X - Size / 2), (point.Y + Size / 2)),
         new WpfPoint((point.X - Size * 1 / 8), (point.Y)),
         new WpfPoint((point.X - Size / 2), (point.Y - Size / 2)),
         new WpfPoint((point.X - Size * 2 / 8), (point.Y - Size / 2))
     }), true, true);
 }
예제 #16
0
파일: VEdge.cs 프로젝트: KOpenMOS/Mos
        static void AddArrow(WStreamGeometryContext context, MPoint start, MPoint end, double thickness)
        {
            if (thickness > 1)
            {
                MPoint dir = end - start;
                MPoint h   = dir;
                double dl  = dir.Length;
                if (dl < 0.001)
                {
                    return;
                }
                dir /= dl;

                var    s  = new MPoint(-dir.Y, dir.X);
                double w  = 0.5 * thickness;
                MPoint s0 = w * s;

                s *= h.Length * HalfArrowAngleTan;
                s += s0;

                double rad = w / HalfArrowAngleCos;

                context.BeginFigure(Common.WpfPoint(start + s), true, true);
                context.LineTo(Common.WpfPoint(start - s), true, false);
                context.LineTo(Common.WpfPoint(end - s0), true, false);
                context.ArcTo(Common.WpfPoint(end + s0), new WSize(rad, rad),
                              Math.PI - ArrowAngle, false, WSweepDirection.Clockwise, true, false);
            }
            else
            {
                MPoint dir = end - start;
                double dl  = dir.Length;
                //take into account the widths
                double delta = Math.Min(dl / 2, thickness + thickness / 2);
                dir *= (dl - delta) / dl;
                end  = start + dir;
                dir  = dir.Rotate(Math.PI / 2);
                MPoint s = dir * HalfArrowAngleTan;

                context.BeginFigure(Common.WpfPoint(start + s), true, true);
                context.LineTo(Common.WpfPoint(end), true, true);
                context.LineTo(Common.WpfPoint(start - s), true, true);
            }
        }
예제 #17
0
파일: VEdge.cs 프로젝트: KOpenMOS/Mos
        WFrameworkElement CreateFrameworkElementForRailArrowhead(Rail rail, Arrowhead arrowhead, MPoint curveAttachmentPoint, byte edgeTransparency)
        {
            var streamGeometry = new WStreamGeometry();

            using (WStreamGeometryContext context = streamGeometry.Open())
            {
                AddArrow(context, curveAttachmentPoint, arrowhead.TipPosition,
                         PathStrokeThickness);
            }

            var path = new WPath
            {
                Data = streamGeometry,
                Tag  = this
            };

            SetPathStrokeToRailPath(rail, path, edgeTransparency);
            return(path);
        }
예제 #18
0
파일: VEdge.cs 프로젝트: KOpenMOS/Mos
 static void FillContexForCurve(WStreamGeometryContext context, Curve c)
 {
     foreach (ICurve seg in c.Segments)
     {
         var bezSeg = seg as CubicBezierSegment;
         if (bezSeg != null)
         {
             context.BezierTo(Common.WpfPoint(bezSeg.B(1)),
                              Common.WpfPoint(bezSeg.B(2)), Common.WpfPoint(bezSeg.B(3)), true, false);
         }
         else
         {
             var ls = seg as MLineSegment;
             if (ls != null)
             {
                 context.LineTo(Common.WpfPoint(ls.End), true, false);
             }
             else
             {
                 var ellipse = seg as MEllipse;
                 if (ellipse != null)
                 {
                     double     sweepAngle = EllipseSweepAngle(ellipse);
                     bool       largeArc   = Math.Abs(sweepAngle) >= Math.PI;
                     MRectangle box        = ellipse.FullBox();
                     context.ArcTo(Common.WpfPoint(ellipse.End),
                                   new WSize(box.Width / 2, box.Height / 2),
                                   sweepAngle,
                                   largeArc,
                                   sweepAngle < 0
                                       ? WSweepDirection.Counterclockwise
                                       : WSweepDirection.Clockwise,
                                   true, true);
                 }
                 else
                 {
                     throw new NotImplementedException();
                 }
             }
         }
     }
 }
예제 #19
0
        public System.Windows.Media.Geometry GetCaptureShape()
        {
            System.Windows.Media.StreamGeometry        geo = new System.Windows.Media.StreamGeometry();
            System.Windows.Media.StreamGeometryContext ctx = geo.Open();
            System.Collections.ObjectModel.ReadOnlyCollection <System.Drawing.Point> points = _shape.Points;

            List <System.Windows.Point> mPoints = new List <System.Windows.Point>();

            foreach (Point p in points)
            {
                mPoints.Add(new System.Windows.Point(p.X, p.Y));
            }

            if (mPoints.Count > 0)
            {
                //mPoints.Add(mPoints[0]);
                ctx.BeginFigure(mPoints[0], false, false);
                ctx.PolyLineTo(mPoints, true, false);
            }
            ctx.Close();
            return(geo);
        }
 private void AddShape(WpfStreamGeometryContext sgc, IGeometryCollection gc)
 {
     foreach (IGeometry geometry in gc.Geometries)
     {
         AddShape(sgc, geometry);
     }
 }
 private void AddShape(WpfStreamGeometryContext sgc, IGeometry geometry)
 {
     if (geometry is IPolygon)
         AddShape(sgc, (IPolygon)geometry);
     else if (geometry is ILineString)
         AddShape(sgc, (ILineString)geometry);
     //else if (geometry is IMultiLineString)
     //    AddShape(sgc, (IMultiLineString)geometry);
     else if (geometry is IPoint)
         AddShape(sgc, (IPoint) geometry);
     else if (geometry is IGeometryCollection)
         AddShape(sgc, (IGeometryCollection)geometry);
     else
     {
         throw new ArgumentException(
             "Unrecognized Geometry class: " + geometry.GetType());
     }
 }
 private void AddShape(WpfStreamGeometryContext sgc, IPolygon p)
 {
     AddShape(sgc, p.Shell, true);
     var holes = p.Holes;
     if (holes != null)
     {
         foreach (ILinearRing hole in holes)
             AddShape(sgc, hole, true);
     }
 }
 public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
 {
     var start = new WpfPoint(point.X, (point.Y - Size / 2));
     var linesTo = new List<WpfPoint>(
         new[]
             {
                 new WpfPoint((point.X + Size/2), (point.Y + Size/2)),
                 new WpfPoint((point.X - Size/2), (point.Y + Size/2)),
                 new WpfPoint((point.X), (point.Y - Size/2))
             });
     sgc.BeginFigure(start, true, true);
     sgc.PolyLineTo(linesTo, true, true);
 }
예제 #24
0
파일: VEdge.cs 프로젝트: KOpenMOS/Mos
        internal static void FillContextForICurve(WStreamGeometryContext context, ICurve iCurve)
        {
            context.BeginFigure(Common.WpfPoint(iCurve.Start), false, false);

            var c = iCurve as Curve;

            if (c != null)
            {
                FillContexForCurve(context, c);
            }
            else
            {
                var cubicBezierSeg = iCurve as CubicBezierSegment;
                if (cubicBezierSeg != null)
                {
                    context.BezierTo(Common.WpfPoint(cubicBezierSeg.B(1)), Common.WpfPoint(cubicBezierSeg.B(2)),
                                     Common.WpfPoint(cubicBezierSeg.B(3)), true, false);
                }
                else
                {
                    var ls = iCurve as MLineSegment;
                    if (ls != null)
                    {
                        context.LineTo(Common.WpfPoint(ls.End), true, false);
                    }
                    else
                    {
                        var rr = iCurve as RoundedRect;
                        if (rr != null)
                        {
                            FillContexForCurve(context, rr.Curve);
                        }
                        else
                        {
                            var poly = iCurve as MPolyline;
                            if (poly != null)
                            {
                                FillContexForPolyline(context, poly);
                            }
                            else
                            {
                                var ellipse = iCurve as MEllipse;
                                if (ellipse != null)
                                {
                                    double     sweepAngle = EllipseSweepAngle(ellipse);
                                    bool       largeArc   = Math.Abs(sweepAngle) >= Math.PI;
                                    MRectangle box        = ellipse.FullBox();
                                    context.ArcTo(Common.WpfPoint(ellipse.End),
                                                  new WSize(box.Width / 2, box.Height / 2),
                                                  sweepAngle,
                                                  largeArc,
                                                  sweepAngle < 0
                                                      ? WSweepDirection.Counterclockwise
                                                      : WSweepDirection.Clockwise,
                                                  true, true);
                                }
                                else
                                {
                                    throw new NotImplementedException();
                                }
                            }
                        }
                    }
                }
            }
        }
 public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
 {
     var start = new WpfPoint(point.X, point.Y - Size * 0.5);
     sgc.BeginFigure(start, true, true);
     sgc.ArcTo(start, new Size(Size, Size), 360, true, WpfSweepDirection.Clockwise, true, true);
 }
        public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
        {
            var x1 = point.X - Size / 2f;
            var x2 = point.X - Size / 4f;
            var x3 = point.X + Size / 4f;
            var x4 = point.X + Size / 2f;

            var y1 = point.Y - Size / 2f;
            var y2 = point.Y - Size / 4f;
            var y3 = point.Y + Size / 4f;
            var y4 = point.Y + Size / 2f;

            sgc.BeginFigure(new WpfPoint(x2, y1), true, true);
            sgc.PolyLineTo(new List<WpfPoint>(new[]
                {
                    new WpfPoint(x3, y1),
                    new WpfPoint(x3, y2),
                    new WpfPoint(x4, y2),
                    new WpfPoint(x4, y3),
                    new WpfPoint(x3, y3),
                    new WpfPoint(x3, y4),
                    new WpfPoint(x2, y4),
                    new WpfPoint(x2, y3),
                    new WpfPoint(x1, y3),
                    new WpfPoint(x1, y2),
                    new WpfPoint(x2, y2),
                    new WpfPoint(x2, y1)
                }), true, true);
        }
 public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
 {
     sgc.BeginFigure(new WpfPoint((point.X), (point.Y - Size * 1 / 8)), true, true);
     sgc.PolyLineTo(new List<WpfPoint>(new[]
         {
             new WpfPoint((point.X + Size*2/8), (point.Y - Size/2)),
             new WpfPoint((point.X + Size/2), (point.Y - Size/2)),
             new WpfPoint((point.X + Size*1/8), (point.Y)),
             new WpfPoint((point.X + Size/2), (point.Y + Size/2)),
             new WpfPoint((point.X + Size*2/8), (point.Y + Size/2)),
             new WpfPoint((point.X), (point.Y + Size*1/8)),
             new WpfPoint((point.X - Size*2/8), (point.Y + Size/2)),
             new WpfPoint((point.X - Size/2), (point.Y + Size/2)),
             new WpfPoint((point.X - Size*1/8), (point.Y)),
             new WpfPoint((point.X - Size/2), (point.Y - Size/2)),
             new WpfPoint((point.X - Size*2/8), (point.Y - Size/2))
         }), true, true);
 }
예제 #28
0
        private void AddShape(WpfStreamGeometryContext sgc, IPoint point)
        {
            var viewPoint = TransformPoint(point.Coordinate);

            _pointFactory.AddShape(viewPoint, sgc);
        }
 public abstract void AddShape(WpfPoint point, WpfStreamGeometryContext sgc);
 public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
 {
     var start = new WpfPoint(point.X - 0.5 * Size, point.Y - 0.5 * Size);
     var polylineTo = new List<WpfPoint>(new[]
                          {
                              new WpfPoint(point.X + 0.5*Size, point.Y - 0.5*Size),
                              new WpfPoint(point.X + 0.5*Size, point.Y + 0.5*Size),
                              new WpfPoint(point.X - 0.5*Size, point.Y + 0.5*Size),
                              start
                          });
     sgc.BeginFigure(start, true, true);
     sgc.PolyLineTo(polylineTo, true, true);
 }
        private void AddShape(WpfStreamGeometryContext sgc, ILinearRing linearRing, bool filled)
        {
            var coords = linearRing.Coordinates;

            WpfPoint[] wpfPoints;
            var startPoint = TransformSequence(coords, out wpfPoints);

            sgc.BeginFigure(startPoint, filled, true);
            sgc.PolyLineTo(wpfPoints, true, true);
        }
 private void AddShape(WpfStreamGeometryContext sgc, IPoint point)
 {
     var viewPoint = TransformPoint(point.Coordinate);
     _pointFactory.AddShape(viewPoint, sgc);
 }
 public abstract void AddShape(WpfPoint point, WpfStreamGeometryContext sgc);