public bool Equals(Pen pen)
{
// ReSharper disable once CompareOfFloatsByEqualityOperator
if (Width != pen.Width)
{
return false;
}
if ((Color == null) ^ (pen.Color == null)) //if one or the other is null then they are not equal, but not when they are both null
{
return false;
}
if (Color != null && !Color.Equals(pen.Color))
{
return false;
}
return true;
}