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

HostResourceProvider.cs « Xamarin.PropertyEditing.Mac - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d205da5dc1aa7dbc52408f3d7d5c14552740d9e6 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using AppKit;
using Foundation;

namespace Xamarin.PropertyEditing.Mac
{
	public class HostResourceProvider
		: IHostResourceProvider
	{
		public NSAppearance CurrentAppearance
		{
			get;
			set;
		}

		private readonly NSBundle resourceBundle;

		public HostResourceProvider ()
		{
			this.resourceBundle = new NSBundle ("../../../PropertyEditingResource.bundle");
		}

		public virtual NSAppearance GetVibrantAppearance (NSAppearance appearance)
		{
			if (appearance == null)
				throw new ArgumentNullException (nameof (appearance));

			if (appearance.Name == NSAppearance.NameDarkAqua || appearance.Name == NSAppearance.NameVibrantDark)
				return NSAppearance.GetAppearance (NSAppearance.NameVibrantDark);

			return NSAppearance.GetAppearance (NSAppearance.NameVibrantLight);
		}

		public virtual NSColor GetNamedColor (string name)
		{
			return NSColor.FromName (name);
		}

		public virtual NSImage GetNamedImage (string name)
		{
			if ((CurrentAppearance ?? NSAppearance.CurrentAppearance).Name.ToLower ().Contains ("dark")) {
				bool sel = name.EndsWith ("~sel");
				if (sel)
					name = name.Substring (0, name.Length - 4);

				name += "~dark";

				if (sel)
					name += "~sel";
			}

			return this.resourceBundle.ImageForResource (name);
		}

		public virtual NSFont GetNamedFont (string name, nfloat fontSize)
		{
			return NSFont.FromFontName (name, fontSize);
		}
	}

	public static class NamedResources
	{
		public const string Checkerboard0Color = "Checkerboard0";
		public const string Checkerboard1Color = "Checkerboard1";
		public const string ForegroundColor = "ForegroundColor";
		public const string PadBackgroundColor = "PadBackgroundColor";
		public const string DescriptionLabelColor = "DescriptionLabelColor";
		public const string ValueBlockBackgroundColor = "ValueBlockBackgroundColor";
		public const string TabBorderColor = "TabBorderColor";
		public const string PanelTabBackground = "PanelTabBackground";
	}
}