Exemple #1
0
        public override void Draw(CGRect rect)
        {
            const int padright = 21;
            var       ctx      = UIGraphics.GetCurrentContext();
            nfloat    boxWidth;
            CGSize    ssize = new CGSize();

            if (MessageCount > 0)
            {
                var ms = MessageCount.ToString();
                //TODO:revisar
//				ssize = StringSize (ms, CountFont);
                boxWidth = (nfloat)Math.Min((nfloat)22 + ssize.Width, (nfloat)18);
                var crect = new CGRect(Bounds.Width - 20 - boxWidth, 32, boxWidth, 16);

                UIColor.Gray.SetFill();
                GraphicsUtil.FillRoundedRect(ctx, crect, 3);
                UIColor.White.SetColor();
                crect.X += 5;
                ms.DrawString(crect, CountFont);

                boxWidth += padright;
            }
            else
            {
                boxWidth = 0;
            }

            UIColor.FromRGB(36, 112, 216).SetColor();
            var    diff = DateTime.Now - Date;
            var    now  = DateTime.Now;
            string label;

            if (now.Day == Date.Day && now.Month == Date.Month && now.Year == Date.Year)
            {
                label = Date.ToShortTimeString();
            }
            else if (diff <= TimeSpan.FromHours(24))
            {
                label = "Yesterday".GetText();
            }
            else if (diff < TimeSpan.FromDays(6))
            {
                label = Date.ToString("dddd");
            }
            else
            {
                label = Date.ToShortDateString();
            }
            ssize = label.StringSize(SubjectFont);
            nfloat dateSize = ssize.Width + padright + 5;

            label.DrawString(new CGRect(Bounds.Width - dateSize, 6, dateSize, 14), SubjectFont, UILineBreakMode.Clip, UITextAlignment.Left);

            const int offset = 33;
            nfloat    bw     = Bounds.Width - offset;

            UIColor.Black.SetColor();
            Sender.DrawString(new CGPoint(offset, 2), bw - dateSize, SenderFont, UILineBreakMode.TailTruncation);
            Subject.DrawString(new CGPoint(offset, 23), bw - offset - boxWidth, SubjectFont, UILineBreakMode.TailTruncation);

            //UIColor.Black.SetFill ();
            //ctx.FillRect (new CGRect (offset, 40, bw-boxWidth, 34));
            UIColor.Gray.SetColor();
            Body.DrawString(new CGRect(offset, 40, bw - boxWidth, 34), TextFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);

            if (NewFlag)
            {
                ctx.SaveState();
                ctx.AddEllipseInRect(new CGRect(10, 32, 12, 12));
                ctx.Clip();
                ctx.DrawLinearGradient(gradient, new CGPoint(10, 32), new CGPoint(22, 44), CGGradientDrawingOptions.DrawsAfterEndLocation);
                ctx.RestoreState();
            }

#if WANT_SHADOWS
            ctx.SaveState();
            UIColor.FromRGB(78, 122, 198).SetStroke();
            ctx.SetShadow(new CGPoint(1, 1), 3);
            ctx.StrokeEllipseInRect(new CGRect(10, 32, 12, 12));
            ctx.RestoreState();
#endif
        }