public override void Draw(RectangleF rect) { var context = UIGraphics.GetCurrentContext(); MessageBarStyleSheet styleSheet = StylesheetProvider.StyleSheetForMessageView(this); context.SaveState(); styleSheet.BackgroundColorForMessageType(MessageType).SetColor(); context.FillRect(rect); context.RestoreState(); context.SaveState(); context.BeginPath(); context.MoveTo(0, rect.Size.Height); context.SetStrokeColorWithColor(styleSheet.StrokeColorForMessageType(MessageType).CGColor); context.SetLineWidth(1); context.AddLineToPoint(rect.Size.Width, rect.Size.Height); context.StrokePath(); context.RestoreState(); context.SaveState(); float xOffset = Padding; float yOffset = Padding; if (!ShowFromBottom) { yOffset += GetStatusBarFrame().Height; } styleSheet.IconImageForMessageType(MessageType).Draw(new RectangleF(xOffset, yOffset, IconSize, IconSize)); context.SaveState(); yOffset -= TextOffset; xOffset += IconSize + Padding; SizeF titleLabelSize = TitleSize(); if (string.IsNullOrEmpty(Title) && !string.IsNullOrEmpty(Description)) { yOffset = (float)(Math.Ceiling((double)rect.Size.Height * 0.5) - Math.Ceiling((double)titleLabelSize.Height * 0.5) - TextOffset); } TitleColor.SetColor(); var titleRectangle = new RectangleF(xOffset, yOffset, titleLabelSize.Width, titleLabelSize.Height); Title.DrawString(titleRectangle, TitleFont, UILineBreakMode.TailTruncation, UITextAlignment.Left); yOffset += titleLabelSize.Height; SizeF descriptionLabelSize = DescriptionSize(); DescriptionColor.SetColor(); var descriptionRectangle = new RectangleF(xOffset, yOffset, descriptionLabelSize.Width, descriptionLabelSize.Height); Description.DrawString(descriptionRectangle, DescriptionFont, UILineBreakMode.TailTruncation, UITextAlignment.Left); }
public override void Draw(CGRect rect) { var context = UIGraphics.GetCurrentContext(); MessageBarStyleSheet styleSheet = StylesheetProvider.StyleSheetForMessageView(this); context.SaveState(); styleSheet.BackgroundColorForMessageType(MessageType).SetColor(); context.FillRect(rect); context.RestoreState(); context.SaveState(); context.BeginPath(); context.MoveTo(0, rect.Size.Height); context.SetStrokeColor(styleSheet.StrokeColorForMessageType(MessageType).CGColor); context.SetLineWidth(1); context.AddLineToPoint(rect.Size.Width, rect.Size.Height); context.StrokePath(); context.RestoreState(); context.SaveState(); nfloat xOffset = Padding; nfloat yOffset = Padding; var icon = styleSheet.IconImageForMessageType(MessageType); if (icon != null) { icon.Draw(new CGRect(xOffset, yOffset, IconSize, IconSize)); } context.SaveState(); yOffset -= TextOffset; xOffset += (icon == null ? 0 : IconSize) + Padding; CGSize titleLabelSize = TitleSize(); if (string.IsNullOrEmpty(Title) && !string.IsNullOrEmpty(Description)) { yOffset = (float)(Math.Ceiling((double)rect.Size.Height * 0.5) - Math.Ceiling((double)titleLabelSize.Height * 0.5) - TextOffset); } TitleColor.SetColor(); var titleRectangle = new CGRect(xOffset, yOffset, titleLabelSize.Width, titleLabelSize.Height); Title.DrawString(titleRectangle, new UIStringAttributes { Font = TitleFont, ForegroundColor = TitleColor }); yOffset += titleLabelSize.Height; CGSize descriptionLabelSize = DescriptionSize(); DescriptionColor.SetColor(); var descriptionRectangle = new CGRect(xOffset, yOffset, descriptionLabelSize.Width, descriptionLabelSize.Height); Description.DrawString(descriptionRectangle, new UIStringAttributes { Font = DescriptionFont, ForegroundColor = DescriptionColor }); }
/// <summary> /// Draws the view within the passed-in rectangle. /// </summary> /// <param name="rect"> /// The <see cref="T:System.Drawing.RectangleF"/> to draw. /// </param> public override void Draw(CGRect rect) { var context = UIGraphics.GetCurrentContext(); MessageBarStyleSheet styleSheet = this.StylesheetProvider.StyleSheetForMessageView(this); context.SaveState(); styleSheet.BackgroundColorForMessageType(this.MessageType).SetColor(); context.FillRect(rect); context.RestoreState(); context.SaveState(); context.BeginPath(); context.MoveTo(0, rect.Size.Height); context.SetStrokeColor(styleSheet.StrokeColorForMessageType(this.MessageType).CGColor); context.SetLineWidth(1); context.AddLineToPoint(rect.Size.Width, rect.Size.Height); context.StrokePath(); context.RestoreState(); context.SaveState(); nfloat xOffset = Padding; nfloat yOffset = Padding; styleSheet.IconImageForMessageType(this.MessageType) .Draw(new CGRect(xOffset, yOffset, this.iconSize, this.iconSize)); context.SaveState(); yOffset -= TextOffset; xOffset += this.iconSize + Padding; CGSize titleLabelSize = this.TitleSize(); CGSize descriptionLabelSize = this.DescriptionSize(); if (!this.HasTitle || !this.HasDescription) { yOffset = (float)(Math.Ceiling(rect.Size.Height * 0.5) - Math.Ceiling( (this.HasTitle ? titleLabelSize : descriptionLabelSize).Height * 0.5) - TextOffset); } if (this.HasTitle) { TitleColor.SetColor(); var titleRectangle = new CGRect(xOffset, yOffset, titleLabelSize.Width, titleLabelSize.Height); this.Title.DrawString(titleRectangle, TitleFont, UILineBreakMode.TailTruncation, UITextAlignment.Left); yOffset += titleLabelSize.Height; } if (this.HasDescription) { DescriptionColor.SetColor(); var descriptionRectangle = new CGRect( xOffset, yOffset, descriptionLabelSize.Width, descriptionLabelSize.Height); this.Description.DrawString( descriptionRectangle, DescriptionFont, UILineBreakMode.TailTruncation, UITextAlignment.Left); } }