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
|
using System;
using AppKit;
using CoreGraphics;
namespace Xamarin.PropertyEditing.Mac
{
internal class BasePopOverControl : NSView
{
const int DefaultIconButtonSize = 32;
public BasePopOverControl (string title, string imageNamed) : base ()
{
if (title == null)
throw new ArgumentNullException (nameof (title));
if (imageNamed == null)
throw new ArgumentNullException (nameof (imageNamed));
TranslatesAutoresizingMaskIntoConstraints = false;
WantsLayer = true;
var iconView = new NSImageView {
Image = NSImage.ImageNamed (imageNamed),
TranslatesAutoresizingMaskIntoConstraints = false,
};
iconView.Image = NSImage.ImageNamed (PropertyEditorPanel.ThemeManager.Theme == Themes.PropertyEditorTheme.Dark ? imageNamed + "~dark" : imageNamed);
AddSubview (iconView);
var viewTitle = new UnfocusableTextField () {
StringValue = title,
TranslatesAutoresizingMaskIntoConstraints = false,
Font = NSFont.BoldSystemFontOfSize(11)
};
AddSubview (viewTitle);
this.DoConstraints (new[] {
iconView.ConstraintTo (this, (iv, c) => iv.Top == c.Top + 5),
iconView.ConstraintTo (this, (iv, c) => iv.Left == c.Left + 5),
iconView.ConstraintTo (this, (iv, c) => iv.Width == DefaultIconButtonSize),
iconView.ConstraintTo (this, (iv, c) => iv.Height == DefaultIconButtonSize),
viewTitle.ConstraintTo (this, (vt, c) => vt.Top == c.Top + 10),
viewTitle.ConstraintTo (this, (vt, c) => vt.Left == c.Left + 38),
viewTitle.ConstraintTo (this, (vt, c) => vt.Width == 120),
viewTitle.ConstraintTo (this, (vt, c) => vt.Height == 24),
});
this.Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance;
}
}
}
|