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

CommonBrushView.cs « Custom « Controls « Xamarin.PropertyEditing.Mac - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d637b6d1b3a6a49f711c1c8dc09915394e4f14fc (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
using System;
using AppKit;
using CoreGraphics;
using Xamarin.PropertyEditing.Drawing;

namespace Xamarin.PropertyEditing.Mac
{
	internal class CommonBrushView
		: NSView, IValueView
	{
		public CommonBrush Brush {
			get => (Layer as CommonBrushLayer)?.Brush;
			set => (Layer as CommonBrushLayer).Brush = value;
		}

		NSView IValueView.NativeView => this;

		public CommonBrushView ()
		{
			Initialize ();
		}

		public CommonBrushView (CGRect frame) : base (frame)
		{
			Initialize ();
		}

		public CommonBrushView (IntPtr handle) : base (handle)
		{
		}

		void IValueView.SetValue (object value)
		{
			var brush = value as CommonBrush;
			if (value != null && brush == null)
				throw new ArgumentException (nameof (value));

			Brush = brush;
		}

		private void Initialize () {
			WantsLayer = true;
			Layer = new CommonBrushLayer
			{
				Brush = Brush
			};
		}
    }
}