예제 #1
0
        private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            Graphics g       = e.Graphics;
            Pen      thePen  = new Pen(Color.Black, 10);
            int      yOffSet = 10;

            // Get all members of the LineCap enum.
            Array obj = Enum.GetValues(typeof(LineCap));

            // Draw a line with a LineCap member.
            for (int x = 0; x < obj.Length; x++)
            {
                // Get next cap and configure pen.
                LineCap temp = (LineCap)obj.GetValue(x);
                thePen.StartCap = temp;
                thePen.EndCap   = temp;

                // Print name of LineCap enum.
                g.DrawString(temp.ToString(), new Font("Times New Roman", 10),
                             new SolidBrush(Color.Black), 0, yOffSet);

                // Draw a line with the correct cap.
                g.DrawLine(thePen, 100, yOffSet, Width - 50, yOffSet);

                yOffSet += 40;
            }
        }
예제 #2
0
 public async Task SetLineCapAsync(LineCap value)
 {
     this.LineCap = value;
     await this.BatchCallAsync(LINE_CAP_PROPERTY, isMethodCall : false, value.ToString().ToLowerInvariant());
 }
예제 #3
0
 public void SetLineCap(LineCap value)
 {
     this.LineCap = value;
     this.CallMethod <object>(LINE_CAP_PROPERTY, value.ToString().ToLowerInvariant());
 }
예제 #4
0
        private void DrawEndAnchor(LineCap lc, CustomLineCap clc, Color col, float w, PointF pt, float angle, bool ignoreUnsupportedLineCaps)
        {
            SvgStyledTransformedElement anchor = null;
            PointF[] points = null;

            switch (lc) {
                case LineCap.NoAnchor:
                    break;

                case LineCap.Flat:
                    // TODO: what is the correct look?
                    break;

                case LineCap.ArrowAnchor:
                    points = new PointF[3];
                    points[0] = new PointF(0, -w / 2f);
                    points[1] = new PointF(-w, w);
                    points[2] = new PointF(w, w);
                    anchor = new SvgPolygonElement(points);
                    break;

                case LineCap.DiamondAnchor:
                    points = new PointF[4];
                    points[0] = new PointF(0, -w);
                    points[1] = new PointF(w, 0);
                    points[2] = new PointF(0, w);
                    points[3] = new PointF(-w, 0);
                    anchor = new SvgPolygonElement(points);
                    break;

                case LineCap.RoundAnchor:
                    anchor = new SvgEllipseElement(0, 0, w, w);
                    break;

                case LineCap.SquareAnchor:
                    float ww = (w / 3) * 2;
                    anchor = new SvgRectElement(0 - ww, 0 - ww, ww * 2, ww * 2);
                    break;

                case LineCap.Custom:
                    if (clc != null)
                    {
                        if (!ignoreUnsupportedLineCaps)
                            throw new SvgGdiNotImpl("DrawEndAnchor custom");
                    }
                    break;

                default:
                    if (!ignoreUnsupportedLineCaps)
                        throw new SvgGdiNotImpl("DrawEndAnchor " + lc.ToString());
                    break;
            }

            if (anchor == null)
                return;

            anchor.Id += "_line_anchor";
            anchor.Style.Set("fill", new SvgColor(col));
            anchor.Style.Set("stroke", "none");

            Matrix rotation = new Matrix();
            rotation.Rotate((angle / (float)Math.PI) * 180);
            Matrix translation = new Matrix();
            translation.Translate(pt.X, pt.Y);

            anchor.Transform = new SvgTransformList(_transforms.Result.Clone());
            anchor.Transform.Add(translation);
            anchor.Transform.Add(rotation);
            _cur.AddChild(anchor);
        }