Skip to content

Commit 30856d3

Browse files
committed
Fixed grid color selector by implementing Equals() for ColorItemViewModel
1 parent de181d6 commit 30856d3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Src/ScreenGrid.ViewModels/ColorItemViewModel.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace ScreenGrid.ViewModels
22
{
3+
using System;
34
using System.Linq;
45
using System.Windows.Media;
56

@@ -42,5 +43,25 @@ private static string GetColorName(Color color)
4243
.FirstOrDefault(p => (Color)p.GetValue(null, null) == color);
4344
return colorProperty != null ? colorProperty.Name : "???";
4445
}
46+
47+
public override bool Equals(Object obj)
48+
{
49+
return ((obj is ColorItemViewModel) && (this == (ColorItemViewModel)obj));
50+
}
51+
52+
public override int GetHashCode()
53+
{
54+
return this.color.GetHashCode();
55+
}
56+
57+
public static bool operator ==(ColorItemViewModel a, ColorItemViewModel b)
58+
{
59+
return (a.Color == b.Color);
60+
}
61+
62+
public static bool operator !=(ColorItemViewModel a, ColorItemViewModel b)
63+
{
64+
return (!(a == b));
65+
}
4566
}
4667
}

0 commit comments

Comments
 (0)