Exemple #1
0
        /// <summary>
        /// Deletes all tools based on the given CapStyle.
        /// </summary>
        private static void NotifyCapStyleChanged(ICapStyle capStyle)
        {
            Debug.Assert(capStyle != null);

            // Collect affected PenKeys
            List <PenKey> penKeys = new List <PenKey>();

            foreach (KeyValuePair <PenKey, Pen> item in _penCache)
            {
                if (item.Key.StartCapStyle != null && item.Key.StartCapStyle == capStyle)
                {
                    penKeys.Add(item.Key);
                }
                else if (item.Key.EndCapStyle != null && item.Key.EndCapStyle == capStyle)
                {
                    penKeys.Add(item.Key);
                }
            }
            // Delete affected Pens
            foreach (PenKey penKey in penKeys)
            {
                Pen pen = _penCache[penKey];
                _penCache.Remove(penKey);
                pen.Dispose();
                pen = null;
            }
            penKeys.Clear();

            // Collect affected CustomLineCaps
            List <CapKey> capKeys = new List <CapKey>();

            foreach (KeyValuePair <CapKey, CustomLineCap> item in _capCache)
            {
                if (item.Key.CapStyle == capStyle)
                {
                    capKeys.Add(item.Key);
                }
            }

            // Delete affected CustomLineCaps
            foreach (CapKey capKey in capKeys)
            {
                CustomLineCap cap = _capCache[capKey];
                _capCache.Remove(capKey);
                cap.Dispose();
                cap = null;
            }
            // Delete affected GraphicsPaths
            foreach (CapKey capKey in capKeys)
            {
                if (_capPathCache.ContainsKey(capKey))
                {
                    GraphicsPath path = _capPathCache[capKey];
                    _capPathCache.Remove(capKey);
                    path.Dispose();
                    path = null;
                }
            }
            capKeys.Clear();
        }
        public void Draw(Graphics gr)
        {
            CustomLineCap e = EndLineCap.GetCustomLineCap();

            Pen pen = new Pen(Color.Black);

            pen.CustomEndCap = e;

            //gr.DrawLine(pen, Start.Location, End.Location);

            e.Dispose();
        }
 public void Disposed_MembersThrow()
 {
     using (GraphicsPath strokePath = new GraphicsPath())
         using (CustomLineCap customLineCap = new CustomLineCap(null, strokePath))
         {
             customLineCap.Dispose();
             AssertExtensions.Throws <ArgumentException>(null, () => customLineCap.StrokeJoin);
             AssertExtensions.Throws <ArgumentException>(null, () => customLineCap.BaseCap);
             AssertExtensions.Throws <ArgumentException>(null, () => customLineCap.BaseInset);
             AssertExtensions.Throws <ArgumentException>(null, () => customLineCap.WidthScale);
             AssertExtensions.Throws <ArgumentException>(null, () => customLineCap.Clone());
             AssertExtensions.Throws <ArgumentException>(null, () => customLineCap.SetStrokeCaps(LineCap.Flat, LineCap.Flat));
             AssertExtensions.Throws <ArgumentException>(null, () => customLineCap.GetStrokeCaps(out LineCap startCap, out LineCap endCap));
         }
 }
Exemple #4
0
        public override void Draw(Graphics gr)
        {
            base.Draw(gr);

            CustomLineCap s = StartLineCap.GetCustomLineCap();
            CustomLineCap e = EndLineCap.GetCustomLineCap();

            pen.CustomStartCap = s;
            pen.CustomEndCap   = e;

            gr.DrawLine(pen, start, end);

            s.Dispose();
            e.Dispose();
        }
