Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
FormattedElement.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 Apache 2.0 License. See LICENSE.md for details.
3 //
4 // Copyright 2011-2012 Xamarin Inc.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 using System;
20 
21 using Android.Content;
22 using Android.Views;
23 using Android.Widget;
24 
25 using MonoDroid.Dialog;
26 
27 namespace Android.NUnitLite.UI {
28 
30 
31  private new TextView _caption;
32  private new TextView _text;
33 
34  public FormattedElement (string caption) : base (caption)
35  {
36  }
37 
38  public string Indicator {
39  get; set;
40  }
41 
42  public override View GetView (Context context, View convertView, ViewGroup parent)
43  {
44  var view = convertView as RelativeLayout;
45 
46  if (view == null)
47  view = new RelativeLayout(context);
48 
49  var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
50  ViewGroup.LayoutParams.WrapContent);
51  parms.SetMargins(5, 3, 5, 0);
52  parms.AddRule(LayoutRules.AlignParentLeft);
53 
54  _caption = new TextView (context);
55  SetCaption (Caption);
56  view.RemoveAllViews();
57  view.AddView(_caption, parms);
58 
59  if (!String.IsNullOrWhiteSpace (Indicator)) {
60  var tparms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
61  ViewGroup.LayoutParams.WrapContent);
62  tparms.SetMargins(5, 3, 5, 5);
63  tparms.AddRule(LayoutRules.CenterVertical);
64  tparms.AddRule(LayoutRules.AlignParentRight);
65 
66  _text = new TextView (context) {
67  Text = Indicator,
68  TextSize = 22f
69  };
70  view.AddView(_text, tparms);
71  }
72  return view;
73  }
74 
75  public void SetCaption (string html)
76  {
77  _caption.SetText (Android.Text.Html.FromHtml (html), TextView.BufferType.Spannable);
78  }
79  }
80 }
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 ...