blob: dd2b224bc7167ab3d79640d75cce3130f224fcb3 (
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
73
74
75
76
77
78
79
80
81
82
|
using System;
using System.IO;
using AppKit;
using Foundation;
namespace Xamarin.PropertyEditing.Mac
{
public class HostResourceProvider
: IHostResourceProvider
{
public NSAppearance CurrentAppearance
{
get;
set;
}
public HostResourceProvider ()
{
var containingDir = Path.GetDirectoryName (typeof (HostResourceProvider).Assembly.Location);
var bundlePath = Path.Combine (containingDir, "PropertyEditingResource.bundle");
this.resourceBundle = new NSBundle (bundlePath);
}
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)
{
NSAppearance currentAppearance = CurrentAppearance ?? NSAppearance.CurrentAppearance;
if (currentAppearance != null && 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);
}
private readonly NSBundle resourceBundle;
}
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 FrameBoxBorderColor = "FrameBoxBorderColor";
public const string FrameBoxBackgroundColor = "FrameBoxBackgroundColor";
public const string FrameBoxButtonBorderColor = "FrameBoxButtonBorderColor";
public const string FrameBoxButtonBackgroundColor = "FrameBoxButtonBackgroundColor";
public const string ListHeaderSeparatorColor = "ListHeaderSeparatorColor";
public const string PanelTabBackground = "PanelTabBackground";
public const string ControlBackground = "ControlBackground";
}
}
|