public override void HandleUp(object arg)
        {
            if (!(arg is Point))
            {
                return;
            }

            var coordinate = (Point)arg;

            // only a point/dot is drawn, no movement of finger on screen
            if (_lastPoint.Equals(coordinate))
            {
                var qbs = new QuadraticBezierSegment
                {
                    Point1 = _lastPoint,
                    Point2 = coordinate
                };

                _pathSegmentCollection.Add(qbs);

                PocketPaintApplication.GetInstance().PaintingAreaLayoutRoot.InvalidateMeasure();
                _path.InvalidateArrange();
            }
            CommandManager.GetInstance().CommitCommand(new BrushCommand(_path));
        }
        public static Path createPath(Point startPoint, QuadraticBezierSegment segment)
        {
            PathSegmentCollection pscollection = new PathSegmentCollection();

            pscollection.Add(segment);

            PathFigure pf = new PathFigure();

            pf.Segments   = pscollection;
            pf.StartPoint = startPoint;

            PathFigureCollection pfcollection = new PathFigureCollection();

            pfcollection.Add(pf);

            PathGeometry pathGeometry = new PathGeometry();

            pathGeometry.Figures = pfcollection;

            Path path = new Path();

            path.Data            = pathGeometry;
            path.Stroke          = System.Windows.Media.Brushes.Black;
            path.StrokeThickness = 2;

            return(path);
        }
        public override void HandleUp(object arg)
        {
            if (PocketPaintApplication.GetInstance().cursorControl.isDrawingActivated())
            {
                if (!(arg is Point))
                {
                    return;
                }
                setHeightWidth();

                var coordinate = new Point(width + _transforms.Value.OffsetX, height + _transforms.Value.OffsetY);

                // only a point/dot is drawn, no movement of finger on screen
                if (_lastPoint.Equals(coordinate))
                {
                    var qbs = new QuadraticBezierSegment
                    {
                        Point1 = _lastPoint,
                        Point2 = coordinate
                    };

                    _pathSegmentCollection.Add(qbs);

                    PocketPaintApplication.GetInstance().PaintingAreaLayoutRoot.InvalidateMeasure();
                    _path.InvalidateArrange();
                }
                CommandManager.GetInstance().CommitCommand(new CursorCommand(_path));
            }
        }
예제 #4
0
파일: WpfUtils.cs 프로젝트: t00/PdfSharpXps
        /// <summary>
        /// Converts a PolyQuadraticBezierSegment into a PolyLineSegment because I currently have no muse to calculate
        /// the correct Bézier curves.
        /// </summary>
        public static PolyLineSegment FlattenSegment(
            Point startPoint,
            PolyQuadraticBezierSegment seg)
        {
            var geo = new PathGeometry();
            var fig = new PathFigure();

            geo.Figures.Add(fig);
            fig.StartPoint = new Point(startPoint.X, startPoint.Y);
            int count  = seg.Points.Count;
            var points = new Point[count];

            for (int idx = 0; idx < count - 1; idx += 2)
            {
                var qbseg = new QuadraticBezierSegment(
                    new Point(seg.Points[idx].X, seg.Points[idx].Y),
                    new Point(seg.Points[idx + 1].X, seg.Points[idx + 1].Y), seg.IsStroked);
                fig.Segments.Add(qbseg);
            }
            geo = geo.GetFlattenedPathGeometry();
            fig = geo.Figures[0];
            var lineSeg   = (PolyLineSegment)fig.Segments[0];
            var resultSeg = new PolyLineSegment();

            foreach (var point in lineSeg.Points)
            {
                resultSeg.Points.Add(new Point(point.X, point.Y));
            }
            return(resultSeg);
        }
        public override void HandleMove(object arg)
        {
            if (!(arg is Point))
            {
                return;
            }

            var coordinate = (Point)arg;

            System.Diagnostics.Debug.WriteLine("BrushTool Coord: " + coordinate.X + " " + coordinate.Y);

            if (!_lastPointSet)
            {
                _lastPoint    = coordinate;
                _lastPointSet = true;
                return;
            }
            if (_lastPointSet && !_lastPoint.Equals(coordinate))
            {
                var qbs = new QuadraticBezierSegment
                {
                    Point1 = _lastPoint,
                    Point2 = coordinate
                };

                _pathSegmentCollection.Add(qbs);


                PocketPaintApplication.GetInstance().PaintingAreaLayoutRoot.InvalidateMeasure();
                _lastPointSet = false;
            }
        }
