JD2022-TU1/main/tools/framework/JD.Application.TeaBox/View/WindowLess/RectangleExtensions.cs

42 lines
No EOL
1.1 KiB
C#

using System.Drawing;
namespace JD.Application.View.WindowLess
{
/// <summary>
/// Adds functions to rectangle
/// </summary>
public static class DrawingExtensions
{
/// <summary>
/// Returns the union of both rectangles, but does consider the empty rectangle as the neutral value.
/// </summary>
public static Rectangle Union(this Rectangle a, Rectangle b)
{
if (Equals(a, Rectangle.Empty))
{
return b;
}
if (Equals(b, Rectangle.Empty))
{
return a;
}
return Rectangle.Union(a, b);
}
/// <summary>
/// Returns the union of both rectangles, but does consider the empty rectangle as the neutral value.
/// </summary>
public static RectangleF Union(this RectangleF a, RectangleF b)
{
if (Equals(a, RectangleF.Empty))
{
return b;
}
if (Equals(b, RectangleF.Empty))
{
return a;
}
return RectangleF.Union(a, b);
}
}
}