/
KeyboardEnter.cs
79 lines (67 loc) · 2.25 KB
/
KeyboardEnter.cs
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
using System.Linq;
using System.Windows.Input;
using Xamarin.Forms;
namespace AsNum.XFControls.Effects {
public class KeyboardEnter {
#region Cmd
public static readonly BindableProperty CmdProperty =
BindableProperty.CreateAttached("Cmd",
typeof(ICommand),
typeof(KeyboardEnter),
null
);
public static ICommand GetCmd(BindableObject view) {
return (ICommand)view.GetValue(CmdProperty);
}
#endregion
#region Param
public static readonly BindableProperty ParamProperty =
BindableProperty.CreateAttached("Param",
typeof(object),
typeof(KeyboardEnter),
null
);
public static object GetParam(BindableObject view) {
return view.GetValue(ParamProperty);
}
#endregion
#region Type
public static readonly BindableProperty TypeProperty =
BindableProperty.CreateAttached("Type",
typeof(KeyboardEnterTypes?),
typeof(KeyboardEnter),
null,
propertyChanged: Changed);
public static void SetType(BindableObject view, KeyboardEnterTypes key) {
if (view is Entry)
view.SetValue(TypeProperty, key);
}
public static KeyboardEnterTypes GetType(BindableObject view) {
return (KeyboardEnterTypes)view.GetValue(TypeProperty);
}
private static void Changed(BindableObject bindable, object oldValue, object newValue) {
var view = (View)bindable;
if (view != null) {
var effect = view.Effects.FirstOrDefault(e => e is KeyboardEnterEffect);
if (effect == null) {
effect = new KeyboardEnterEffect();
view.Effects.Add(effect);
}
}
}
#endregion
class KeyboardEnterEffect : RoutingEffect {
public KeyboardEnterEffect()
: base("AsNum.KeyboardEnterEffect") {
}
}
}
public enum KeyboardEnterTypes {
Default,
Go,
Search,
Send,
Next,
Done
}
}