当前位置: 首页>>代码示例>>C#>>正文


C# StreamGeometryContext.BezierTo方法代码示例

本文整理汇总了C#中System.Windows.Media.StreamGeometryContext.BezierTo方法的典型用法代码示例。如果您正苦于以下问题:C# StreamGeometryContext.BezierTo方法的具体用法?C# StreamGeometryContext.BezierTo怎么用?C# StreamGeometryContext.BezierTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.StreamGeometryContext的用法示例。


在下文中一共展示了StreamGeometryContext.BezierTo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseToGeometryContext


//.........这里部分代码省略.........
                    last_cmd = 'L';
                    break;

                case 'c': case 'C': // cubic Bezier
                case 's': case 'S': // smooth cublic Bezier
                    EnsureFigure();
                    
                    do
                    {
                        Point p;
                        
                        if ((cmd == 's') || (cmd == 'S'))
                        {
                            if (last_cmd == 'C')
                            {
                                p = Reflect();
                            }
                            else
                            {
                                p = _lastPoint;
                            }

                            _secondLastPoint = ReadPoint(cmd, ! AllowComma);
                        }
                        else
                        {
                            p = ReadPoint(cmd, ! AllowComma);

                            _secondLastPoint = ReadPoint(cmd, AllowComma);
                        }
                            
                        _lastPoint = ReadPoint(cmd, AllowComma);

                        context.BezierTo(p, _secondLastPoint, _lastPoint, IsStroked, ! IsSmoothJoin);
                        
                        last_cmd = 'C';
                    }
                    while (IsNumber(AllowComma));
                    
                    break;
                    
                case 'q': case 'Q': // quadratic Bezier
                case 't': case 'T': // smooth quadratic Bezier
                    EnsureFigure();
                    
                    do
                    {
                        if ((cmd == 't') || (cmd == 'T'))
                        {
                            if (last_cmd == 'Q')
                            {
                                _secondLastPoint = Reflect();
                            }
                            else
                            {
                                _secondLastPoint = _lastPoint;
                            }

                            _lastPoint = ReadPoint(cmd, ! AllowComma);
                        }
                        else
                        {
                            _secondLastPoint = ReadPoint(cmd, ! AllowComma);
                            _lastPoint = ReadPoint(cmd, AllowComma);
                        }
开发者ID:JianwenSun,项目名称:cc,代码行数:66,代码来源:parserscommon.cs

示例2: FillContextForICurve

        static internal void FillContextForICurve(StreamGeometryContext 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 LineSegment;
                    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 Polyline;
                            if (poly != null)
                                FillContexForPolyline(context, poly);
                            else
                            {
                                var ellipse = iCurve as Ellipse;
                                if (ellipse != null) {
                                    //       context.LineTo(Common.WpfPoint(ellipse.End),true,false);
                                    double sweepAngle = EllipseSweepAngle(ellipse);
                                    bool largeArc = Math.Abs(sweepAngle) >= Math.PI;
                                    Rectangle box = ellipse.FullBox();
                                    context.ArcTo(Common.WpfPoint(ellipse.End),
                                                  new Size(box.Width/2, box.Height/2),
                                                  sweepAngle,
                                                  largeArc,
                                                  sweepAngle < 0
                                                      ? SweepDirection.Counterclockwise
                                                      : SweepDirection.Clockwise,
                                                  true, true);
                                } else {
                                    throw new NotImplementedException();
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:49,代码来源:GraphmapsEdge.cs

示例3: FillContexForCurve

 static void FillContexForCurve(StreamGeometryContext 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 LineSegment;
             if(ls != null)
                 context.LineTo(Common.WpfPoint(ls.End),true,false);
             else {
                 var ellipse = seg as Ellipse;
                 if(ellipse != null) {
                     //       context.LineTo(Common.WpfPoint(ellipse.End),true,false);
                     double sweepAngle = EllipseSweepAngle(ellipse);
                     bool largeArc = Math.Abs(sweepAngle) >= Math.PI;
                     Rectangle box = ellipse.FullBox();
                     context.ArcTo(Common.WpfPoint(ellipse.End),
                                   new Size(box.Width / 2,box.Height / 2),
                                   sweepAngle,
                                   largeArc,
                                   sweepAngle < 0
                                       ? SweepDirection.Counterclockwise
                                       : SweepDirection.Clockwise,
                                   true,true);
                 } else
                     throw new NotImplementedException();
             }
         }
     }
 }
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:31,代码来源:GraphmapsEdge.cs

示例4: DrawArrowGeometry

        /// <summary>
        /// The actual method for drawing the arrow.
        /// </summary>
        /// <param name="StreamGeometryContext">Describes a geometry using drawing commands.</param>
        protected override void DrawArrowGeometry(StreamGeometryContext StreamGeometryContext)
        {
            var theta = Math.Atan2(Y1 - Y2, X1 - X2);
            var sint  = Math.Sin(theta);
            var cost  = Math.Cos(theta);

            var ArrowOrigin        = new Point(X1, Y1);
            var OriginControlPoint = new Point(X1CP, Y1CP);
            var ArrowTarget        = new Point(X2, Y2);
            var TargetControlPoint = new Point(Y2CP, Y2CP);

            var pt3 = new Point(X2 + (HeadWidth  * cost - HeadHeight * sint),
                                Y2 + (HeadWidth  * sint + HeadHeight * cost));

            var pt4 = new Point(X2 + (HeadWidth  * cost + HeadHeight * sint),
                                Y2 - (HeadHeight * cost - HeadWidth  * sint));

            StreamGeometryContext.BeginFigure(ArrowOrigin, isFilled:  false, isClosed:    false);
            StreamGeometryContext.BezierTo(OriginControlPoint, TargetControlPoint, ArrowTarget, true, true);
            //StreamGeometryContext.LineTo     (pt3,         isStroked: true, isSmoothJoin: true);
            //StreamGeometryContext.LineTo     (ArrowTarget, isStroked: true, isSmoothJoin: true);
            //StreamGeometryContext.LineTo     (pt4,         isStroked: true, isSmoothJoin: true);
        }
开发者ID:subbuballa,项目名称:Loki,代码行数:27,代码来源:BezierArrow.cs

示例5: SerializeData

 /// <summary>
 /// SerializeData - Serialize the contents of this Segment to the provided context.
 /// </summary>
 internal override void SerializeData(StreamGeometryContext ctx)
 {
     ctx.BezierTo(Point1, Point2, Point3, IsStroked, IsSmoothJoin);
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:BezierSegment.cs

示例6: DrawFigure

        public static void DrawFigure(StreamGeometryContext ctx, PathFigure figure)
        {
            ctx.BeginFigure(figure.StartPoint, figure.IsFilled, figure.IsClosed);
            foreach (var segment in figure.Segments)
            {
                var lineSegment = segment as WpfLineSegment;
                if (lineSegment != null) { ctx.LineTo(lineSegment.Point, lineSegment.IsStroked, lineSegment.IsSmoothJoin); continue; }

                var bezierSegment = segment as BezierSegment;
                if (bezierSegment != null) { ctx.BezierTo(bezierSegment.Point1, bezierSegment.Point2, bezierSegment.Point3, bezierSegment.IsStroked, bezierSegment.IsSmoothJoin); continue; }

                var quadraticSegment = segment as QuadraticBezierSegment;
                if (quadraticSegment != null) { ctx.QuadraticBezierTo(quadraticSegment.Point1, quadraticSegment.Point2, quadraticSegment.IsStroked, quadraticSegment.IsSmoothJoin); continue; }

                var polyLineSegment = segment as PolyLineSegment;
                if (polyLineSegment != null) { ctx.PolyLineTo(polyLineSegment.Points, polyLineSegment.IsStroked, polyLineSegment.IsSmoothJoin); continue; }

                var polyBezierSegment = segment as PolyBezierSegment;
                if (polyBezierSegment != null) { ctx.PolyBezierTo(polyBezierSegment.Points, polyBezierSegment.IsStroked, polyBezierSegment.IsSmoothJoin); continue; }

                var polyQuadraticSegment = segment as PolyQuadraticBezierSegment;
                if (polyQuadraticSegment != null) { ctx.PolyQuadraticBezierTo(polyQuadraticSegment.Points, polyQuadraticSegment.IsStroked, polyQuadraticSegment.IsSmoothJoin); continue; }

                var arcSegment = segment as ArcSegment;
                if (arcSegment != null) { ctx.ArcTo(arcSegment.Point, arcSegment.Size, arcSegment.RotationAngle, arcSegment.IsLargeArc, arcSegment.SweepDirection, arcSegment.IsStroked, arcSegment.IsSmoothJoin); continue; }
            }
        }
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:27,代码来源:GraphmapsNode.cs

示例7: InternalDrawArrowGeometry

        private void InternalDrawArrowGeometry(StreamGeometryContext context)
        {
            Point pt1, pt2, pt3, pt4;
            if (ConnectionArrowType == ConnectionArrowType.Normal)
            {
                var theta = Math.Atan2(Y1 - Y2, X1 - X2);
                var sint = Math.Sin(theta);
                var cost = Math.Cos(theta);

                switch (ViewType)
                {
                    case 0: // прямая в центр
                        pt1 = new Point(X1, Y1);
                        pt2 = new Point(X2, Y2);

                        pt3 = new Point(
                            X2 + (HeadWidth * cost - HeadHeight * sint),
                            Y2 + (HeadWidth * sint + HeadHeight * cost));

                        pt4 = new Point(
                            X2 + (HeadWidth * cost + HeadHeight * sint),
                            Y2 - (HeadHeight * cost - HeadWidth * sint));

                        context.BeginFigure(pt1, true, false);
                        context.LineTo(pt2, true, true);
                        context.LineTo(pt3, true, true);
                        context.LineTo(pt2, true, true);
                        context.LineTo(pt4, true, true);
                        break;

                    case 1: // безье (слабое) в центр
                        pt1 = new Point(X1, Y1);
                        pt2 = new Point(X2, Y2);

                        var ptTemp1 = new Point(
                            X1 - (X1 - X2) / 2,
                            Y1 - (Y1 - Y2) / 3);

                        var ptTemp2 = new Point(
                            X1 - (X1 - X2) / 4 * 3,
                            Y1 - (Y1 - Y2) / 3 * 2);

                        pt3 = new Point(
                            X2 + (HeadWidth * cost - HeadHeight * sint),
                            Y2 + (HeadWidth * sint + HeadHeight * cost));

                        pt4 = new Point(
                            X2 + (HeadWidth * cost + HeadHeight * sint),
                            Y2 - (HeadHeight * cost - HeadWidth * sint));

                        context.BeginFigure(pt1, true, false);
                        context.BezierTo(ptTemp1, ptTemp2, pt2, true, true);
                        context.LineTo(pt3, true, true);
                        context.LineTo(pt2, true, true);
                        context.LineTo(pt4, true, true);
                        break;

                    case 2: // к ближайшему краю
                        var startPoint = GetBoundPoint(false);
                        X1 = startPoint.X;
                        Y1 = startPoint.Y;

                        var endPoint = GetBoundPoint(true);
                        X2 = endPoint.X;
                        Y2 = endPoint.Y;

                        pt3 = new Point(
                            X2 + (HeadWidth * cost - HeadHeight * sint),
                            Y2 + (HeadWidth * sint + HeadHeight * cost));

                        pt4 = new Point(
                            X2 + (HeadWidth * cost + HeadHeight * sint),
                            Y2 - (HeadHeight * cost - HeadWidth * sint));

                        context.BeginFigure(startPoint, true, false);
                        context.LineTo(endPoint, true, false);
                        context.LineTo(pt3, true, true);
                        context.LineTo(endPoint, true, true);
                        context.LineTo(pt4, true, true);
                        break;
                }
            }
            else if (ConnectionArrowType == ConnectionArrowType.Loopback)
            {
                pt1 = new Point(FromItem.Position.X - 5, FromItem.Position.Y + 83);
                pt2 = new Point(pt1.X + 10, pt1.Y - 10);

                pt3 = new Point(pt2.X - 4, pt2.Y + 9);
                pt4 = new Point(pt2.X - 6, pt2.Y + 16);

                context.BeginFigure(pt1, true, false);
                context.ArcTo(pt2, new Size(6, 6), 125, true, SweepDirection.Clockwise, true, true);
                context.ArcTo(pt1, new Size(6, 6), 125, true, SweepDirection.Clockwise, true, true);
                context.LineTo(pt3, true, true);
                context.LineTo(pt1, true, true);
                context.LineTo(pt4, true, true);
            }
            else
            {
                pt1 = new Point(X1 + 20, Y1 - 25);
//.........这里部分代码省略.........
开发者ID:F1nZeR,项目名称:CourseWork,代码行数:101,代码来源:ConnectionArrow.cs

示例8: FillContextForICurve

        internal void FillContextForICurve(StreamGeometryContext context, ICurve iCurve)
        {
            if (iCurve == null) return;
            context.BeginFigure(CommonX.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(CommonX.WpfPoint(cubicBezierSeg.B(1)), CommonX.WpfPoint(cubicBezierSeg.B(2)),
                                     CommonX.WpfPoint(cubicBezierSeg.B(3)), true, false);
                else
                {
                    var ls = iCurve as LineSegment;
                    if (ls != null)
                        context.LineTo(CommonX.WpfPoint(ls.End), true, false);
                    else
                    {
                        var rr = iCurve as RoundedRect;
                        if (rr != null)
                            FillContexForCurve(context, rr.Curve);
                        else
                        {
                            var poly = iCurve as Polyline;
                            FillContexForPolyline(context, poly);
                        }
                    }
                }
            }
        }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:33,代码来源:XEdge.cs


注:本文中的System.Windows.Media.StreamGeometryContext.BezierTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。