예제 #6
0
        public void MoveMouse(object sender, MouseEventArgs e)
        {
            Point point = paintTool.GetCurrentPoint();

            // 캔버스 벗어나는 것을 막는다
            if (point.X >= paintCanvas.ActualWidth || point.Y >= paintCanvas.ActualHeight || point.X < 0 || point.Y < 0)
            {
                return;
            }

            /* 원래의 타입으로 변환*/

            // 선 그리기
            if (DrawingObject.GetType().ToString().Equals("System.Windows.Shapes.Line"))
            {
                Line line = (Line)DrawingObject;
                line.X2 = point.X;
                line.Y2 = point.Y;
            }

            // 브러쉬로 그리기
            else if (DrawingObject.GetType().ToString().Equals("System.Windows.Shapes.Path"))
            {
                Path                   brush        = (Path)DrawingObject;
                PathGeometry           geometry     = (PathGeometry)brush.Data;
                PathFigureCollection   figures      = geometry.Figures;
                PathFigure             figure       = figures[0];
                PathSegmentCollection  pathSegments = figure.Segments;
                QuadraticBezierSegment quadratic    = new QuadraticBezierSegment();
                quadratic.Point1 = priorPoint;
                quadratic.Point2 = point;
                pathSegments.Add(quadratic);
            }

            // 정사각형, 원 그리기
            else
            {
                Shape shape = (Shape)DrawingObject;

                double width  = point.X - startPoint.X;
                double height = point.Y - startPoint.Y;

                if (width < 0)
                {
                    width = Math.Abs(width);
                    Canvas.SetLeft(shape, point.X);
                }
                if (height < 0)
                {
                    height = Math.Abs(height);
                    Canvas.SetTop(shape, point.Y);
                }

                shape.Width  = width;
                shape.Height = height;
            }
            priorPoint = point;

            this.Title = "그림판  X : " + priorPoint.X.ToString() + " Y : " + priorPoint.Y.ToString();
        }
예제 #7
0
        public static Path GetPath(Point from, Point middle, Point to, Brush brush, string name = "", bool orient = false)      // false - не направ
        {
            QuadraticBezierSegment bezierSegment = new QuadraticBezierSegment(middle, to, true);

            PathFigure pathFigure = new PathFigure();

            pathFigure.StartPoint = from;
            pathFigure.Segments.Add(bezierSegment);

            PathGeometry pathGeometry = new PathGeometry();

            pathGeometry.Figures.Add(pathFigure);

            Path path = new Path();

            path.Tag             = name;
            path.Data            = pathGeometry;
            path.Stroke          = brush;
            path.StrokeThickness = 1.3;

            if (orient)
            {
                path.StrokeEndLineCap = PenLineCap.Round;
            }

            return(path);
        }
예제 #8
0
        private void TestPathQuadratic_Click(object sender, RoutedEventArgs e)
        {
            PathGeometry pathGeometry = new PathGeometry();

            pathGeometry.Figures = new PathFigureCollection();
            PathFigure figure = new PathFigure()
            {
                IsClosed = false, IsFilled = false, StartPoint = new Point(10, 10)
            };

            figure.Segments = new PathSegmentCollection();

            quadratic = new QuadraticBezierSegment()
            {
                Point1 = new Point(0, 0), Point2 = new Point(200, 200)
            };
            figure.Segments.Add(quadratic);

            pathGeometry.Figures.Add(figure);
            path1.Data = pathGeometry;

            PathArcButtons.Visibility           = Visibility.Collapsed;
            PathBezierButtons.Visibility        = Visibility.Collapsed;
            PathLineButtons.Visibility          = Visibility.Collapsed;
            PathPolyBezierButtons.Visibility    = Visibility.Collapsed;
            PathPolyLineButtons.Visibility      = Visibility.Collapsed;
            PathPolyQuadraticButtons.Visibility = Visibility.Collapsed;
            PathQuadraticButtons.Visibility     = Visibility.Visible;
        }
