1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
using System;
namespace Xamarin.PropertyEditing.Drawing
{
/// <summary>
/// Paints an area with a solid color.
/// </summary>
[Serializable]
public class CommonSolidBrush : CommonBrush, IEquatable<CommonSolidBrush>
{
public CommonSolidBrush(CommonColor color, string colorSpace = null, double opacity = 1.0)
: base(opacity)
{
Color = color;
ColorSpace = colorSpace;
}
public CommonSolidBrush(byte r, byte g, byte b, byte a = 255, string colorSpace = null, double opacity = 1.0)
: this(new CommonColor(r, g, b, a), colorSpace, opacity) { }
/// <summary>
/// The color of the brush.
/// </summary>
public CommonColor Color { get; }
/// <summary>
/// The color space the brush is defined in.
/// </summary>
public string ColorSpace { get; }
public override bool Equals (object obj)
{
var brush = obj as CommonSolidBrush;
if (brush == null) return false;
return Equals(brush);
}
public bool Equals (CommonSolidBrush other)
{
return other != null &&
Color.Equals(other.Color) &&
ColorSpace == other.ColorSpace &&
Opacity == other.Opacity;
}
public static bool operator == (CommonSolidBrush left, CommonSolidBrush right) => Equals (left, right);
public static bool operator != (CommonSolidBrush left, CommonSolidBrush right) => !Equals (left, right);
public override int GetHashCode ()
{
var hashCode = base.GetHashCode ();
unchecked {
hashCode = hashCode * -1521134295 + Color.GetHashCode ();
if (ColorSpace != null)
hashCode = hashCode * -1521134295 + ColorSpace.GetHashCode ();
}
return hashCode;
}
}
}
|