public override void DrawRectangle(Rectangle area, Brush brush, Thickness thickness, double radius, Rectangle bounds) { SetClipArea(bounds); if (area != Rectangle.Empty) { if (radius > 0) { FillRectangle(area, brush, radius, bounds); } else { var areaXNA = area.ToXNA(); FillRect(new RectangleXNA(areaXNA.X, areaXNA.Top, areaXNA.Width, thickness.Top), brush); FillRect(new RectangleXNA(areaXNA.X, areaXNA.Top + thickness.Top, thickness.Left, areaXNA.Height - thickness.Top - thickness.Bottom), brush); FillRect(new RectangleXNA(areaXNA.Right - thickness.Right, areaXNA.Top + thickness.Top, thickness.Right, areaXNA.Height - thickness.Top - thickness.Bottom), brush); FillRect(new RectangleXNA(areaXNA.X, areaXNA.Bottom - thickness.Bottom, areaXNA.Width, thickness.Bottom), brush); } } ResetClipArea(); }
/// <summary> /// Draws a rounded rectangle within the specified area. /// </summary> public abstract void DrawRectangle(Rectangle area, Brush brush, Thickness border, double cornerRadius, Rectangle bounds);
/// <summary> /// Add the specified thickness to the size. /// </summary> public Size Add(Thickness thickness) => new Size(Math.Max(0, Width + thickness.Left + thickness.Right), Math.Max(0, Height + thickness.Top + thickness.Bottom));
/// <summary> /// Draws a rectangle within the specified area. /// </summary> public void DrawRectangle(Rectangle area, Brush brush, Thickness border, Rectangle bounds) => DrawRectangle(area, brush, border, 0, bounds);
/// <summary> /// Extend the rectangle to include the specified thickness. /// </summary> public Rectangle Extend(Thickness thickness) => new Rectangle(0, 0, thickness.Right + thickness.Left + Width, thickness.Bottom + thickness.Top + Height);
/// <summary> /// Remove the specified thickness from the size. /// </summary> public Size Remove(Thickness thickness) => new Size(Math.Max(0, Width - thickness.Left - thickness.Right), Math.Max(0, Height - thickness.Top - thickness.Bottom));
/// <summary> /// Remove the specified thickness from the rectangle to make it smaller. /// </summary> public Rectangle Remove(Thickness thickness) => new Rectangle(X -thickness.Left, Y - thickness.Right, Width -thickness.Width, Height - thickness.Height);
/// <summary> /// Add the specified thickness from the outsides of the rectangle in order to move the rectangle further outward. (SUBTRACTING from the X and Y values) /// </summary> public Rectangle AddBorder(Thickness borderThickness) => new Rectangle(X - borderThickness.Left, Y - borderThickness.Right, Width + borderThickness.Width, Height + borderThickness.Height);
/// <summary> /// Remove the specified thickness from the outsides of the rectangle in order to move the rectangle further inward. (ADDING to the X and Y values) /// </summary> public Rectangle RemoveBorder(Thickness borderThickness) => new Rectangle(X + borderThickness.Left, Y + borderThickness.Right, Width - borderThickness.Width, Height - borderThickness.Height);
public bool Equals(Thickness other) => Left == other.Left && Top == other.Top && Right == other.Right && Bottom == other.Bottom;
/// <summary> /// Add the left and top of the rectangle to the left and top of the thickness. /// </summary> public Thickness Offset(Thickness rectangle) => new Thickness(rectangle.Left + Left, rectangle.Top + Top, Right, Bottom);