Equality overrides

This commit is contained in:
glax 2024-04-15 22:06:27 +02:00
parent 2352e868bc
commit c445cbb6af
3 changed files with 51 additions and 0 deletions

View File

@ -28,4 +28,19 @@ public struct Point
{
return $"{{X={X,-7:####0}, Y={Y,-7:####0}}}";
}
public override bool Equals(object? obj)
{
return obj is Point other && Equals(other);
}
public bool Equals(Point other)
{
return X == other.X && Y == other.Y;
}
public override int GetHashCode()
{
return HashCode.Combine(X, Y);
}
}

View File

@ -17,6 +17,24 @@ public struct WindowInfo
this.WindowTitle = windowTitle;
}
public override bool Equals(object? obj)
{
return obj is WindowInfo other && Equals(other);
}
public bool Equals(WindowInfo other)
{
return WindowHandle == other.WindowHandle &&
WindowPlacement.Equals(other.WindowPlacement) &&
WindowTitle == other.WindowTitle &&
ProcessInfo.Equals(other.ProcessInfo);
}
public override int GetHashCode()
{
return HashCode.Combine(WindowHandle, WindowPlacement, WindowTitle, ProcessInfo);
}
public override string ToString()
{
const int cutoffStr = 17;

View File

@ -59,4 +59,22 @@ public struct WINDOWPLACEMENT
{
return $"CMD: {ShowCmd,13} Min: {MinPosition} Max: {MaxPosition} Normal: {NormalPosition}";
}
public override bool Equals(object? obj)
{
return obj is WindowPlacement other && Equals(other);
}
public bool Equals(WindowPlacement other)
{
return ShowCmd == other.ShowCmd &&
MinPosition.Equals(other.MinPosition) &&
MaxPosition.Equals(other.MaxPosition) &&
NormalPosition.Equals(other.NormalPosition);
}
public override int GetHashCode()
{
return HashCode.Combine((int)ShowCmd, MinPosition, MaxPosition, NormalPosition);
}
}