Exemple #5
0
 internal static void DrawConnector(Graphics graphics, Pen pen, Point[] points, Size connectorCapSize, Size maxCapSize, LineAnchor startConnectorCap, LineAnchor endConnectorCap)
 {
     if (points.GetLength(0) >= 2)
     {
         points = OptimizeConnectorPoints(points);
         GraphicsPath path     = null;
         float        capinset = 0f;
         if (startConnectorCap != LineAnchor.None)
         {
             Point[] pointArray = new Point[] { points[0], points[1] };
             int     num2       = (pointArray[0].Y == pointArray[1].Y) ? connectorCapSize.Width : connectorCapSize.Height;
             num2 += num2 % 2;
             num2  = Math.Min(Math.Min(num2, maxCapSize.Width), maxCapSize.Height);
             path  = GetLineCap(startConnectorCap, num2, out capinset);
             if (((path != null) && ((startConnectorCap % LineAnchor.ArrowAnchor) == LineAnchor.None)) && ((pointArray[0].X == pointArray[1].X) || (pointArray[0].Y == pointArray[1].Y)))
             {
                 Matrix transform = graphics.Transform;
                 graphics.TranslateTransform((float)pointArray[0].X, (float)pointArray[0].Y);
                 if (pointArray[0].Y == pointArray[1].Y)
                 {
                     graphics.RotateTransform((pointArray[0].X < pointArray[1].X) ? 90f : 270f);
                 }
                 else
                 {
                     graphics.RotateTransform((pointArray[0].Y < pointArray[1].Y) ? 180f : 0f);
                 }
                 using (Brush brush = new SolidBrush(pen.Color))
                 {
                     graphics.FillPath(brush, path);
                 }
                 graphics.Transform = (transform != null) ? transform : new Matrix();
             }
         }
         GraphicsPath path2 = null;
         float        num3  = 0f;
         if (endConnectorCap != LineAnchor.None)
         {
             Point[] pointArray2 = new Point[] { points[points.GetLength(0) - 2], points[points.GetLength(0) - 1] };
             int     num4        = (pointArray2[0].Y == pointArray2[1].Y) ? connectorCapSize.Width : connectorCapSize.Height;
             num4 += num4 % 2;
             num4  = Math.Min(Math.Min(num4, maxCapSize.Width), maxCapSize.Height);
             path2 = GetLineCap(endConnectorCap, num4, out num3);
             if (((path2 != null) && ((endConnectorCap % LineAnchor.ArrowAnchor) == LineAnchor.None)) && ((pointArray2[0].X == pointArray2[1].X) || (pointArray2[0].Y == pointArray2[1].Y)))
             {
                 Matrix matrix2 = graphics.Transform;
                 graphics.TranslateTransform((float)pointArray2[1].X, (float)pointArray2[1].Y);
                 if (pointArray2[0].Y == pointArray2[1].Y)
                 {
                     graphics.RotateTransform((pointArray2[0].X < pointArray2[1].X) ? 270f : 90f);
                 }
                 else
                 {
                     graphics.RotateTransform((pointArray2[0].Y < pointArray2[1].Y) ? 0f : 180f);
                 }
                 using (Brush brush2 = new SolidBrush(pen.Color))
                 {
                     graphics.FillPath(brush2, path2);
                 }
                 graphics.Transform = (matrix2 != null) ? matrix2 : new Matrix();
             }
         }
         if (path != null)
         {
             CustomLineCap cap = new CustomLineCap(null, path)
             {
                 WidthScale = 1f / pen.Width,
                 BaseInset  = capinset
             };
             pen.CustomStartCap = cap;
         }
         if (path2 != null)
         {
             CustomLineCap cap2 = new CustomLineCap(null, path2)
             {
                 WidthScale = 1f / pen.Width,
                 BaseInset  = num3
             };
             pen.CustomEndCap = cap2;
         }
         using (GraphicsPath path3 = GetRoundedPath(points, 5))
         {
             graphics.DrawPath(pen, path3);
         }
         if (path != null)
         {
             CustomLineCap customStartCap = pen.CustomStartCap;
             pen.StartCap = LineCap.Flat;
             customStartCap.Dispose();
         }
         if (path2 != null)
         {
             CustomLineCap customEndCap = pen.CustomEndCap;
             pen.EndCap = LineCap.Flat;
             customEndCap.Dispose();
         }
     }
 }
