Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
FloatElement.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 Android.Content;
5 using Android.Graphics;
6 using Android.Util;
7 using Android.Views;
8 using Android.Widget;
9 
10 namespace MonoDroid.Dialog
11 {
12  public class FloatElement : Element, SeekBar.IOnSeekBarChangeListener
13  {
14  public bool ShowCaption;
15  public int Value;
16  public int MinValue, MaxValue;
17  public Bitmap Left;
18  public Bitmap Right;
19 
20  public FloatElement(string caption)
21  : this(caption, (int)DroidResources.ElementLayout.dialog_floatimage)
22  {
23  Value = 0;
24  MinValue = 0;
25  MaxValue = 10;
26  }
27 
28  public FloatElement(string caption, int layoutId)
29  : base(caption, layoutId)
30  {
31  Value = 0;
32  MinValue = 0;
33  MaxValue = 10;
34  }
35 
36  public FloatElement(Bitmap left, Bitmap right, int value)
37  : this(left, right, value, (int)DroidResources.ElementLayout.dialog_floatimage)
38  {
39  }
40 
41  public FloatElement(Bitmap left, Bitmap right, int value, int layoutId)
42  : base(string.Empty, layoutId)
43  {
44  Left = left;
45  Right = right;
46  MinValue = 0;
47  MaxValue = 10;
48  Value = value;
49  }
50 
51  public override View GetView(Context context, View convertView, ViewGroup parent)
52  {
53  TextView label;
54  SeekBar slider;
55  ImageView left;
56  ImageView right;
57 
58  View view = DroidResources.LoadFloatElementLayout(context, convertView, parent, LayoutId, out label, out slider, out left, out right);
59 
60  if (view != null)
61  {
62  if (left != null)
63  {
64  if (Left != null)
65  left.SetImageBitmap(Left);
66  else
67  left.Visibility = ViewStates.Gone;
68  }
69  if (right != null)
70  {
71  if (Right != null)
72  right.SetImageBitmap(Right);
73  else
74  right.Visibility = ViewStates.Gone;
75  }
76  slider.Max = MaxValue - MinValue;
77  slider.Progress = Value - MinValue;
78  slider.SetOnSeekBarChangeListener(this);
79  if (label != null)
80  {
81  if (ShowCaption)
82  label.Text = Caption;
83  else
84  label.Visibility = ViewStates.Gone;
85  }
86  }
87  else
88  {
89  Android.Util.Log.Error("FloatElement", "GetView failed to load template view");
90  }
91 
92  return view;
93  }
94 
95  void SeekBar.IOnSeekBarChangeListener.OnProgressChanged(SeekBar seekBar, int progress, bool fromUser)
96  {
97  Value = MinValue + progress;
98  }
99 
100  void SeekBar.IOnSeekBarChangeListener.OnStartTrackingTouch(SeekBar seekBar)
101  {
102  }
103 
104  void SeekBar.IOnSeekBarChangeListener.OnStopTrackingTouch(SeekBar seekBar)
105  {
106  }
107  }
108 }
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 ...
Definition: FloatElement.cs:51
FloatElement(string caption, int layoutId)
Definition: FloatElement.cs:28
FloatElement(Bitmap left, Bitmap right, int value)
Definition: FloatElement.cs:36
FloatElement(string caption)
Definition: FloatElement.cs:20
FloatElement(Bitmap left, Bitmap right, int value, int layoutId)
Definition: FloatElement.cs:41