コード例 #1
0
ファイル: OverlayShapeViews.cs プロジェクト: wilsoc5/tikzedt
        }                                           // the angles of the spokes, in radians


        //public double R { get { return TheShape.R; } set { TheShape.R = value; } }
        //public Point Center { get { return TheShape.Center; } set { TheShape.Center = value; } }
        //public List<double> Spokes { get { return TheShape.Spokes; } set { TheShape.Spokes = value; } }    // the angles of the spokes, in radians

        /// <summary>
        /// Draw an arc
        /// </summary>
        /// <param name="dc"></param>
        public override void Draw(Cairo.Context dc)
        {
            if (R == 0 || Spokes == null || Spokes.Count < 2 || ThePen == null)
            {
                return;
            }

            dc.DrawLine(Center, spokep(0)); //ThePen,

            for (int i = 1; i < Spokes.Count; i++)
            {
                if (Math.Abs(Spokes[i] - Spokes[i - 1]) > 2 * Math.PI - .001)
                {
                    // Display a circle
                    double ControlPointRatio = (Math.Sqrt(2) - 1) * 4 / 3;

                    var x0 = (float)(Center.X - R);
                    var x1 = (float)(Center.X - R * ControlPointRatio);
                    var x2 = (float)(Center.X);
                    var x3 = (float)(Center.X + R * ControlPointRatio);
                    var x4 = (float)(Center.X + R);

                    var y0 = (float)(Center.Y - R);
                    var y1 = (float)(Center.Y - R * ControlPointRatio);
                    var y2 = (float)(Center.Y);
                    var y3 = (float)(Center.Y + R * ControlPointRatio);
                    var y4 = (float)(Center.Y + R);

                    System.Windows.Point[] pts = new System.Windows.Point[] { new System.Windows.Point(x2, y0), new System.Windows.Point(x3, y0), new System.Windows.Point(x4, y1),
                                                                              new System.Windows.Point(x4, y2), new System.Windows.Point(x1, y4), new System.Windows.Point(x0, y3), new System.Windows.Point(x0, y2),
                                                                              new System.Windows.Point(x0, y1), new System.Windows.Point(x1, y0), new System.Windows.Point(x2, y0) };

                    dc.DrawBeziers(pts); //ThePen,

                    /* context.BeginFigure(new Point(x2, y0), true, true);
                     * context.BezierTo(new Point(x3, y0), new Point(x4, y1), new Point(x4, y2), true, true);
                     * context.BezierTo(new Point(x4, y3), new Point(x3, y4), new Point(x2, y4), true, true);
                     * context.BezierTo(new Point(x1, y4), new Point(x0, y3), new Point(x0, y2), true, true);
                     * context.BezierTo(new Point(x0, y1), new Point(x1, y0), new Point(x2, y0), true, true); */
                }
                else
                {
                    bool largearc = Math.Abs(Spokes[i] - Spokes[i - 1]) > Math.PI;

                    /* SweepDirection sd = SweepDirection.Counterclockwise;
                     * if (Spokes[i] < Spokes[i - 1])
                     *   sd = SweepDirection.Clockwise;
                     *
                     * dc.DrawArc(ThePen, (float)Center.X, (float(Center.Y), (float)R, (float)R, )
                     * context.ArcTo(spokep(i), new Size(R, R), 0, largearc, sd, true, false);*/
                    //TODO:support
                }

                dc.DrawLine(Center, spokep(i));//ThePen,
            }
        }