Пример #1
0
        public override void Draw(RectangleF rect)
        {
            const int padright = 21;
            var       ctx      = UIGraphics.GetCurrentContext();
            float     boxWidth;
            SizeF     ssize;

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

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

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

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

            if (DateTime.Now.Day == Date.Day)
            {
                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 = StringSize(label, SubjectFont);
            float dateSize = ssize.Width + padright + 5;

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

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

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

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

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

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