예제 #9
0
        private void drawLine(Point p1, Point p2)
        {
            List <Point> controlPoints = BezierHelper.getControlPoints(0.4, p1, p2);

            if (isHaveLastControlPoint == false)
            {
                lastControlPoint       = p1;
                isHaveLastControlPoint = true;
            }

            QuadraticBezierSegment bezierSegment = new QuadraticBezierSegment(p1, controlPoints[0], true);

            lastControlPoint = controlPoints[1];
            pathFigure.Segments.Add(bezierSegment);
            LineSegment lineSegment = new LineSegment(controlPoints[1], true);

            pathFigure.Segments.Add(lineSegment);
            //if (isHaveLastControlPoint == false)
            //{
            //    lastControlPoint = p1;
            //    isHaveLastControlPoint = true;
            //}
            //LineSegment lineSegment=new LineSegment(p2,true);

            //pathFigure.Segments.Add(lineSegment);
            //            Graphics.FromHwnd(this)
            lastControlPoint = controlPoints[1];
        }
        public void SetMouth()
        {
            int index = _laugh ? 0 : 1;

            var figure = new PathFigure()
            {
                StartPoint = _mouthPoints[index, 0]
            };

            figure.Segments = new PathSegmentCollection();
            var segment1 = new QuadraticBezierSegment
            {
                Point1 = _mouthPoints[index, 1],
                Point2 = _mouthPoints[index, 2]
            };

            figure.Segments.Add(segment1);
            var geometry = new PathGeometry();

            geometry.Figures = new PathFigureCollection();
            geometry.Figures.Add(figure);

            mouth.Data = geometry;
            _laugh     = !_laugh;
        }
예제 #11
0
        //! ベジェ曲線のジオメトリを作成する
        public static Geometry MakeBezierPathGeometry(BezierConnectionInfo bezierInfo)
        {
            PathFigure MakePath(Point start, Point center, Point end)
            {
                var figure = new PathFigure()
                {
                    StartPoint = start,
                    IsClosed   = false,
                };
                var segment = new QuadraticBezierSegment
                {
                    Point1 = center,
                    Point2 = end
                };

                figure.Segments.Add(segment);
                return(figure);
            }

            var geometry = new PathGeometry();

            {
                geometry.Figures.Add(MakePath(bezierInfo.Start, bezierInfo.StartToCenter, bezierInfo.Center));
                geometry.Figures.Add(MakePath(bezierInfo.Center, bezierInfo.CenterToEnd, bezierInfo.End));
            }

            return(geometry);
        }
예제 #12
0
 public void AddQuadraticBeziers(QuadraticBezierSegment[] beziers)
 {
     for (int index = 0; index < beziers.Length; ++index)
     {
         AddQuadraticBezier(beziers[index]);
     }
 }
예제 #13
0
        private Path SimpleQuadraticBezierLine()
        {
            // <Snippet34>
            PathFigure myPathFigure = new PathFigure();

            myPathFigure.StartPoint = new Point(10, 100);

            QuadraticBezierSegment myQuadraticBezierSegment = new QuadraticBezierSegment();

            myQuadraticBezierSegment.Point1 = new Point(200, 200);
            myQuadraticBezierSegment.Point2 = new Point(300, 100);

            PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();

            myPathSegmentCollection.Add(myQuadraticBezierSegment);

            myPathFigure.Segments = myPathSegmentCollection;

            PathFigureCollection myPathFigureCollection = new PathFigureCollection();

            myPathFigureCollection.Add(myPathFigure);

            PathGeometry myPathGeometry = new PathGeometry();

            myPathGeometry.Figures = myPathFigureCollection;

            Path myPath = new Path();

            myPath.Stroke          = Brushes.Black;
            myPath.StrokeThickness = 1;
            myPath.Data            = myPathGeometry;
            // </Snippet34>
            return(myPath);
        }
예제 #14
0
 public static Point SplitByNextIntersection(Point startPoint, QuadraticBezierSegment segment, out SegmentBase segment1, out SegmentBase segment2)
 {
     return(SplitByNextIntersection(startPoint, segment, out segment1, out segment2,
                                    new QuadraticBezierEquation(startPoint, segment),
                                    (t, p) => new QuadraticBezierSegment(Mid(startPoint, segment.ControlPoint, t), p),
                                    t => new QuadraticBezierSegment(Mid(segment.ControlPoint, segment.EndPoint, t), segment.EndPoint)));
 }
