Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
StringElement.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Linq;
5 
6 using Android.App;
7 using Android.Content;
8 using Android.OS;
9 using Android.Views;
10 using Android.Widget;
11 using Android.Runtime;
12 
13 
14 namespace MonoDroid.Dialog
15 {
16  public class StringElement : Element
17  {
18  public int FontSize {get;set;}
19  public string Value
20  {
21  get { return _value; }
22  set { _value = value; if (_text != null) _text.Text = _value; }
23  }
24  private string _value;
25 
26  public object Alignment;
27 
28  public StringElement(string caption)
29  : base(caption, (int)DroidResources.ElementLayout.dialog_labelfieldright)
30  {
31  }
32 
33  public StringElement(string caption, int layoutId)
34  : base(caption, layoutId)
35  {
36  }
37 
38  public StringElement(string caption, string value)
39  : base(caption, (int)DroidResources.ElementLayout.dialog_labelfieldright)
40  {
41  Value = value;
42  }
43 
44 
45  public StringElement(string caption, string value, Action clicked)
46  : base(caption, (int)DroidResources.ElementLayout.dialog_labelfieldright)
47  {
48  Value = value;
49  this.Click = clicked;
50  }
51 
52  public StringElement(string caption, string value, int layoutId)
53  : base(caption, layoutId)
54  {
55  Value = value;
56  }
57 
58  public StringElement(string caption, Action clicked)
59  : base(caption, (int)DroidResources.ElementLayout.dialog_labelfieldright)
60  {
61  Value = null;
62  this.Click = clicked;
63  }
64 
65  public override View GetView(Context context, View convertView, ViewGroup parent)
66  {
67  View view = DroidResources.LoadStringElementLayout(context, convertView, parent, LayoutId, out _caption, out _text);
68  if (view != null)
69  {
70  var fontSize = FontSize > 0 ? FontSize : 21; // taken from dialog_textarea.xml
71  _caption.Text = Caption;
72  _caption.TextSize = fontSize;
73  _text.Text = Value;
74  _text.TextSize = fontSize;
75  if (Click != null)
76  view.Click += delegate { this.Click(); };
77  }
78  return view;
79  }
80 
81  public override void Selected ()
82  {
83  base.Selected ();
84 
85  if(this.Click != null) {
86  Click();
87  }
88  }
89 
90  public override string Summary()
91  {
92  return Value;
93  }
94 
95  public override bool Matches(string text)
96  {
97  return (Value != null ? Value.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) != -1 : false) ||
98  base.Matches(text);
99  }
100 
101  protected TextView _caption;
102  protected TextView _text;
103 
104  protected override void Dispose(bool disposing)
105  {
106  if (disposing)
107  {
108  //_caption.Dispose();
109  _caption = null;
110  //_text.Dispose();
111  _text = null;
112  }
113  }
114  }
115 }
StringElement(string caption, string value)
StringElement(string caption, string value, int layoutId)
override bool Matches(string text)
override void Dispose(bool disposing)
StringElement(string caption, int layoutId)
override View GetView(Context context, View convertView, ViewGroup parent)
Overriden my most derived classes, creates a view that creates a View with the contents for display ...
StringElement(string caption, string value, Action clicked)
override string Summary()
Returns a summary of the value represented by this object, suitable for rendering as the result of a ...
StringElement(string caption, Action clicked)