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
|
using System;
using Xamarin.Forms.Platform;
namespace Xamarin.Forms
{
[RenderWith(typeof(_EditorRenderer))]
public class Editor : InputView, IEditorController, IFontElement, ITextElement, IElementConfiguration<Editor>
{
public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(Editor), null, BindingMode.TwoWay, propertyChanged: (bindable, oldValue, newValue) =>
{
var editor = (Editor)bindable;
if (editor.TextChanged != null)
editor.TextChanged(editor, new TextChangedEventArgs((string)oldValue, (string)newValue));
});
public static readonly BindableProperty FontFamilyProperty = FontElement.FontFamilyProperty;
public static readonly BindableProperty FontSizeProperty = FontElement.FontSizeProperty;
public static readonly BindableProperty FontAttributesProperty = FontElement.FontAttributesProperty;
public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
readonly Lazy<PlatformConfigurationRegistry<Editor>> _platformConfigurationRegistry;
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
public Color TextColor
{
get { return (Color)GetValue(TextElement.TextColorProperty); }
set { SetValue(TextElement.TextColorProperty, value); }
}
public FontAttributes FontAttributes
{
get { return (FontAttributes)GetValue(FontAttributesProperty); }
set { SetValue(FontAttributesProperty, value); }
}
public string FontFamily
{
get { return (string)GetValue(FontFamilyProperty); }
set { SetValue(FontFamilyProperty, value); }
}
[TypeConverter(typeof(FontSizeConverter))]
public double FontSize
{
get { return (double)GetValue(FontSizeProperty); }
set { SetValue(FontSizeProperty, value); }
}
void IFontElement.OnFontFamilyChanged(string oldValue, string newValue)
{
}
void IFontElement.OnFontSizeChanged(double oldValue, double newValue)
{
}
void IFontElement.OnFontChanged(Font oldValue, Font newValue)
{
}
double IFontElement.FontSizeDefaultValueCreator() =>
Device.GetNamedSize(NamedSize.Default, (Editor)this);
void IFontElement.OnFontAttributesChanged(FontAttributes oldValue, FontAttributes newValue)
{
}
public event EventHandler Completed;
public event EventHandler<TextChangedEventArgs> TextChanged;
public Editor()
{
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Editor>>(() => new PlatformConfigurationRegistry<Editor>(this));
}
public IPlatformElementConfiguration<T, Editor> On<T>() where T : IConfigPlatform
{
return _platformConfigurationRegistry.Value.On<T>();
}
void IEditorController.SendCompleted()
{
EventHandler handler = Completed;
if (handler != null)
handler(this, EventArgs.Empty);
}
void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
{
}
}
}
|