Пример #1
0
        /// <summary>
        /// Compute the display rectangles for the various field elements of the given message
        /// </summary>
        private DrawRectElements ComputeDrawRectElements(Graphics graphics, CIXMessage message, Rectangle bounds)
        {
            DrawRectElements drawRectElements = new DrawRectElements();
            Rectangle drawRect = bounds;

            // Indent for conversations
            int indent = IndentForItem(message);
            drawRect.X += indent;
            drawRect.Width -= indent;
            drawRect.Inflate(-2, -2);

            // The rectangle for the selection and focus
            drawRectElements.BoundaryRect = drawRect;

            Font headerFont = FontForItem(message);
            Rectangle imageRect;

            drawRect.Y = drawRect.Y + (drawRect.Height - headerFont.Height)/2;
            drawRect.X += 4;
            drawRect.Width -= 4;

            // Compute the optional expander rectangle
            if (message.IsRoot && message.HasChildren && CanGroupByConversation())
            {
                Image arrowImage = IsExpanded(message) ? Resources.CollapseArrow : Resources.ExpandArrow;
                imageRect = new Rectangle(drawRect.X, bounds.Y + (bounds.Height - arrowImage.Height) / 2, arrowImage.Width, arrowImage.Height);

                drawRectElements.ExpanderRect = imageRect;

                drawRect.X += arrowImage.Width + 4;
                drawRect.Width -= arrowImage.Width + 4;
            }

            // Compute Read image rectangle
            Image readImage = ReadImageForMessage(message);
            imageRect = new Rectangle(drawRect.X, bounds.Y + (bounds.Height - readImage.Height) / 2, readImage.Width, readImage.Height);

            drawRectElements.ReadRect = imageRect;

            drawRect.X += readImage.Width + 4;
            drawRect.Width -= readImage.Width + 4;

            // Compute author name rectangle
            SizeF idSize = graphics.MeasureString(message.Author, headerFont);

            drawRectElements.AuthorRect = drawRect;

            drawRect.X += (int)idSize.Width + 4;
            drawRect.Width -= (int)idSize.Width + 4;

            // Compute first separator rectangle
            const string separatorChar = "•";
            idSize = graphics.MeasureString(separatorChar, headerFont);

            drawRectElements.Separator1Rect = drawRect;

            drawRect.X += (int)idSize.Width + 4;
            drawRect.Width -= (int)idSize.Width + 4;

            // Compute date field rectangle
            string dateString = (_showFullDate)
                ? message.Date.ToString("d MMM yyyy") + " " + message.Date.ToShortTimeString()
                : message.Date.FriendlyString(true);
            idSize = graphics.MeasureString(dateString, headerFont);

            drawRectElements.DateRect = drawRect;

            drawRect.X += (int)idSize.Width + 4;
            drawRect.Width -= (int)idSize.Width + 4;

            // Compute Star field rectangle
            Image starIcon = message.Starred ? Resources.ActiveStar : Resources.InactiveStar;
            imageRect = new Rectangle(drawRect.X, bounds.Y + (bounds.Height - starIcon.Height) / 2,
                starIcon.Width, starIcon.Height);

            drawRectElements.StarRect = imageRect;

            drawRect.X += starIcon.Width + 4;
            drawRect.Width -= starIcon.Width + 4;

            // Compute ID field rectangle
            string idString = message.IsPseudo
                ? "Draft"
                : message.RemoteID.ToString(CultureInfo.InvariantCulture);
            idSize = graphics.MeasureString(idString, headerFont);

            drawRectElements.IDRect = drawRect;

            drawRect.X += (int)idSize.Width + 4;
            drawRect.Width -= (int)idSize.Width + 4;

            // Compute second separator rectangle
            idSize = graphics.MeasureString(separatorChar, headerFont);
            drawRectElements.Separator2Rect = drawRect;

            // Compute subject line rectangle
            drawRect.X += (int)idSize.Width + 4;
            drawRect.Width -= (int)idSize.Width + 8;

            drawRectElements.SubjectRect = drawRect;

            return drawRectElements;
        }
Пример #2
0
        /// <summary>
        /// Compute the display rectangles for the various field elements of the given message
        /// </summary>
        private DrawRectElements ComputeDrawRectElements(Graphics graphics, InboxConversation message, Rectangle bounds)
        {
            DrawRectElements drawRectElements = new DrawRectElements();
            Rectangle drawRect = bounds;
            drawRect.Inflate(-2, -2);

            // The rectangle for the selection and focus
            drawRectElements.BoundaryRect = drawRect;

            drawRect.Y = drawRect.Y + (drawRect.Height - _font.Height) / 2;
            drawRect.X += 4;
            drawRect.Width -= 4;

            // Compute Read image rectangle
            Image readImage = ReadImageForMessage(message);
            Rectangle imageRect = new Rectangle(drawRect.X, bounds.Y + (bounds.Height - readImage.Height) / 2, readImage.Width, readImage.Height);

            drawRectElements.ReadRect = imageRect;

            drawRect.X += readImage.Width + 4;
            drawRect.Width -= readImage.Width + 4;

            // Compute author name rectangle
            SizeF idSize = graphics.MeasureString(message.Author, _font);

            drawRectElements.AuthorRect = drawRect;

            drawRect.X += (int)idSize.Width + 4;
            drawRect.Width -= (int)idSize.Width + 4;

            // Compute first separator rectangle
            const string separatorChar = "•";
            idSize = graphics.MeasureString(separatorChar, _font);

            drawRectElements.Separator1Rect = drawRect;

            drawRect.X += (int)idSize.Width + 4;
            drawRect.Width -= (int)idSize.Width + 4;

            // Compute date field rectangle
            string dateString = (_showFullDate)
                ? message.Date.ToString("d MMM yyyy") + " " + message.Date.ToShortTimeString()
                : message.Date.FriendlyString(true);
            idSize = graphics.MeasureString(dateString, _font);

            drawRectElements.DateRect = drawRect;

            drawRect.X += (int)idSize.Width + 4;
            drawRect.Width -= (int)idSize.Width + 4;

            // Compute ID field rectangle
            string idString = (message.IsDraft)
                ? "Draft"
                : message.RemoteID.ToString(CultureInfo.InvariantCulture);
            idSize = graphics.MeasureString(idString, _font);

            drawRectElements.IDRect = drawRect;

            drawRect.X += (int)idSize.Width + 4;
            drawRect.Width -= (int)idSize.Width + 4;

            // Compute second separator rectangle
            idSize = graphics.MeasureString(separatorChar, _font);
            drawRectElements.Separator2Rect = drawRect;

            // Compute subject line rectangle
            drawRect.X += (int)idSize.Width + 4;
            drawRect.Width -= (int)idSize.Width + 8;

            drawRectElements.SubjectRect = drawRect;

            return drawRectElements;
        }