1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using System;
- using System.IO;
- namespace fis.Vid.Visuals
- {
- public class VinnoRect
- {
- public double Left { get; }
- public double Right { get; }
- public double Top { get; }
- public double Bottom { get; }
- public double Width => Math.Abs(Right - Left);
- public double Height => Math.Abs(Bottom - Top);
- public VinnoPoint TopLeft => new VinnoPoint(Left, Top);
- public VinnoPoint TopRight => new VinnoPoint(Right, Top);
- public VinnoPoint BottomLeft => new VinnoPoint(Left, Bottom);
- public VinnoPoint BottomRight => new VinnoPoint(Right, Bottom);
- public VinnoRect(double x, double y, double width, double height)
- {
- if ((width < 0.0) || (height < 0.0))
- {
- throw new ArgumentException("width and height can not less than 0.");
- }
- Left = x;
- Top = y;
- Right = Left + width;
- Bottom = Top + height;
- }
- public VinnoRect(VinnoPoint topLeft, VinnoPoint bottomRight)
- {
- Left = topLeft.X;
- Top = topLeft.Y;
- Right = bottomRight.X;
- Bottom = bottomRight.Y;
- }
- public static bool operator ==(VinnoRect rect1, VinnoRect rect2)
- {
- return ((((rect1.Left == rect2.Left) && (rect1.Right == rect2.Right)) && (rect1.Bottom == rect2.Bottom)) &&
- (rect1.Top == rect2.Top));
- }
- public static bool operator !=(VinnoRect rect1, VinnoRect rect2)
- {
- return !(rect1 == rect2);
- }
- public static bool Equals(VinnoRect rect1, VinnoRect rect2)
- {
- return ((((rect1.Left == rect2.Left) && (rect1.Right == rect2.Right)) && (rect1.Bottom == rect2.Bottom)) &&
- (rect1.Top == rect2.Top));
- }
- public override bool Equals(object o)
- {
- if ((o == null) || !(o is VinnoRect))
- {
- return false;
- }
- VinnoRect rect = (VinnoRect)o;
- return Equals(this, rect);
- }
- public bool Equals(VinnoRect value)
- {
- return Equals(this, value);
- }
- public override int GetHashCode()
- {
- return (((Left.GetHashCode() ^ Right.GetHashCode()) ^ Top.GetHashCode()) ^ Bottom.GetHashCode());
- }
- public override string ToString()
- {
- return $"L:{Left},R:{Right},T:{Top},B:{Bottom}";
- }
- }
- }
|