Created
May 26, 2016 15:30
-
-
Save hieumoscow/b795bcbdee9d328b3ec3dce18e7ab64d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This file has been autogenerated from a class added in the UI designer. | |
using System; | |
using Foundation; | |
using UIKit; | |
using Mailbox; | |
using CoreGraphics; | |
namespace ios110 | |
{ | |
public partial class TableViewController : UITableViewController | |
{ | |
public TableViewController (IntPtr handle) : base (handle) | |
{ | |
} | |
EmailServer emailServer = new EmailServer(1000); | |
public override nint RowsInSection(UITableView tableview, nint section) | |
{ | |
return emailServer.Email.Count; | |
} | |
const string CellId = "EmailCell"; | |
const string Cell1Id = "EmailLeftCell"; | |
public override UITableViewCell GetCell(UITableView tableView, | |
NSIndexPath indexPath) | |
{ | |
Random r = new Random (); | |
string cid = (r.Next (0,1) > 0 ) ? CellId : Cell1Id; | |
UITableViewCell cell = tableView.DequeueReusableCell(cid); | |
// if (cell == null) { | |
// cell = new UITableViewCell(UITableViewCellStyle.Subtitle, CellId); | |
// cell.TextLabel.Font = UIFont.FromName("Helvetica Light", 14); | |
// cell.DetailTextLabel.Font = UIFont.FromName("Helvetica Light", 12); | |
// cell.DetailTextLabel.TextColor = UIColor.LightGray; | |
// cell.Accessory = UITableViewCellAccessory.DetailDisclosureButton; | |
// | |
// } else | |
if (cell.ImageView.Image != null) { | |
cell.ImageView.Image.Dispose(); | |
} | |
var item = emailServer.Email[indexPath.Row]; | |
cell.TextLabel.Text = item.Subject.Substring(0,20) + "..."; | |
cell.ImageView.Image = item.GetImage(); | |
cell.DetailTextLabel.Text = item.Body; | |
return cell; | |
} | |
public override void RowSelected (UITableView tableView, NSIndexPath indexPath) | |
{ | |
//base.RowSelected (tableView, indexPath); | |
// Create the View Controller in the Main storyboard. | |
var storyboard = UIStoryboard.FromName("Main", null); | |
var detailViewController = | |
(DetailViewController) storyboard.InstantiateViewController( | |
"DetailViewController"); | |
var item = emailServer.Email[indexPath.Row]; | |
detailViewController.Item = item; | |
ShowDetailViewController(detailViewController, this); | |
} | |
public override void AccessoryButtonTapped (UITableView tableView, NSIndexPath indexPath) | |
{ | |
var emailItem = emailServer.Email[indexPath.Row]; | |
var controller = UIAlertController.Create("Email Details", | |
emailItem.ToString(), UIAlertControllerStyle.Alert); | |
controller.AddAction(UIAlertAction.Create("OK", | |
UIAlertActionStyle.Default, null)); | |
PresentViewController(controller, true, null); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment