Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ProxyRowResponder.cs « Controls « Xamarin.PropertyEditing.Mac - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 406bde4a277b797f460a130f6dbddadc14f06f2f (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
using System;

namespace Xamarin.PropertyEditing.Mac
{
	internal enum ProxyRowType
	{
		SingleView,
		FirstView,
		LastView
	}

	internal class ProxyResponder 
	{
		protected WeakReference<PropertyEditorControl> editorControl;

		readonly ProxyRowType rowType;

		public ProxyResponder (PropertyEditorControl editorControl, ProxyRowType rowType)
		{
			this.rowType = rowType;
			this.editorControl = new WeakReference<PropertyEditorControl> (editorControl);
		}

		public bool NextResponder()
		{
			if (this.editorControl.TryGetTarget (out var editor))
			{
				if (this.rowType == ProxyRowType.LastView || this.rowType == ProxyRowType.SingleView) {
					editor.OnNextResponderRequested (false);
					return true;
				}
			}
			return false;
		}

		public bool PreviousResponder ()
		{
			if (this.editorControl.TryGetTarget (out var editor))
			{
				if (this.rowType == ProxyRowType.FirstView || this.rowType == ProxyRowType.SingleView) {
					editor.OnNextResponderRequested (true);
					return true;
				}
			}
			return false;
		}
	}
}