Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
DialogHelper.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.Widget;
6 
7 namespace MonoDroid.Dialog
8 {
9  public class DialogHelper
10  {
11  private Context context;
12  private RootElement formLayer;
13 
14  //public event Action<Section, Element> ElementClick;
15  //public event Action<Section, Element> ElementLongClick;
16 
17  public RootElement Root { get; set; }
18 
19  private DialogAdapter DialogAdapter { get; set; }
20 
21  public DialogHelper(Context context, ListView dialogView, RootElement root)
22  {
23  this.Root = root;
24  this.Root.Context = context;
25 
26  dialogView.Adapter = this.DialogAdapter = new DialogAdapter(context, this.Root);
27  dialogView.ItemClick += ListView_ItemClick;
28  // FIXME: should I comment out this? some branch seems to have done it.
29  dialogView.ItemLongClick += ListView_ItemLongClick;;
30  dialogView.Tag = root;
31  }
32 
33  void ListView_ItemLongClick (object sender, AdapterView.ItemLongClickEventArgs e)
34  {
35  var elem = this.DialogAdapter.ElementAtIndex(e.Position);
36  if (elem != null && elem.LongClick != null) {
37  elem.LongClick();
38  }
39  }
40 
41  void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
42  {
43  var elem = this.DialogAdapter.ElementAtIndex(e.Position);
44  if(elem != null)
45  elem.Selected();
46  }
47 
48  public void ReloadData()
49  {
50  if(Root == null) {
51  return;
52  }
53 
54  this.DialogAdapter.ReloadData();
55  }
56 
57  }
58 }
DialogHelper(Context context, ListView dialogView, RootElement root)
Definition: DialogHelper.cs:21