-
Notifications
You must be signed in to change notification settings - Fork 2
/
TestTableSource.cs
97 lines (78 loc) · 3.35 KB
/
TestTableSource.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
using System;
using System.Drawing;
using System.Collections.Generic;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace LWSlideViewController
{
public class TestTableSource : UITableViewSource
{
private List<string> MenuOptions = new List<string>(5){"Spiderman","Batman","Superman","Deadpool", "Jimmy Dizzle"};
private List<string> ImageNames = new List<string>(5){"Images/spiderman.jpeg","Images/batman.jpeg","Images/superman.jpeg","Images/deadpool.jpeg","Images/doos.png"};
private NSString kCellID = new NSString("tableCell");
public delegate void RowSelectedDelegate(string name);
public event RowSelectedDelegate RowSelectedEvent;
public TestTableSource ()
{
}
public override int RowsInSection (UITableView tableview, int section)
{
return MenuOptions.Count;
}
public override string TitleForHeader (UITableView tableView, int section)
{
return "Superheroes";
}
public override UIView GetViewForHeader (UITableView tableView, int section)
{
string title = "Superheroes";
if (string.IsNullOrEmpty(title))
return null;
UIImageView imageView = new UIImageView(new RectangleF(0,0,tableView.Bounds.Size.Width, 22));
imageView.Image = UIImage.FromFile("Images/section_background.png");
imageView.Image.StretchableImage(0,0);
UILabel titleLabel = new UILabel(RectangleF.Inflate(imageView.Frame, -10f,0));
titleLabel.Font = UIFont.FromName("Helvetica-Bold", 12f);
titleLabel.TextAlignment = UITextAlignment.Left;
titleLabel.TextColor = UIColor.FromRGBA(125f/255f, 129f/255f, 146f/255f, 1f);
titleLabel.ShadowColor = UIColor.FromRGBA(40f/255f, 45f/255f, 57f/255, 1f);
titleLabel.ShadowOffset = new SizeF(0,1);
titleLabel.BackgroundColor = UIColor.Clear;
titleLabel.Text = title;
imageView.AddSubview(titleLabel);
return imageView;
}
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell cell = tableView.DequeueReusableCell(kCellID);
if (cell == null)
{
cell = new UITableViewCell(UITableViewCellStyle.Value1, kCellID);
}
UIImageView background = new UIImageView(new RectangleF(0,0,320,44));
background.Image = UIImage.FromFile("Images/cell_background.png");
background.Image.StretchableImage(0,0);
cell.BackgroundView = background;
UIImageView selectedBackground = new UIImageView(new RectangleF(0,0,320,44));
selectedBackground.Image = UIImage.FromFile("Images/cell_selected_background.png");
selectedBackground.Image.StretchableImage(0,0);
cell.SelectedBackgroundView = selectedBackground;
cell.TextLabel.TextColor = UIColor.FromRGBA(190f/255f,197f/255f,212f/255f,1f);
cell.TextLabel.HighlightedTextColor = cell.TextLabel.TextColor;
cell.TextLabel.ShadowColor = UIColor.FromRGBA(33f/255f,38f/255f,49f/255f,1f);
cell.TextLabel.ShadowOffset = new SizeF(0f,1f);
cell.TextLabel.BackgroundColor = UIColor.Clear;
cell.TextLabel.Font = UIFont.FromName("Helvetica", 16f);
cell.ImageView.Image = UIImage.FromFile(ImageNames[indexPath.Row]);
cell.ImageView.ClipsToBounds = true;
cell.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
cell.TextLabel.Text = MenuOptions[indexPath.Row];
return cell;
}
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
if (RowSelectedEvent != null)
RowSelectedEvent(MenuOptions[indexPath.Row]);
}
}
}