Inheritance: UITableViewCell
Beispiel #1
0
        public override UITableViewCell GetCell(UITableView tv)
        {
            var cellid = new NSString(Value == null ? "dialog.StringElement" : "dialog.StringElementValue");
            var cell   = (StringElementCell)tv.DequeueReusableCell(cellid);

            if (cell == null)
            {
                if (Value == null)
                {
                    cell = new StringElementCell(UITableViewCellStyle.Default, cellid);
                }
                else
                {
                    cell = new StringElementCell(this.CellStyle, cellid);
                }
            }

            cell.SelectionStyle                      = (Tapped != null || Sections.Count > 0) ? UITableViewCellSelectionStyle.Blue : UITableViewCellSelectionStyle.None;
            cell.Accessory                           = (Tapped != null || Sections.Count > 0)? CellAccessory : UITableViewCellAccessory.None;
            cell.ImageView.Image                     = Image;
            cell.TextLabel.Text                      = Caption;
            cell.TextLabel.MinimumFontSize           = 11;
            cell.TextLabel.AdjustsFontSizeToFitWidth = true;
            cell.TextLabel.TextAlignment             = Alignment;
            cell.TextLabel.Font                      = this.Appearance.LabelFont;
            cell.TextLabel.TextColor                 = this.Appearance.LabelTextColor; //this.ReadOnly ?  this.Appearance.DisabledLabelTextColor : this.Appearance.LabelTextColor;
            cell.TextLabel.HighlightedTextColor      = this.Appearance.LabelHighlightedTextColor;

            cell.BackgroundColor = this.ReadOnly ?  this.Appearance.BackgroundColorDisabled : this.Appearance.BackgroundColorEditable;

            if (cell.DetailTextLabel != null && !String.IsNullOrEmpty(Value))
            {
                cell.DetailTextLabel.Lines                     = 0;
                cell.DetailTextLabel.Font                      = this.Appearance.DetailLabelFont;
                cell.DetailTextLabel.TextColor                 = this.Appearance.DetailLabelTextColor; //this.ReadOnly ? this.Appearance.DisabledLabelTextColor :
                cell.DetailTextLabel.MinimumFontSize           = 11;
                cell.DetailTextLabel.AdjustsFontSizeToFitWidth = true;
                cell.DetailTextLabel.HighlightedTextColor      = this.Appearance.DetailLabelHighlightedTextColor;

                if (!ShowValueAsBadge)
                {
                    cell.DetailTextLabel.Text = Value == null ? "" : Value;
                    cell.ShowBadge            = false;
                }
                else
                {
                    var frame = cell.DetailTextLabel.Frame;
                    cell.ShowBadge       = true;
                    cell.BadgeLabel.Text = Value == null ? "" : Value;
                }
            }
            else
            {
                if (cell.DetailTextLabel != null)
                {
                    cell.DetailTextLabel.Text = "";
                }
            }
            return(cell);
        }
		public override UITableViewCell GetCell (UITableView tv)
		{
			var cellid = new NSString(Value==null ? "dialog.StringElement" : "dialog.StringElementValue");
			var cell = (StringElementCell)tv.DequeueReusableCell (cellid);
			if (cell == null){
				if (Value==null) 
					cell = new StringElementCell (UITableViewCellStyle.Default, cellid);
				else
					cell = new StringElementCell (this.CellStyle, cellid);
			}

			cell.SelectionStyle = (Tapped != null || Sections.Count>0) ? UITableViewCellSelectionStyle.Blue : UITableViewCellSelectionStyle.None;
			cell.Accessory = (Tapped != null || Sections.Count>0)? CellAccessory : UITableViewCellAccessory.None;
			cell.ImageView.Image = Image;
			cell.TextLabel.Text = Caption;
			cell.TextLabel.MinimumFontSize = 11;
			cell.TextLabel.AdjustsFontSizeToFitWidth = true;
			cell.TextLabel.TextAlignment = Alignment;
			cell.TextLabel.Font = this.Appearance.LabelFont;
			cell.TextLabel.TextColor = this.Appearance.LabelTextColor; //this.ReadOnly ?  this.Appearance.DisabledLabelTextColor : this.Appearance.LabelTextColor;
			cell.TextLabel.HighlightedTextColor = this.Appearance.LabelHighlightedTextColor;

			cell.BackgroundColor = this.ReadOnly ?  this.Appearance.BackgroundColorDisabled : this.Appearance.BackgroundColorEditable;
			
			if (cell.DetailTextLabel != null && !String.IsNullOrEmpty (Value)) {
				cell.DetailTextLabel.Lines = 0;
				cell.DetailTextLabel.Font = this.Appearance.DetailLabelFont;
				cell.DetailTextLabel.TextColor = this.Appearance.DetailLabelTextColor; //this.ReadOnly ? this.Appearance.DisabledLabelTextColor : 
				cell.DetailTextLabel.MinimumFontSize = 11;
				cell.DetailTextLabel.AdjustsFontSizeToFitWidth = true;
				cell.DetailTextLabel.HighlightedTextColor = this.Appearance.DetailLabelHighlightedTextColor;

				if (!ShowValueAsBadge) {
					cell.DetailTextLabel.Text = Value == null ? "" : Value;
					cell.ShowBadge = false;
				} else {
					var frame = cell.DetailTextLabel.Frame;
					cell.ShowBadge = true;
					cell.BadgeLabel.Text = Value == null ? "" : Value;
				}
			} else {
				if (cell.DetailTextLabel!=null) 
					cell.DetailTextLabel.Text = "";
			}
			return cell;
		}