Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CommonImageBrush.cs « Drawing « Xamarin.PropertyEditing - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dd0132bb858881ae587a3e77dd39e15a62fc2753 (plain)
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
using System;

namespace Xamarin.PropertyEditing.Drawing
{
	/// <summary>
	/// Paints an area with an image.
	/// </summary>
	[Serializable]
	public sealed class CommonImageBrush : CommonTileBrush, IEquatable<CommonImageBrush>
	{
		public CommonImageBrush(
			string imageSource,
			CommonAlignmentX alignmentX,
			CommonAlignmentY alignmentY,
			CommonStretch stretch,
			CommonTileMode tileMode,
			CommonRectangle viewBox,
			CommonBrushMappingMode viewBoxUnits,
			CommonRectangle viewPort,
			CommonBrushMappingMode viewPortUnits,
			double opacity = 1.0)
			: base(alignmentX, alignmentY, stretch, tileMode, viewBox, viewBoxUnits, viewPort, viewPortUnits, opacity)
		{
			ImageSource = imageSource;
		}

		/// <summary>
		/// The image displayed by this ImageBrush.
		/// </summary>
		public string ImageSource { get; }

		public override bool Equals (object obj)
		{
			var brush = obj as CommonImageBrush;
			if (brush == null) return false;
			return Equals (brush);
		}

		public bool Equals (CommonImageBrush other)
		{
			return other != null &&
				   base.Equals (other) &&
				   ImageSource == other.ImageSource;
		}

		public static bool operator == (CommonImageBrush left, CommonImageBrush right) => Equals (left, right);
		public static bool operator != (CommonImageBrush left, CommonImageBrush right) => !Equals (left, right);

		public override int GetHashCode ()
		{
			var hashCode = base.GetHashCode ();
			hashCode = unchecked(hashCode * -1521134295 + ImageSource.GetHashCode());
			return hashCode;
		}
	}
}