-
Notifications
You must be signed in to change notification settings - Fork 7
/
SessionCell2.cs
111 lines (95 loc) · 2.94 KB
/
SessionCell2.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
using System;
using System.Drawing;
using Cirrious.Conference.UI.Touch.Bindings;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Cirrious.MvvmCross.Binding.Touch.Views;
using MonoTouch.ObjCRuntime;
namespace Cirrious.Conference.UI.Touch
{
public partial class SessionCell2 : MvxBindableTableViewCell
{
public static NSString Identifier = new NSString("SessionCell2");
public const string BindingText = @"
{'SpeakerText':{'Path':'Item.Session.Speaker'},
'MainText':{'Path':'Item.Session.Title'},
'RoomText':{'Path':'Item.Session','Converter':'SessionSmallDetails','ConverterParameter':'SmallDetailsFormat'},
'SelectedCommand':{'Path':'Command'},
'IsFavorite':{'Path':'Item.IsFavorite'}
}";
public static SessionCell2 LoadFromNib(NSObject owner)
{
// this bizarre loading sequence is modified from a blog post on AlexYork.net
// basically we create an empty cell in C#, then pass that through a NIB loading, which then magically
// gives us a new cell back in MonoTouch again
var views = NSBundle.MainBundle.LoadNib("SessionCell2", owner, null);
var cell2 = Runtime.GetNSObject( views.ValueAt(0) ) as SessionCell2;
views = null;
cell2.Initialise();
return cell2;
}
public SessionCell2(IntPtr handle)
: base(BindingText, handle)
{
}
public SessionCell2 ()
: base(BindingText, MonoTouch.UIKit.UITableViewCellStyle.Default, Identifier)
{
}
public SessionCell2 (string bindingText)
: base(bindingText, MonoTouch.UIKit.UITableViewCellStyle.Default, Identifier)
{
}
private void Initialise()
{
Image1.Image = UIImage.FromFile("ConfResources/Images/appbar.people.png");
Image2.Image = UIImage.FromFile("ConfResources/Images/appbar.city.png");
FavoritesButton.TouchDown += HandleFavoritesButtonTouchDown;
TitleLabel.Lines = 2;
TitleLabel.AdjustsFontSizeToFitWidth = false;
}
protected override void Dispose (bool disposing)
{
if (disposing)
{
// TODO - really not sure that Dispose is the right place for this call
// - but couldn't see how else to do this in a TableViewCell
ReleaseDesignerOutlets();
}
base.Dispose (disposing);
}
public event EventHandler PublicFavoritesButtonPressed;
void HandleFavoritesButtonTouchDown (object sender, EventArgs e)
{
var handler = PublicFavoritesButtonPressed;
if (handler != null)
handler(this, EventArgs.Empty);
}
public override string ReuseIdentifier
{
get
{
return Identifier.ToString();
}
}
public string MainText
{
get { return TitleLabel.Text; }
set { if (TitleLabel != null) TitleLabel.Text = value; }
}
public string SpeakerText
{
get { return Label1.Text; }
set { if (Label1 != null) Label1.Text = value; }
}
public string RoomText
{
get { return Label2.Text; }
set { if (Label2 != null) Label2.Text = value; }
}
public UIButton PublicFavoritesButton
{
get { return FavoritesButton; }
}
}
}