forked from Clancey/MonoDroid.Dialog
-
Notifications
You must be signed in to change notification settings - Fork 7
/
StringElement.cs
112 lines (97 loc) · 3.71 KB
/
StringElement.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
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
using System;
using Android.Content;
using Android.Views;
using Android.Widget;
namespace Android.Dialog
{
public class StringElement : Element
{
public int FontSize { get; set; }
public string Value
{
get { return _value; }
set { _value = value; if (_text != null) _text.Text = _value; }
}
private string _value;
public object Alignment;
public StringElement(string caption)
: base(caption, Resource.Layout.dialog_multiline_labelfieldbelow)
{
}
public StringElement(string caption, int layoutId)
: base(caption, layoutId)
{
}
public StringElement(string caption, string value)
: base(caption, Resource.Layout.dialog_multiline_labelfieldbelow)
{
Value = value;
}
public StringElement(string caption, string value, int layoutId)
: base(caption, layoutId)
{
Value = value;
}
public override View GetView(Context context, View convertView, ViewGroup parent)
{
var view = DroidResources.LoadStringElementLayout(context, convertView, parent, LayoutId, out _caption, out _text);
if (view != null && _caption != null && _text != null)
{
_caption.Text = Caption;
_caption.Visibility = Caption == null ? ViewStates.Gone : ViewStates.Visible;
_text.Text = Value;
if (FontSize > 0)
{
_caption.TextSize = FontSize;
_text.TextSize = FontSize;
}
}
return view;
}
public override string Summary()
{
return Value;
}
public override bool IsSelectable
{
get { return true; }
}
public override bool Matches(string text)
{
return Value != null && Value.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) != -1 || base.Matches(text);
}
protected TextView _caption;
protected TextView _text;
protected override void Dispose(bool disposing)
{
if (!disposing) return;
//_caption.Dispose();
_caption = null;
//_text.Dispose();
_text = null;
}
}
#region Compatibility classes
public class MultilineElement : StringElement
{
public MultilineElement(string caption) : base(caption) { }
public MultilineElement(string caption, int layoutId) : base(caption, layoutId) { }
public MultilineElement(string caption, string value) : base(caption, value) { }
public MultilineElement(string caption, string value, int layoutId) : base(caption, value, layoutId) { }
}
public class StringMultilineElement : StringElement
{
public StringMultilineElement(string caption) : base(caption) { }
public StringMultilineElement(string caption, int layoutId) : base(caption, layoutId) { }
public StringMultilineElement(string caption, string value) : base(caption, value) { }
public StringMultilineElement(string caption, string value, int layoutId) : base(caption, value, layoutId) { }
}
public class StyledMultilineElement : StringElement
{
public StyledMultilineElement(string caption) : base(caption) { }
public StyledMultilineElement(string caption, int layoutId) : base(caption, layoutId) { }
public StyledMultilineElement(string caption, string value) : base(caption, value) { }
public StyledMultilineElement(string caption, string value, int layoutId) : base(caption, value, layoutId) { }
}
#endregion
}