public IEnumerable<IBorderCharacter> GetBorderCharacters(Rectangle location) { if (Left != BorderType.None) { for (int i = location.Top; i <= location.Bottom; i++) { yield return BorderCharacter.LeftBorder(Left, new Point(location.Left, i)); } } if (Right != BorderType.None) { for (int i = location.Top; i <= location.Bottom; i++) { yield return BorderCharacter.RightBorder(Right, new Point(location.Right, i)); } } if (Top != BorderType.None) { for (int i = location.Left; i <= location.Right; i++) { yield return BorderCharacter.TopBorder(Top, new Point(i, location.Top)); } } if (Bottom != BorderType.None) { for (int i = location.Left; i <= location.Right; i++) { yield return BorderCharacter.BottomBorder(Bottom, new Point(i, location.Bottom)); } } }
private Rectangle GetPaddedBounds() { var left = Padding.Left + (Border.Left != BorderType.None ? 1 : 0); var right = Padding.Right + (Border.Right != BorderType.None ? 1 : 0) - 1; var top = Padding.Top + (Border.Top != BorderType.None ? 1 : 0); var bottom = Padding.Bottom + (Border.Bottom != BorderType.None ? 1 : 0) - 1; var paddedBounds = new Rectangle( Bounds.Left + left, Bounds.Top + top, Bounds.Width - right - left, Bounds.Height - bottom - top); return paddedBounds; }