예제 #15
0
        public WpfQuadraticBezier(IQuadraticBezier qb)
        {
            _xqb = qb;

            _fillBrush = new SolidColorBrush(_xqb.Fill.ToNativeColor());
            _fillBrush.Freeze();
            _strokeBrush = new SolidColorBrush(_xqb.Stroke.ToNativeColor());
            _strokeBrush.Freeze();

            _path                 = new Path();
            _path.Tag             = this;
            _path.Fill            = _fillBrush;
            _path.Stroke          = _strokeBrush;
            _path.StrokeThickness = qb.StrokeThickness;
            _pg            = new PathGeometry();
            _pf            = new PathFigure();
            _pf.StartPoint = new Point(qb.Start.X, qb.Start.Y);
            _pf.IsFilled   = qb.IsFilled;
            _pf.IsClosed   = qb.IsClosed;
            _qbs           = new QuadraticBezierSegment();
            _qbs.Point1    = new Point(qb.Point1.X, qb.Point1.Y);
            _qbs.Point2    = new Point(qb.Point2.X, qb.Point2.Y);
            _pf.Segments.Add(_qbs);
            _pg.Figures.Add(_pf);
            _path.Data = _pg;

            Native = _path;
        }
예제 #16
0
        /// <summary>
        /// Adds the segments necessary to close the shape
        /// </summary>
        /// <param name="pathFigure"></param>
        private void CloseFigure(PathFigure pathFigure)
        {
            //No need to visually close the figure if we don't have at least 3 points.
            if (Points.Count < 3)
            {
                return;
            }
            Point backPoint, nextPoint;

            if (UseRoundnessPercentage)
            {
                backPoint = GetPointAtDistancePercent(Points[Points.Count - 1], Points[0], ArcRoundness, false);
                nextPoint = GetPointAtDistancePercent(Points[0], Points[1], ArcRoundness, true);
            }
            else
            {
                backPoint = GetPointAtDistance(Points[Points.Count - 1], Points[0], ArcRoundness, false);
                nextPoint = GetPointAtDistance(Points[0], Points[1], ArcRoundness, true);
            }
            ConnectLinePoints(pathFigure, Points[Points.Count - 2], Points[Points.Count - 1], backPoint, ArcRoundness, UseRoundnessPercentage);
            var line2 = new QuadraticBezierSegment {
                Point1 = Points[0], Point2 = nextPoint
            };

            pathFigure.Segments.Add(line2);
            pathFigure.StartPoint = nextPoint;
        }
예제 #17
0
        /// <summary>
        /// Method used to connect 2 segments with a common point, defined by 3 points and aplying an arc segment between them
        /// </summary>
        /// <param name="pathFigure"></param>
        /// <param name="p1">First point, of the first segment</param>
        /// <param name="p2">Second point, the common point</param>
        /// <param name="p3">Third point, the second point of the second segment</param>
        /// <param name="roundness">The roundness of the arc</param>
        /// <param name="usePercentage">A value that indicates if the roundness of the arc will be used as a percentage or not</param>
        private static void ConnectLinePoints(PathFigure pathFigure, Point p1, Point p2, Point p3, double roundness, bool usePercentage)
        {
            //The point on the first segment where the curve will start.
            Point backPoint;
            //The point on the second segment where the curve will end.
            Point nextPoint;

            if (usePercentage)
            {
                backPoint = GetPointAtDistancePercent(p1, p2, roundness, false);
                nextPoint = GetPointAtDistancePercent(p2, p3, roundness, true);
            }
            else
            {
                backPoint = GetPointAtDistance(p1, p2, roundness, false);
                nextPoint = GetPointAtDistance(p2, p3, roundness, true);
            }

            int lastSegmentIndex = pathFigure.Segments.Count - 1;

            //Set the ending point of the first segment.
            ((LineSegment)(pathFigure.Segments[lastSegmentIndex])).Point = backPoint;
            //Create and add the curve.
            var curve = new QuadraticBezierSegment {
                Point1 = p2, Point2 = nextPoint
            };

            pathFigure.Segments.Add(curve);
            //Create and add the new segment.
            var line = new LineSegment {
                Point = p3
            };

            pathFigure.Segments.Add(line);
        }
