blob: 0736e25f987063b5da50cafbf80550227120ccca (
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
|
using System;
using System.Collections;
using System.Diagnostics;
using AppKit;
using CoreGraphics;
using Foundation;
using Xamarin.PropertyEditing.Mac.Resources;
using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Mac
{
internal abstract class BaseNumericEditorControl : PropertyEditorControl
{
public BaseNumericEditorControl ()
{
base.TranslatesAutoresizingMaskIntoConstraints = false;
NumericEditor = new NumericSpinEditor ();
AddSubview (NumericEditor);
this.DoConstraints ( new[] {
NumericEditor.ConstraintTo (this, (n, c) => n.Top == c.Top + 1),
NumericEditor.ConstraintTo (this, (n, c) => n.Left == c.Left + 4),
NumericEditor.ConstraintTo (this, (n, c) => n.Width == c.Width - 33),
});
}
protected NumericSpinEditor NumericEditor { get; set; }
protected NSNumberFormatter Formatter {
get {
return NumericEditor.Formatter;
}
set {
NumericEditor.Formatter = value;
}
}
public override NSView FirstKeyView => NumericEditor;
public override NSView LastKeyView => NumericEditor;
protected NSNumberFormatterStyle NumberStyle {
get {
return NumericEditor.NumberStyle; }
set {
NumericEditor.NumberStyle = value;
}
}
protected override void UpdateErrorsDisplayed (IEnumerable errors)
{
if (ViewModel.HasErrors) {
SetErrors (errors);
} else {
SetErrors (null);
SetEnabled ();
}
}
protected override void HandleErrorsChanged (object sender, System.ComponentModel.DataErrorsChangedEventArgs e)
{
UpdateErrorsDisplayed (ViewModel.GetErrors (ViewModel.Property.Name));
}
protected override void SetEnabled ()
{
NumericEditor.Editable = ViewModel.Property.CanWrite;
}
protected override void UpdateAccessibilityValues ()
{
NumericEditor.AccessibilityEnabled = NumericEditor.Enabled;
NumericEditor.AccessibilityTitle = string.Format (LocalizationResources.AccessibilityNumeric, ViewModel.Property.Name);
}
}
}
|