MonoMobile.Views.ComposableViewListCell.Draw C# (CSharp) Method

Draw() public method

public Draw ( RectangleF rect ) : void
rect System.Drawing.RectangleF
return void
		public override void Draw(RectangleF rect)
		{
			if (ListSource != null)
			{
				Theme.Cell = this;
				 
				TextLabel.BackgroundColor = UIColor.Clear;
				if (DetailTextLabel != null)
					DetailTextLabel.BackgroundColor = UIColor.Clear;

				if (ListSource.IsRootCell)
				{
					Accessory = UITableViewCellAccessory.DisclosureIndicator;
					TextLabel.Text = ListSource.Caption;
					
					if (ListSource.IsMultiselect && DetailTextLabel != null)
					{
						DetailTextLabel.Text = ListSource.SelectedItems.Count.ToString();
					}
					else
					{
						if (ListSource.SelectedItem != null)
						{
							if (ListSource.ReplaceCaptionWithSelection)
							{
								TextLabel.Text = ListSource.SelectedItem.ToString();
							}
							else if (DetailTextLabel != null)
							{
								DetailTextLabel.Text = ListSource.SelectedItem.ToString();
							}
						}
					}
				}
				else
				{
					var sectionData = ListSource.GetSectionData(0);
					if (sectionData.Count > 0 && IndexPath.Row < sectionData.Count)
					{
						TextLabel.Text = sectionData[IndexPath.Row].ToString();
					}
				}
			}
	
			var resizedRows = false;

			if (ViewList != null)
			{
				foreach (var view in ViewList)
				{
					var sectionData = ListSource.GetSectionData(0);
					if (sectionData != null && sectionData.Count > 0)
					{
						var data = sectionData[IndexPath.Row];
						var dc = view as IDataContext<object>;
						if (dc != null)
						{
							dc.DataContext = data;
						}
	
						if (dc == null)
						{
							var valueMember = view.GetType().GetProperty("Value");
							if (valueMember != null && data.GetType().IsAssignableFrom(valueMember.PropertyType))
							{
								valueMember.SetValue(view, data);
							}
							else
							{
								var dataContextMember = view.GetType().GetProperty("DataContext");
								if (dataContextMember != null && data.GetType().IsAssignableFrom(dataContextMember.PropertyType))
								{
									dataContextMember.SetValue(view, data);
								}
							}
						}
	
						var updateable = view as IUpdateable;
						if (updateable != null)
						{
							updateable.UpdateCell(this, IndexPath);
						}
				
						var rowHeight = 0f;
						var themeable = view as IThemeable;
						if (themeable != null)
						{			
							themeable.ApplyTheme(this);
							if (themeable.Theme != null && themeable.Theme.CellHeight > 0)
							{
								rowHeight = themeable.Theme.CellHeight;
							}
						}
	
						var sizeable = view as ISizeable;
						if (sizeable != null)
						{
							rowHeight = sizeable.GetRowHeight();
						}
						
						if (rowHeight > 0 && ListSource.RowHeights[ListSource.BaseIndexPath] != rowHeight)
						{
							if (ListSource.RowHeights.ContainsKey(IndexPath))
							{
								if (ListSource.RowHeights[IndexPath] != rowHeight)
								{
									ListSource.RowHeights[IndexPath] = rowHeight;
									resizedRows = true;
								}
							}
							else
							{
								ListSource.RowHeights.Add(IndexPath, rowHeight);
								resizedRows = true;
							}
						}
	
						var customDraw = view as ICustomDraw;
						if (customDraw != null)
						{
							customDraw.Draw(rect);
						}
					}
				}

				if (resizedRows)
				{
					new Wait(TimeSpan.FromMilliseconds(0), () =>
					{
						ListSource.Controller.TableView.BeginUpdates();
						ListSource.Controller.TableView.EndUpdates();
					});
				}
			}
		}