예제 #18
0
        /// <summary>
        /// Converts a PolyQuadraticBezierSegment into a PolyLineSegment because I currently have no muse to calculate
        /// the correct Bézier curves.
        /// </summary>
        public static PdfSharp.Xps.XpsModel.PolyLineSegment FlattenSegment(PdfSharp.Xps.XpsModel.Point startPoint,
                                                                           PdfSharp.Xps.XpsModel.PolyQuadraticBezierSegment seg)
        {
            PathGeometry geo = new PathGeometry();
            PathFigure   fig = new PathFigure();

            geo.Figures.Add(fig);
            fig.StartPoint = new Point(startPoint.X, startPoint.Y);
            int count = seg.Points.Count;

            Point[] points = new Point[count];
            for (int idx = 0; idx < count - 1; idx += 2)
            {
                QuadraticBezierSegment qbseg = new QuadraticBezierSegment(
                    new Point(seg.Points[idx].X, seg.Points[idx].Y), new Point(seg.Points[idx + 1].X, seg.Points[idx + 1].Y), seg.IsStroked);
                fig.Segments.Add(qbseg);
            }
            geo = geo.GetFlattenedPathGeometry();
            fig = geo.Figures[0];
            PolyLineSegment lineSeg = (PolyLineSegment)fig.Segments[0];

            PdfSharp.Xps.XpsModel.PolyLineSegment resultSeg = new PdfSharp.Xps.XpsModel.PolyLineSegment();
            foreach (Point point in lineSeg.Points)
            {
                resultSeg.Points.Add(new PdfSharp.Xps.XpsModel.Point(point.X, point.Y));
            }
            return(resultSeg);
        }
예제 #19
0
 public static PathSegment GetPathSegment(List <Point> edge)
 {
     if (edge.Count == 2)
     {
         return(new System.Windows.Media.LineSegment()
         {
             Point = edge[1]
         });
     }
     if (edge.Count == 3)
     {
         QuadraticBezierSegment bezierSegment = new QuadraticBezierSegment();
         bezierSegment.Point1 = edge[1];
         bezierSegment.Point2 = edge[2];
         return(bezierSegment);
     }
     else if (edge.Count == 4)
     {
         BezierSegment bezierSegment = new BezierSegment();
         bezierSegment.Point1 = edge[1];
         bezierSegment.Point2 = edge[2];
         bezierSegment.Point3 = edge[3];
         return(bezierSegment);
     }
     else
     {
         throw new ArgumentException();
     }
 }
예제 #20
0
        public void DrawCurve(int x1, int y1, int ctrlx, int ctrly, int x2, int y2)
        {
            Path path = new Path()
            {
                Stroke = new SolidColorBrush(_color), StrokeThickness = 1
            };

            QuadraticBezierSegment bezier = new QuadraticBezierSegment()
            {
                Point1 = new Point(ctrlx, ctrly), Point2 = new Point(x2, y2)
            };

            PathFigure figure = new PathFigure()
            {
                StartPoint = new Point(x1, y1)
            };

            figure.Segments.Add(bezier);

            PathGeometry geometry = new PathGeometry();

            geometry.Figures.Add(figure);

            path.Data = geometry;

            Canvas.Children.Add(path);
            //Debug.WriteLine("Curve Start Point: ( " + x1 + ", " + y1 + ")");
            //Debug.WriteLine("Curve End Point: ( " + x2 + ", " + y2 + ")");
        }
예제 #21
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            var pgFill = new PathGeometry();
            var pfFill = new PathFigure()
            {
                IsFilled = true, IsClosed = true
            };

            pfFill.StartPoint = new Point(ActualWidth, 0.0);

            var q1Fill = new QuadraticBezierSegment()
            {
                Point1 = new Point(ActualWidth * 2 / 3, 0.0), Point2 = new Point(ActualWidth / 2.0, ActualHeight / 2.0), IsStroked = false
            };

            pfFill.Segments.Add(q1Fill);
            var q2Fill = new QuadraticBezierSegment()
            {
                Point1 = new Point(ActualWidth / 3, ActualHeight), Point2 = new Point(0, ActualHeight), IsStroked = false
            };

            pfFill.Segments.Add(q2Fill);

            pfFill.Segments.Add(new LineSegment()
            {
                Point = new Point(ActualWidth, ActualHeight), IsStroked = false
            });

            pgFill.Figures.Add(pfFill);

            drawingContext.DrawGeometry(Fill, null, pgFill);

            var pgBorder = new PathGeometry();
            var pfBorder = new PathFigure()
            {
                IsFilled = false, IsClosed = false
            };

            pfBorder.StartPoint = new Point(ActualWidth, Thickness / 2);

            var q1Border = new QuadraticBezierSegment()
            {
                Point1 = new Point(ActualWidth * 2 / 3, 0.0), Point2 = new Point(ActualWidth / 2.0, ActualHeight / 2.0)
            };

            pfBorder.Segments.Add(q1Border);
            var q2Border = new QuadraticBezierSegment()
            {
                Point1 = new Point(ActualWidth / 3, ActualHeight), Point2 = new Point(0.0, ActualHeight - BottomBorderMargin)
            };

            pfBorder.Segments.Add(q2Border);

            pgBorder.Figures.Add(pfBorder);

            drawingContext.DrawGeometry(null, new Pen(Stroke, Thickness), pgBorder);

            base.OnRender(drawingContext);
        }
