private void DrawCapStyleItem(ICapStyle capStyle, DrawItemEventArgs e) { ILineStyle lineStyle = styleSet.LineStyles.Normal; Pen capPen = ToolCache.GetPen(lineStyle, capStyle, capStyle); Brush capBrush = null; PointF[] capPoints = null; int left = previewRect.Left; int right = previewRect.Right; if (capPen.StartCap == LineCap.Custom) { if (capPen.CustomStartCap.BaseInset > 0) { left += (int)Math.Round(capStyle.CapSize - capPen.CustomStartCap.BaseInset); right -= (int)Math.Round(capStyle.CapSize - capPen.CustomEndCap.BaseInset); } } int y = previewRect.Y + (previewRect.Height / 2); // Start Cap if (HasCustomLineCap(capStyle)) { capBrush = ToolCache.GetBrush(capStyle.ColorStyle, lineStyle); ToolCache.GetCapPoints(capStyle, styleSet.LineStyles.Normal, ref capPoints); float angle = Geometry.RadiansToDegrees(Geometry.Angle(left, y, right, y)); matrix.Reset(); matrix.Translate(left, y); matrix.Rotate(angle + 90); matrix.TransformPoints(capPoints); e.Graphics.FillPolygon(capBrush, capPoints, System.Drawing.Drawing2D.FillMode.Alternate); } // End Cap if (HasCustomLineCap(capStyle)) { capBrush = ToolCache.GetBrush(capStyle.ColorStyle, lineStyle); ToolCache.GetCapPoints(capStyle, styleSet.LineStyles.Normal, ref capPoints); float angle = Geometry.RadiansToDegrees(Geometry.Angle(right, y, left, y)); matrix.Reset(); matrix.Translate(right, y); matrix.Rotate(angle + 90); matrix.TransformPoints(capPoints); e.Graphics.FillPolygon(capBrush, capPoints, System.Drawing.Drawing2D.FillMode.Alternate); } // Draw e.Graphics.DrawLine(capPen, left, y, right, y); e.Graphics.DrawString(capStyle.Title, e.Font, TextBrush, labelLayoutRect, styleItemFormatter); }