Exemple #6
0
 protected override void OnPaint(PaintEventArgs A_0)
 {
     try
     {
         base.OnPaint(A_0);
         Rectangle rect = new Rectangle(base.ClientRectangle.Left + (d - 1), base.ClientRectangle.Top + (d - 1), base.ClientRectangle.Width - 1 - 2 * (d - 1), base.ClientRectangle.Height - 1 - 2 * (d - 1));
         if (rect.Width > ab.X)
         {
             rect.X     += ab.X;
             rect.Width -= ab.X;
         }
         if (rect.Height > ab.Y)
         {
             rect.Y      += ab.Y;
             rect.Height -= ab.Y;
         }
         if (rect.Width > ac.X)
         {
             rect.Width -= ac.X;
         }
         if (rect.Height > ac.Y)
         {
             rect.Height -= ac.Y;
         }
         A_0.Graphics.SmoothingMode     = SmoothingMode.AntiAlias;
         A_0.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
         if (!i)
         {
             SolidBrush solidBrush = new SolidBrush(base.Parent.BackColor);
             A_0.Graphics.FillRectangle(solidBrush, base.ClientRectangle);
             Pen pen = new Pen(solidBrush);
             A_0.Graphics.DrawRectangle(pen, base.ClientRectangle);
             pen.Dispose();
             solidBrush.Dispose();
         }
         Pen pen2 = new Pen(e, d)
         {
             DashCap  = m,
             StartCap = j
         };
         if (pen2.StartCap == LineCap.Custom)
         {
             GraphicsPath graphicsPath = new GraphicsPath();
             int          num          = 0;
             if (s && !r)
             {
                 num = -1;
             }
             if (n != HMICustomizedCap.CC_Circle)
             {
                 if (n == HMICustomizedCap.CC_Diamond)
                 {
                     if (!r)
                     {
                         graphicsPath.AddLine(0, 2 * o + num, o, o + num);
                         graphicsPath.AddLine(o, o + num, 0, num);
                         graphicsPath.AddLine(0, num, -o, o + num);
                         graphicsPath.AddLine(-o, o + num, 0, 2 * o + num);
                     }
                     else
                     {
                         graphicsPath.AddLine(0, num, o, -o);
                         graphicsPath.AddLine(o, -o, 0, -2 * o);
                         graphicsPath.AddLine(0, -2 * o, -o, -o);
                         graphicsPath.AddLine(-o, -o, 0, 0);
                     }
                 }
                 else if (n != HMICustomizedCap.CC_HalfCircle)
                 {
                     if (n == HMICustomizedCap.CC_HalfCircle2)
                     {
                         if (r)
                         {
                             graphicsPath.AddArc(-o, -o, 2 * o, 2 * o, 180f, 180f);
                         }
                         else
                         {
                             graphicsPath.AddArc(-o, num, 2 * o, 2 * o, 180f, 180f);
                         }
                         graphicsPath.CloseFigure();
                     }
                     else if (n == HMICustomizedCap.CC_Rectangle)
                     {
                         Rectangle rect2 = new Rectangle(-o, -2 * o, 2 * o, 2 * o);
                         if (!r)
                         {
                             rect2.Y = num;
                         }
                         graphicsPath.AddRectangle(rect2);
                     }
                     else if (n == HMICustomizedCap.CC_Triangle)
                     {
                         if (!r)
                         {
                             graphicsPath.AddLine(-o, num, o, num);
                             graphicsPath.AddLine(o, num, 0, o + num);
                             graphicsPath.AddLine(0, o + num, -o, num);
                         }
                         else
                         {
                             graphicsPath.AddLine(0, 0, -o, -o);
                             graphicsPath.AddLine(-o, -o, o, -o);
                             graphicsPath.AddLine(o, -o, 0, 0);
                         }
                     }
                     else if (r)
                     {
                         graphicsPath.AddLine(o, -o, 0, 0);
                         graphicsPath.AddLine(0, 0, -o, -o);
                     }
                     else
                     {
                         graphicsPath.AddLine(o, o + num, 0, num);
                         graphicsPath.AddLine(0, num, -o, o + num);
                     }
                 }
                 else
                 {
                     if (!r)
                     {
                         graphicsPath.AddArc(-o, -o + num, 2 * o, 2 * o, 0f, 180f);
                     }
                     else
                     {
                         graphicsPath.AddArc(-o, -2 * o, 2 * o, 2 * o, 0f, 180f);
                     }
                     graphicsPath.CloseFigure();
                 }
             }
             else if (r)
             {
                 graphicsPath.AddEllipse(-o, -2 * o, 2 * o, 2 * o);
             }
             else
             {
                 graphicsPath.AddEllipse(-o, num, 2 * o, 2 * o);
             }
             if (!s)
             {
                 CustomLineCap customLineCap2 = pen2.CustomStartCap = new CustomLineCap(null, graphicsPath);
                 customLineCap2.Dispose();
             }
             else
             {
                 graphicsPath.CloseFigure();
                 CustomLineCap customLineCap4 = pen2.CustomStartCap = new CustomLineCap(graphicsPath, null);
                 customLineCap4.Dispose();
             }
             graphicsPath.Dispose();
         }
         pen2.EndCap = k;
         if (pen2.EndCap == LineCap.Custom)
         {
             GraphicsPath graphicsPath2 = new GraphicsPath();
             int          num2          = 0;
             if (u && !t)
             {
                 num2 = -1;
             }
             if (p == HMICustomizedCap.CC_Circle)
             {
                 if (t)
                 {
                     graphicsPath2.AddEllipse(-q, -2 * q, 2 * q, 2 * q);
                 }
                 else
                 {
                     graphicsPath2.AddEllipse(-q, num2, 2 * q, 2 * q);
                 }
             }
             else if (p == HMICustomizedCap.CC_Diamond)
             {
                 if (t)
                 {
                     graphicsPath2.AddLine(0, 0, q, -q);
                     graphicsPath2.AddLine(q, -q, 0, -2 * q);
                     graphicsPath2.AddLine(0, -2 * q, -q, -q);
                     graphicsPath2.AddLine(-q, -q, 0, 0);
                 }
                 else
                 {
                     graphicsPath2.AddLine(0, 2 * q + num2, q, q + num2);
                     graphicsPath2.AddLine(q, q + num2, 0, num2);
                     graphicsPath2.AddLine(0, num2, -q, q + num2);
                     graphicsPath2.AddLine(-q, q + num2, 0, 2 * q + num2);
                 }
             }
             else if (p == HMICustomizedCap.CC_HalfCircle)
             {
                 if (t)
                 {
                     graphicsPath2.AddArc(-q, -2 * q, 2 * q, 2 * q, 0f, 180f);
                 }
                 else
                 {
                     graphicsPath2.AddArc(-q, -q + num2, 2 * q, 2 * q, 0f, 180f);
                 }
                 graphicsPath2.CloseFigure();
             }
             else if (p != HMICustomizedCap.CC_HalfCircle2)
             {
                 if (p == HMICustomizedCap.CC_Rectangle)
                 {
                     Rectangle rect3 = new Rectangle(-q, -2 * q, 2 * q, 2 * q);
                     if (!t)
                     {
                         rect3.Y = num2;
                     }
                     graphicsPath2.AddRectangle(rect3);
                 }
                 else if (p == HMICustomizedCap.CC_Triangle)
                 {
                     if (!t)
                     {
                         graphicsPath2.AddLine(-q, num2, q, num2);
                         graphicsPath2.AddLine(q, num2, 0, q + num2);
                         graphicsPath2.AddLine(0, q + num2, -q, num2);
                     }
                     else
                     {
                         graphicsPath2.AddLine(0, 0, -q, -q);
                         graphicsPath2.AddLine(-q, -q, q, -q);
                         graphicsPath2.AddLine(q, -q, 0, 0);
                     }
                 }
                 else if (!t)
                 {
                     graphicsPath2.AddLine(q, q + num2, 0, num2);
                     graphicsPath2.AddLine(0, num2, -q, q + num2);
                 }
                 else
                 {
                     graphicsPath2.AddLine(q, -q, 0, 0);
                     graphicsPath2.AddLine(0, 0, -q, -q);
                 }
             }
             else
             {
                 if (t)
                 {
                     graphicsPath2.AddArc(-q, -q, 2 * q, 2 * q, 180f, 180f);
                 }
                 else
                 {
                     graphicsPath2.AddArc(-q, num2, 2 * q, 2 * q, 180f, 180f);
                 }
                 graphicsPath2.CloseFigure();
             }
             if (u)
             {
                 graphicsPath2.CloseFigure();
                 CustomLineCap customLineCap6 = pen2.CustomEndCap = new CustomLineCap(graphicsPath2, null);
                 customLineCap6.Dispose();
             }
             else
             {
                 CustomLineCap customLineCap8 = pen2.CustomEndCap = new CustomLineCap(null, graphicsPath2);
                 customLineCap8.Dispose();
             }
             graphicsPath2.Dispose();
         }
         pen2.DashStyle = l;
         if (ad)
         {
             float[] array = new float[6];
             float   num3  = 0f;
             array[0] = 0f;
             array[1] = num3 + ae;
             num3    += ae;
             if (num3 <= 1f)
             {
                 if (num3 + af <= 1f)
                 {
                     array[2] = num3 + af;
                     num3    += af;
                 }
                 else
                 {
                     array[2] = 1f;
                     num3     = 1f;
                 }
             }
             if (num3 <= 1f)
             {
                 if (num3 + ag <= 1f)
                 {
                     array[3] = num3 + ag;
                     num3    += ag;
                 }
                 else
                 {
                     array[3] = 1f;
                     num3     = 1f;
                 }
             }
             if (num3 <= 1f)
             {
                 if (num3 + ah <= 1f)
                 {
                     array[4] = num3 + ah;
                     num3    += ah;
                 }
                 else
                 {
                     array[4] = 1f;
                     num3     = 1f;
                 }
             }
             if (num3 <= 1f)
             {
                 array[5] = 1f;
                 num3     = 1f;
             }
             pen2.CompoundArray = array;
         }
         LinearGradientBrush linearGradientBrush = new LinearGradientBrush(base.ClientRectangle, e, g, h);
         if (f)
         {
             pen2.Brush = linearGradientBrush;
         }
         if (c == HMILineType.LT_ForwardDiagonal)
         {
             A_0.Graphics.DrawLine(pen2, rect.Left, rect.Top, rect.Right, rect.Bottom);
         }
         else if (c != HMILineType.LT_BackwardDiagonal)
         {
             if (c == HMILineType.LT_Horizontal)
             {
                 A_0.Graphics.DrawLine(pen2, rect.Left, (rect.Top + rect.Bottom) / 2, rect.Right, (rect.Top + rect.Bottom) / 2);
             }
             else if (c == HMILineType.LT_Vertical)
             {
                 A_0.Graphics.DrawLine(pen2, (rect.Left + rect.Right) / 2, rect.Top, (rect.Left + rect.Right) / 2, rect.Bottom);
             }
             else if (c == HMILineType.LT_CustomizedLine)
             {
                 A_0.Graphics.DrawLine(pen2, v, w);
             }
             else if (c != HMILineType.LT_LeftArc)
             {
                 if (c != HMILineType.LT_RightArc)
                 {
                     if (c != HMILineType.LT_TopArc)
                     {
                         if (c != HMILineType.LT_BottomArc)
                         {
                             if (c != HMILineType.LT_LeftTopArc)
                             {
                                 if (c == HMILineType.LT_RightTopArc)
                                 {
                                     A_0.Graphics.DrawArc(pen2, rect.Left - rect.Width, rect.Top, 2 * rect.Width, 2 * rect.Height, 270, 90);
                                 }
                                 else if (c != HMILineType.LT_LeftBottomArc)
                                 {
                                     if (c == HMILineType.LT_RightBottomArc)
                                     {
                                         A_0.Graphics.DrawArc(pen2, rect.Left - rect.Width, rect.Top - rect.Height, 2 * rect.Width, 2 * rect.Height, 0, 90);
                                     }
                                     else if (c == HMILineType.LT_CustomizedArc)
                                     {
                                         A_0.Graphics.DrawArc(pen2, rect, x, y - x);
                                     }
                                     else if (c == HMILineType.LT_FourPointCurve)
                                     {
                                         A_0.Graphics.DrawBezier(pen2, v, z, aa, w);
                                     }
                                 }
                                 else
                                 {
                                     A_0.Graphics.DrawArc(pen2, rect.Left, rect.Top - rect.Height, 2 * rect.Width, 2 * rect.Height, 90, 90);
                                 }
                             }
                             else
                             {
                                 A_0.Graphics.DrawArc(pen2, rect.Left, rect.Top, 2 * rect.Width, 2 * rect.Height, 180, 90);
                             }
                         }
                         else
                         {
                             A_0.Graphics.DrawArc(pen2, rect.Left, rect.Top - rect.Height, rect.Width, 2 * rect.Height, 0, 180);
                         }
                     }
                     else
                     {
                         A_0.Graphics.DrawArc(pen2, rect.Left, rect.Top, rect.Width, 2 * rect.Height, 180, 180);
                     }
                 }
                 else
                 {
                     A_0.Graphics.DrawArc(pen2, rect.Left - rect.Width, rect.Top, 2 * rect.Width, rect.Height, 270, 180);
                 }
             }
             else
             {
                 A_0.Graphics.DrawArc(pen2, rect.Left, rect.Top, 2 * rect.Width, rect.Height, 90, 180);
             }
         }
         else
         {
             A_0.Graphics.DrawLine(pen2, rect.Right, rect.Top, rect.Left, rect.Bottom);
         }
         linearGradientBrush.Dispose();
         pen2.Dispose();
         if (flagB)
         {
             SolidBrush   solidBrush2 = new SolidBrush(Color.Red);
             StringFormat format      = new StringFormat
             {
                 Alignment     = StringAlignment.Center,
                 LineAlignment = StringAlignment.Center
             };
             A_0.Graphics.DrawString("Designed By Hao Thien Co.,Ltd: 0909.886.483", Font, solidBrush2, base.ClientRectangle, format);
             solidBrush2.Dispose();
         }
     }
     catch (ApplicationException ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        internal static void DrawConnector(Graphics graphics, Pen pen, Point[] points, Size connectorCapSize, Size maxCapSize, LineAnchor startConnectorCap, LineAnchor endConnectorCap)
        {
            if (points.GetLength(0) < 2)
            {
                return;
            }

            points = OptimizeConnectorPoints(points);

            //First we start with drawing start cap
            GraphicsPath startCap      = null;
            float        startCapInset = 0.0f;

            if (startConnectorCap != LineAnchor.None)
            {
                Point[] startSegment = new Point[] { points[0], points[1] };
                int     capSize      = (startSegment[0].Y == startSegment[1].Y) ? connectorCapSize.Width : connectorCapSize.Height;
                capSize += (capSize % 2);
                capSize  = Math.Min(Math.Min(capSize, maxCapSize.Width), maxCapSize.Height);
                startCap = GetLineCap(startConnectorCap, capSize, out startCapInset);

                //Now if user has requested us to fill the line cap then we do so
                //THIS IS A WORKAROUND IN FILLING THE CUSTOM CAPS AS GDI+ HAS A
                bool fill = (startCap != null && (((int)startConnectorCap % 2) == 0) && (startSegment[0].X == startSegment[1].X || startSegment[0].Y == startSegment[1].Y));
                if (fill)
                {
                    Matrix oldTransform = graphics.Transform;
                    graphics.TranslateTransform(startSegment[0].X, startSegment[0].Y);
                    if (startSegment[0].Y == startSegment[1].Y)
                    {
                        graphics.RotateTransform((startSegment[0].X < startSegment[1].X) ? 90.0f : 270.0f);
                    }
                    else
                    {
                        graphics.RotateTransform((startSegment[0].Y < startSegment[1].Y) ? 180.0f : 0.0f);
                    }
                    using (Brush penBrush = new SolidBrush(pen.Color))
                        graphics.FillPath(penBrush, startCap);
                    graphics.Transform = (oldTransform != null) ? oldTransform : new Matrix();
                }
            }

            GraphicsPath endCap      = null;
            float        endCapInset = 0.0f;

            if (endConnectorCap != LineAnchor.None)
            {
                Point[] endSegment = new Point[] { points[points.GetLength(0) - 2], points[points.GetLength(0) - 1] };
                int     capSize    = (endSegment[0].Y == endSegment[1].Y) ? connectorCapSize.Width : connectorCapSize.Height;
                capSize += (capSize % 2);
                capSize  = Math.Min(Math.Min(capSize, maxCapSize.Width), maxCapSize.Height);
                endCap   = GetLineCap(endConnectorCap, capSize, out endCapInset);

                //Now if user has requested us to fill the line cap then we do so,
                //THIS IS A WORKAROUND IN FILLING THE CUSTOM CAPS AS GDI+ HAS A
                bool fill = (endCap != null && (((int)endConnectorCap % 2) == 0) && (endSegment[0].X == endSegment[1].X || endSegment[0].Y == endSegment[1].Y));
                if (fill)
                {
                    Matrix oldTransform = graphics.Transform;
                    graphics.TranslateTransform(endSegment[1].X, endSegment[1].Y);
                    if (endSegment[0].Y == endSegment[1].Y)
                    {
                        graphics.RotateTransform((endSegment[0].X < endSegment[1].X) ? 270.0f : 90.0f);
                    }
                    else
                    {
                        graphics.RotateTransform((endSegment[0].Y < endSegment[1].Y) ? 0.0f : 180.0f);
                    }
                    using (Brush penBrush = new SolidBrush(pen.Color))
                        graphics.FillPath(penBrush, endCap);
                    graphics.Transform = (oldTransform != null) ? oldTransform : new Matrix();
                }
            }

            if (startCap != null)
            {
                CustomLineCap customStartCap = new CustomLineCap(null, startCap);
                customStartCap.WidthScale = 1.0f / pen.Width;
                customStartCap.BaseInset  = startCapInset;
                pen.CustomStartCap        = customStartCap;
            }

            if (endCap != null)
            {
                CustomLineCap customEndCap = new CustomLineCap(null, endCap);
                customEndCap.WidthScale = 1.0f / pen.Width;
                customEndCap.BaseInset  = endCapInset;
                pen.CustomEndCap        = customEndCap;
            }

            using (GraphicsPath path = GetRoundedPath(points, StateDesignerConnector.ConnectorPadding / 2))
            {
                graphics.DrawPath(pen, path);
            }

            if (startCap != null)
            {
                CustomLineCap disposableLineCap = pen.CustomStartCap;
                pen.StartCap = LineCap.Flat;
                disposableLineCap.Dispose();
            }

            if (endCap != null)
            {
                CustomLineCap disposableLineCap = pen.CustomEndCap;
                pen.EndCap = LineCap.Flat;
                disposableLineCap.Dispose();
            }
        }