예제 #22
0
 /// <summary>
 /// Returns new QuadraticBezierSegment by easing startValue to endValue using a time percentage 0 -> 1.
 /// </summary>
 /// <example>XAML: Data="M 10,100 Q 200,200 300,100"</example>
 /// <seealso cref="http://msdn.microsoft.com/en-us/library/system.windows.media.quadraticbeziersegment.aspx"/>
 public static QuadraticBezierSegment EaseValue(QuadraticBezierSegment startValue, QuadraticBezierSegment endValue, double percent)
 {
     return(new QuadraticBezierSegment
     {
         Point1 = EaseValue(startValue.Point1, endValue.Point1, percent),
         Point2 = EaseValue(startValue.Point2, endValue.Point2, percent)
     });
 }
        public void QuadraticBezierTo(Point control, Point endPoint)
        {
            var quadraticBezierSegment = new QuadraticBezierSegment {
                Point1 = control, Point2 = endPoint
            };

            _currentFigure.Segments.Add(quadraticBezierSegment);
        }
예제 #24
0
        private void AddNetOutShape(Stroke stroke)
        {
            double width  = NetOutStrokesGrid.Width;
            double height = width;

            Path         netOutShape  = new Path();
            PathGeometry pathGeometry = new PathGeometry();
            PathFigure   pathFigure   = new PathFigure();

            pathFigure.StartPoint = new Point(width * 0.6, 0);

            QuadraticBezierSegment tr = new QuadraticBezierSegment(new Point(width, 0), new Point(width, height * 0.4), false);

            pathFigure.Segments.Add(tr);
            LineSegment r = new LineSegment(new Point(width, height * 0.6), false);

            pathFigure.Segments.Add(r);
            QuadraticBezierSegment rb = new QuadraticBezierSegment(new Point(width, height), new Point(width * 0.6, height), false);

            pathFigure.Segments.Add(rb);
            LineSegment b = new LineSegment(new Point(width * 0.4, height), false);

            pathFigure.Segments.Add(b);
            QuadraticBezierSegment bl = new QuadraticBezierSegment(new Point(0, height), new Point(0, height * 0.6), false);

            pathFigure.Segments.Add(bl);
            LineSegment l = new LineSegment(new Point(0, height * 0.4), false);

            pathFigure.Segments.Add(l);
            QuadraticBezierSegment lt = new QuadraticBezierSegment(new Point(0, 0), new Point(width * 0.4, 0), false);

            pathFigure.Segments.Add(lt);
            LineSegment t = new LineSegment(new Point(width * 0.6, 0), false);

            pathFigure.Segments.Add(t);

            pathFigure.IsClosed = true;

            pathGeometry.Figures.Add(pathFigure);

            double topMargin = 2;

            netOutShape.Data   = pathGeometry;
            netOutShape.Tag    = ShapeType.NetOut;
            netOutShape.Margin = new Thickness(0, topMargin, 0, 0);

            ApplyStyle(stroke, netOutShape);
            AttachEventHandlerToShape(netOutShape, stroke);
            StrokeShapes[stroke].Add(netOutShape);

            Grid.SetRow(netOutShape, NetOutStrokesGrid.Children.Count);
            RowDefinition row = new RowDefinition();

            row.Height = new GridLength(height + topMargin);
            NetOutStrokesGrid.RowDefinitions.Add(row);

            NetOutStrokesGrid.Children.Add(netOutShape);
        }
