Created
October 16, 2013 23:26
-
-
Save nicwise/7016758 to your computer and use it in GitHub Desktop.
Cell which has the image view moved to the top.
This file contains 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
using System; | |
using MonoTouch.Dialog; | |
using MonoTouch.UIKit; | |
using MonoTouch.Foundation; | |
using MonoTouch.CoreFoundation; | |
using MicroAgent.Common; | |
using System.Drawing; | |
namespace MicroAgent.Library | |
{ | |
public class BTMultilineDeadlineElement : ImageStringElement, IElementSizing | |
{ | |
static NSString skey = new NSString("BTMultilineDeadlineElement"); | |
Deadline deadline; | |
public BTMultilineDeadlineElement(Deadline deadline) : base("", null) | |
{ | |
this.deadline = deadline; | |
SizeF textSize = new NSString(deadline.DeadlineDate.ToString ("d MMM yyyy")).StringSize(UIFont.BoldSystemFontOfSize(16f), new SizeF(250, 999)); | |
SizeF detailSize = new NSString(deadline.Description).StringSize(UIFont.SystemFontOfSize(14f), new SizeF(250, 999)); | |
cellHeight = textSize.Height + detailSize.Height + 8 + 8; | |
} | |
public UIFont DetailFont; | |
public bool IsBold = false; | |
public UIColor DetailTextColor; | |
protected override NSString CellKey | |
{ | |
get | |
{ | |
return skey; | |
} | |
} | |
public override UITableViewCell GetCell (UITableView tv) | |
{ | |
var cell = tv.DequeueReusableCell (CellKey); | |
if (cell == null){ | |
cell = new TopImageTableViewCell (UITableViewCellStyle.Subtitle, CellKey); | |
cell.SelectionStyle = UITableViewCellSelectionStyle.None; | |
} | |
float indentSize = 36; | |
UILabel text = new UILabel(); | |
text.BackgroundColor = UIColor.Clear; | |
SizeF textSize = new NSString(deadline.DeadlineDate.ToString ("d MMM yyyy")).StringSize(UIFont.BoldSystemFontOfSize(16f), new SizeF(250, 999)); | |
text.TextAlignment = Alignment; | |
text.Text = deadline.DeadlineDate.ToString ("d MMM yyyy"); | |
text.Font = UIFont.BoldSystemFontOfSize(16f); | |
text.TextColor = Resources.UIBlack; | |
text.Frame = new RectangleF(indentSize,8,textSize.Width, textSize.Height); | |
cell.ImageView.Image = deadline.IsComplete ? Resources.TickBoxCheckedSmall : Resources.TickBoxUncheckedSmall; | |
cell.ImageView.ContentMode = UIViewContentMode.TopLeft; | |
UILabel detailtext = new UILabel(); | |
detailtext.BackgroundColor = UIColor.Clear; | |
SizeF detailSize = new NSString(deadline.Description).StringSize(UIFont.SystemFontOfSize(14f), new SizeF(250, 999)); | |
detailtext.Text = deadline.Description; | |
detailtext.TextColor = Resources.UIGrey; | |
detailtext.Font = UIFont.SystemFontOfSize(14f); | |
detailtext.Frame = new RectangleF(indentSize, textSize.Height + 8, 250,detailSize.Height); | |
detailtext.Lines = 7; | |
cell.ContentView.AddSubview(text); | |
cell.ContentView.AddSubview(detailtext); | |
return cell; | |
} | |
float cellHeight = 88f; | |
public float GetHeight (UITableView tableView, NSIndexPath indexPath) | |
{ | |
return cellHeight; | |
} | |
} | |
public class TopImageTableViewCell : UITableViewCell | |
{ | |
public TopImageTableViewCell(UITableViewCellStyle style, NSString key) : base(style, key) | |
{ | |
} | |
public override void LayoutSubviews () | |
{ | |
base.LayoutSubviews (); | |
ImageView.Frame = new RectangleF(10,10, this.ImageView.Image.Size.Width, this.ImageView.Image.Size.Height); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment