blob: 21f475335848e5eb698fd6df5d18bf75aaf0b9f8 (
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
using System;
using System.ComponentModel;
using AppKit;
using CoreGraphics;
using Foundation;
using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Mac
{
internal class NotifyingView<TViewModel> : NSView, INotifyingListner<TViewModel> where TViewModel : NotifyingObject
{
internal TViewModel ViewModel
{
get => Adaptor.ViewModel;
set => Adaptor.ViewModel = value;
}
public NotifyingView ()
{
Adaptor = new NotifyingViewAdaptor<TViewModel> (this);
}
public NotifyingView (CGRect frame) : base (frame)
{
Adaptor = new NotifyingViewAdaptor<TViewModel> (this);
}
public NotifyingView (IntPtr handle) : base (handle)
{
}
[Export ("initWithCoder:")]
public NotifyingView (NSCoder coder) : base (coder)
{
}
protected NotifyingViewAdaptor<TViewModel> Adaptor { get; }
public virtual void OnViewModelChanged (TViewModel oldModel)
{
}
public virtual void OnPropertyChanged (object sender, PropertyChangedEventArgs e)
{
}
protected virtual void AppearanceChanged ()
{
}
public sealed override void ViewDidChangeEffectiveAppearance ()
{
base.ViewDidChangeEffectiveAppearance ();
AppearanceChanged ();
}
}
internal abstract class ColorEditorView : NotifyingView<SolidBrushViewModel>
{
protected const float Padding = 3;
public ColorEditorView (IntPtr handle) : base (handle)
{
}
public ColorEditorView (NSCoder coder) : base (coder)
{
}
public ColorEditorView (CGRect frame) : base (frame)
{
}
public ColorEditorView ()
{
}
public new SolidBrushViewModel ViewModel {
get => Adaptor.ViewModel;
set => Adaptor.ViewModel = value;
}
public override void OnViewModelChanged (SolidBrushViewModel oldModel)
{
OnPropertyChanged (ViewModel, new PropertyChangedEventArgs (nameof (SolidBrushViewModel.Color)));
}
public override void MouseDragged (NSEvent theEvent)
{
//base.MouseDragged (theEvent);
UpdateFromEvent (theEvent);
}
public override void MouseDown (NSEvent theEvent)
{
//base.MouseDown (theEvent);
UpdateFromEvent (theEvent);
}
public virtual void UpdateFromEvent (NSEvent theEvent)
{
}
protected override void Dispose (bool disposing)
{
base.Dispose (disposing);
if (!disposing)
return;
Adaptor.Dispose ();
}
}
}
|