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

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

namespace Xamarin.PropertyEditing.Mac
{
	internal class DynamicFillBox
		: NSBox
	{
		public DynamicFillBox (IHostResourceProvider hostResources, string colorName)
		{
			this.hostResources = hostResources;
			BorderWidth = 0;
			BoxType = NSBoxType.NSBoxCustom;
			TranslatesAutoresizingMaskIntoConstraints = false;
			this.colorName = colorName;
			if (colorName == null)
				FillColor = NSColor.Clear;

			ViewDidChangeEffectiveAppearance ();
		}

		public string FillColorName
		{
			get => this.colorName;
			set
			{
				this.colorName = value;
				if (value == null)
					FillColor = NSColor.Clear;

				ViewDidChangeEffectiveAppearance ();
			}
		}

		public override void ViewDidChangeEffectiveAppearance ()
		{
			if (this.colorName == null)
				return;

			FillColor = this.hostResources.GetNamedColor (this.colorName);
		}

		private readonly IHostResourceProvider hostResources;
		private string colorName;
	}
}