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
|
using System;
using System.Collections;
using System.Collections.Generic;
using AppKit;
using CoreGraphics;
namespace Xamarin.PropertyEditing.Mac
{
internal class BaseEditorControl : NSView
{
NSButton errorButton;
IEnumerable errorList;
public BaseEditorControl ()
{
errorButton = new NSButton () {
Bordered = false,
Enabled = false,
ImageScaling = NSImageScale.AxesIndependently,
Title = string.Empty,
TranslatesAutoresizingMaskIntoConstraints = false,
};
errorButton.Activated += (object sender, EventArgs e) => {
var Container = new ErrorMessageView (errorList) {
Frame = new CGRect (CGPoint.Empty, new CGSize (320, 200))
};
var errorMessagePopUp = new NSPopover {
Behavior = NSPopoverBehavior.Semitransient,
ContentViewController = new NSViewController (null, null) { View = Container },
};
errorMessagePopUp.Show (default (CGRect), errorButton, NSRectEdge.MinYEdge);
};
AddSubview (errorButton);
this.DoConstraints (new[] {
errorButton.ConstraintTo (this, (cb, c) => cb.Width == 20),
errorButton.ConstraintTo (this, (cb, c) => cb.Height == 20),
errorButton.ConstraintTo (this, (cb, c) => cb.Left == c.Right - 22),
errorButton.ConstraintTo (this, (cb, c) => cb.Top == c.Top + 4),
});
PropertyEditorPanel.ThemeManager.ThemeChanged += ThemeManager_ThemeChanged;
}
protected override void Dispose (bool disposing)
{
if (disposing) {
PropertyEditorPanel.ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged;
}
}
void ThemeManager_ThemeChanged (object sender, EventArgs e)
{
UpdateTheme ();
}
protected void UpdateTheme ()
{
this.Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance;
}
protected void SetErrors (IEnumerable errors)
{
errorList = errors;
errorButton.Enabled = errors != null;
// Using NSImageName.Caution for now, we can change this later at the designers behest
errorButton.Image = errorButton.Enabled ? NSImage.ImageNamed (NSImageName.Caution) : null;
}
}
}
|