/// <summary> /// Calculates this controls shape and size that will be used /// when it is drawn /// </summary> /// <param name="container">The allowed space for the control</param> public virtual void CalculatePaths(RectangleF container) { DisposePaths(); m_path = new GraphicsPath(); RectangleF rect = container; bool bHorizontal = (m_orientation == SegmentOrientation.Horizontal); if (bHorizontal) { rect.Inflate(-Padding, 0); } else { rect.Inflate(0, -Padding); } PointF topLeft = new PointF(rect.Left, rect.Top); PointF topRight = new PointF(rect.Right, rect.Top); PointF bottomLeft = new PointF(rect.Left, rect.Bottom); PointF bottomRight = new PointF(rect.Right, rect.Bottom); float xOffset = bHorizontal ? TipLength : 0; float yOffset = bHorizontal ? 0 : TipLength; PointF topLeftOffset = new PointF(topLeft.X + xOffset, topLeft.Y + yOffset); PointF topRightOffset = new PointF(topRight.X - xOffset, topRight.Y + yOffset); PointF bottomLeftOffset = new PointF(bottomLeft.X + xOffset, bottomLeft.Y - yOffset); PointF bottomRightOffset = new PointF(bottomRight.X - xOffset, bottomRight.Y - yOffset); PointF topCenter = new PointF(rect.Left + (rect.Width / 2f), rect.Y + (yOffset / 2f)); PointF leftCenter = new PointF(rect.Left + (xOffset / 2f), rect.Y + (rect.Height / 2f)); PointF bottomCenter = new PointF(topCenter.X, rect.Bottom - (yOffset / 2f)); PointF rightCenter = new PointF(rect.Right - (xOffset / 2f), leftCenter.Y); List <PointF> points = new List <PointF>(); points.Add(leftCenter); if (CustomExtensions.IsFlagSet(Corners, SegmentCorners.TopLeft)) { points.Add(topLeft); } else { points.Add(topLeftOffset); points.Add(topCenter); } if (CustomExtensions.IsFlagSet(Corners, SegmentCorners.TopRight)) { points.Add(topRight); } else { points.Add(topRightOffset); } if (CustomExtensions.IsFlagSet(Corners, SegmentCorners.BottomRight)) { points.Add(bottomRight); } else { points.Add(rightCenter); points.Add(bottomRightOffset); } if (CustomExtensions.IsFlagSet(Corners, SegmentCorners.BottomLeft)) { points.Add(bottomLeft); } else { points.Add(bottomCenter); points.Add(bottomLeftOffset); } if (CustomExtensions.IsFlagSet(Corners, SegmentCorners.TopLeft)) { points.Add(topLeft); } m_path.AddLines(points.ToArray()); m_path.CloseFigure(); //these areas need to be redrawn now m_redrawRegion.Union(m_path); }