예제 #25
0
        public void QuadraticBezierTo(Point point1, Point point2, bool isStroked, bool isSmoothJoin)
        {
            CheckState();
            QuadraticBezierSegment seg = new QuadraticBezierSegment();

            seg.Point1 = point1;
            seg.Point2 = point2;
            _Fig.Segments.Add(seg);
        }
예제 #26
0
        private static void Point2_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            QuadraticBezierSegment segment = (QuadraticBezierSegment)d;

            if (e.NewValue != e.OldValue && segment.INTERNAL_parentPath != null && segment.INTERNAL_parentPath._isLoaded)
            {
                segment.INTERNAL_parentPath.ScheduleRedraw();
            }
        }
        protected override Point BezierFormula(double t)
        {
            QuadraticBezierSegment s = (QuadraticBezierSegment)Segment;
            Point r = new Point();

            r.X = (1 - t) * (1 - t) * StartPoint.X + 2 * (1 - t) * t * s.Point1.X + t * t * s.Point2.X;
            r.Y = (1 - t) * (1 - t) * StartPoint.Y + 2 * (1 - t) * t * s.Point1.Y + t * t * s.Point2.Y;
            return(r);
        }
예제 #28
0
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var coordinate = value as CurveViewModel.Coordinate;
        var segment    = new QuadraticBezierSegment();

        // Set properties of quadratic bezier element

        return(segment);
    }
예제 #29
0
        public static QuadraticBezierSegment CreateQuadraticBezierSegment(Point point1, Point point2, bool isStroked, bool?isSmoothJoin)
        {
            QuadraticBezierSegment quadraticBezierSegment = new QuadraticBezierSegment();

            quadraticBezierSegment.Point1 = point1;
            quadraticBezierSegment.Point2 = point2;
            PathSegmentUtilities.SetStrokeAndJoinOnSegment((PathSegment)quadraticBezierSegment, isStroked, isSmoothJoin);
            return(quadraticBezierSegment);
        }
예제 #30
0
            private static void AddQuadraticBeziersImpl(IntPtr thisPtr, IntPtr beziers, int beziersCount)
            {
                var shadow         = ToShadow <ID2D1GeometrySinkShadow>(thisPtr);
                var callback       = (ID2D1GeometrySink)shadow.Callback;
                var managedBeziers = new QuadraticBezierSegment[beziersCount];

                MemoryHelpers.Read(beziers, managedBeziers, 0, beziersCount);
                callback.AddQuadraticBeziers(managedBeziers);
            }
예제 #31
0
        private static void Point2_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            QuadraticBezierSegment segment = (QuadraticBezierSegment)d;

            if (segment.ParentPath != null)
            {
                segment.ParentPath.ScheduleRedraw();
            }
        }
예제 #32
0
 public void AddQuadraticBeziers(QuadraticBezierSegment[] beziers)
 {
 }
예제 #33
0
 void GeometrySink.AddQuadraticBeziers(QuadraticBezierSegment[] beziers)
 {
     throw new NotSupportedException();
 }
 /// <summary>
 /// Returns new QuadraticBezierSegment by easing startValue to endValue using a time percentage 0 -> 1.
 /// </summary>
 /// <example>XAML: Data="M 10,100 Q 200,200 300,100"</example>
 /// <seealso cref="http://msdn.microsoft.com/en-us/library/system.windows.media.quadraticbeziersegment.aspx"/>
 public static QuadraticBezierSegment EaseValue(QuadraticBezierSegment startValue, QuadraticBezierSegment endValue, double percent)
 {
     return new QuadraticBezierSegment
     {
        Point1 = EaseValue(startValue.Point1, endValue.Point1, percent),
        Point2 = EaseValue(startValue.Point2, endValue.Point2, percent)
     };
 }
예제 #35
0
 public void AddQuadraticBezier(QuadraticBezierSegment bezier)
 {
     _buffer.AppendFormat("Q {0},{1} {2},{3} ",
         bezier.Point1.X, bezier.Point1.Y,
         bezier.Point2.X, bezier.Point2.Y);
 }
예제 #36
0
 public void AddQuadraticBezier(QuadraticBezierSegment bezier)
 {
     AddQuadraticBezier_(bezier);
 }
예제 #37
0
 public void AddQuadraticBeziers(QuadraticBezierSegment[] beziers)
 {
     AddQuadraticBeziers_(beziers, beziers.Length);
 }