Ejemplo n.º 1
0
        public Boolean FixupParentalStatus(int nodeCount, UIExtension.TaskIcon taskIcons)
        {
            bool wasParent = m_IsParent;

            if (nodeCount == 0)
            {
                m_IsParent = (!m_HasIcon && taskIcons.Get(m_TaskID));
            }
            else
            {
                m_IsParent = true;
            }

            return(m_IsParent != wasParent);
        }
        protected override void OnDrawItem(DrawListViewItemEventArgs e)
        {
            if (e.Item == null)
            {
                return;
            }

            // Draw the background
            var item = (e.Item.Tag as CloudTaskItem);

            var textColor = item.GetTextColor(e.Item.Selected, m_TaskColorIsBkgnd);
            var backColor = item.GetBackColor(e.Item.Selected, m_TaskColorIsBkgnd);

            Brush textBrush = new SolidBrush(textColor);

            if (e.Item.Selected)
            {
                m_SelectionRect.Draw(Handle, e.Graphics, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
            }
            else if (m_TaskColorIsBkgnd && !backColor.IsEmpty)
            {
                using (Brush backBrush = new SolidBrush(backColor))
                    e.Graphics.FillRectangle(backBrush, e.Bounds);
            }
            else
            {
                e.DrawBackground();
            }

            // Draw subitems
            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Near;
            stringFormat.LineAlignment = StringAlignment.Center;
            stringFormat.FormatFlags   = StringFormatFlags.NoWrap;

            Rectangle itemRect = new Rectangle(e.Bounds.Location, e.Bounds.Size);

            for (int colIndex = 0; colIndex < e.Item.SubItems.Count; colIndex++)
            {
                itemRect.X    += 2;
                itemRect.Width = (Columns[colIndex].Width - 2);

                if (colIndex == 0)
                {
                    if (m_ShowCompletionCheckboxes)
                    {
                        if (m_CheckBoxSize.IsEmpty)
                        {
                            m_CheckBoxSize = CheckBoxRenderer.GetGlyphSize(e.Graphics, CheckBoxState.UncheckedNormal);
                        }

                        var checkRect = CalcCheckboxRect(itemRect);

                        CheckBoxRenderer.DrawCheckBox(e.Graphics, checkRect.Location, GetItemCheckboxState(item));

                        itemRect.X     += CheckboxOffset;
                        itemRect.Width -= CheckboxOffset;
                    }

                    if (m_TaskMatchesHaveIcons)
                    {
                        if ((e.Item.ImageIndex != -1) && m_TaskIcons.Get(item.Id))
                        {
                            int       imageSize = ImageSize;
                            Rectangle iconRect  = new Rectangle(itemRect.Location, new Size(imageSize, imageSize));
                            iconRect.Y += ((itemRect.Height - imageSize) / 2);

                            m_TaskIcons.Draw(e.Graphics, iconRect.Left, iconRect.Top);
                        }

                        itemRect.X     += TextIconOffset;
                        itemRect.Width -= TextIconOffset;
                    }
                }

                itemRect.Y++;
                itemRect.Height--;

                DrawText(e.Graphics,
                         e.Item.SubItems[colIndex].Text,
                         itemRect,
                         textBrush,
                         StringAlignment.Near,
                         (colIndex == 0));

                // next subitem
                itemRect.X += itemRect.Width;
            }
        }
Ejemplo n.º 3
0
        public override void DrawAppointment(Graphics g, Rectangle rect, Calendar.Appointment appointment, bool isLong, bool isSelected, Rectangle gripRect)
        {
            if (appointment == null)
            {
                throw new ArgumentNullException("appointment");
            }

            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            if (rect.Width != 0 && rect.Height != 0)
            {
                CalendarItem taskItem = (appointment as CalendarItem);

                UInt32 taskId     = taskItem.Id;
                UInt32 realTaskId = GetRealTaskId(taskItem);

                bool isFutureItem = (taskId != realTaskId);

                // Recalculate colours
                Color textColor = taskItem.TaskTextColor;
                Color fillColor = DrawingColor.SetLuminance(textColor, 0.95f);

                if (isFutureItem)
                {
                    fillColor = SystemColors.Window;

                    float textLum = DrawingColor.GetLuminance(textColor);
                    textColor = DrawingColor.SetLuminance(textColor, Math.Min(textLum + 0.2f, 0.7f));
                }

                Color borderColor = textColor;
                Color barColor    = textColor;

                if (taskItem.HasTaskTextColor)
                {
                    if (isSelected)
                    {
                        textColor = DrawingColor.SetLuminance(textColor, 0.3f);
                    }
                    else if (TaskColorIsBackground && !taskItem.IsDoneOrGoodAsDone && !isFutureItem)
                    {
                        barColor  = textColor;
                        fillColor = textColor;

                        borderColor = DrawingColor.AdjustLighting(textColor, -0.5f, true);
                        textColor   = DrawingColor.GetBestTextColor(textColor);
                    }
                }

                // Draw the background of the appointment
                g.SmoothingMode = SmoothingMode.None;

                if (isSelected)
                {
                    if (isLong)
                    {
                        rect.Height++;
                    }

                    if (isFutureItem)
                    {
                        UIExtension.SelectionRect.Draw(m_hWnd,
                                                       g,
                                                       rect.Left,
                                                       rect.Top,
                                                       rect.Width,
                                                       rect.Height,
                                                       UIExtension.SelectionRect.Style.DropHighlighted,
                                                       false);                                                          // opaque
                    }
                    else
                    {
                        UIExtension.SelectionRect.Draw(m_hWnd,
                                                       g,
                                                       rect.Left,
                                                       rect.Top,
                                                       rect.Width,
                                                       rect.Height,
                                                       false);                                                          // opaque
                    }
                }
                else
                {
                    using (SolidBrush brush = new SolidBrush(fillColor))
                        g.FillRectangle(brush, rect);

                    if (taskItem.DrawBorder)
                    {
                        if (!isLong)
                        {
                            rect.Height--;                             // drawing with pen adds 1 to height
                            rect.Width--;
                        }


                        using (Pen pen = new Pen(borderColor, 1))
                        {
                            if (isFutureItem)
                            {
                                pen.DashStyle = DashStyle.Dash;
                            }

                            g.DrawRectangle(pen, rect);
                        }
                    }
                }

                // Draw appointment icon
                bool hasIcon = false;
                taskItem.IconRect = Rectangle.Empty;

                if (TaskHasIcon(taskItem))
                {
                    Rectangle rectIcon;
                    int       imageSize = DPIScaling.Scale(16);

                    if (isLong)
                    {
                        int yCentre = ((rect.Top + rect.Bottom + 1) / 2);
                        rectIcon = new Rectangle((rect.Left + TextPadding), (yCentre - (imageSize / 2)), imageSize, imageSize);
                    }
                    else
                    {
                        rectIcon = new Rectangle(rect.Left + TextPadding, rect.Top + TextPadding, imageSize, imageSize);
                    }

                    if (g.IsVisible(rectIcon) && m_TaskIcons.Get(realTaskId))
                    {
                        if (isLong)
                        {
                            rectIcon.X = (gripRect.Right + TextPadding);
                        }
                        else
                        {
                            gripRect.Y      += (imageSize + TextPadding);
                            gripRect.Height -= (imageSize + TextPadding);
                        }

                        var clipRgn = g.Clip;

                        if (rect.Bottom < (rectIcon.Y + imageSize))
                        {
                            g.Clip = new Region(RectangleF.Intersect(rect, g.ClipBounds));
                        }

                        m_TaskIcons.Draw(g, rectIcon.X, rectIcon.Y);

                        g.Clip = clipRgn;

                        hasIcon           = true;
                        taskItem.IconRect = rectIcon;

                        rect.Width -= (rectIcon.Right - rect.Left);
                        rect.X      = rectIcon.Right;
                    }
                }

                // Draw gripper bar
                if (gripRect.Width > 0)
                {
                    using (SolidBrush brush = new SolidBrush(barColor))
                        g.FillRectangle(brush, gripRect);

                    if (!isLong)
                    {
                        gripRect.Height--; // drawing with pen adds 1 to height
                    }
                    // Draw gripper border
                    using (Pen pen = new Pen(DrawingColor.AdjustLighting(barColor, -0.5f, true), 1))
                        g.DrawRectangle(pen, gripRect);

                    if (!hasIcon)
                    {
                        rect.X      = gripRect.Right;
                        rect.Width -= (gripRect.Width + (TextPadding * 2));
                    }
                }

                // draw appointment text
                using (StringFormat format = new StringFormat())
                {
                    format.Alignment     = StringAlignment.Near;
                    format.LineAlignment = (isLong ? StringAlignment.Center : StringAlignment.Near);

                    rect.Y += 3;

                    if (isLong)
                    {
                        rect.Height = m_BaseFont.Height;
                    }
                    else
                    {
                        rect.Height -= 3;
                    }

                    taskItem.TextRect   = rect;
                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                    using (SolidBrush brush = new SolidBrush(textColor))
                    {
                        if (taskItem.IsDone && StrikeThruDoneTasks)
                        {
                            using (Font font = new Font(this.BaseFont, FontStyle.Strikeout))
                            {
                                g.DrawString(appointment.Title, font, brush, rect, format);
                            }
                        }
                        else
                        {
                            g.DrawString(appointment.Title, this.BaseFont, brush, rect, format);
                        }
                    }

                    g.TextRenderingHint = TextRenderingHint.SystemDefault;
                }
            }
        }
Ejemplo n.º 4
0
        protected override void DrawNodeLabel(Graphics graphics, String label, Rectangle rect,
                                              NodeDrawState nodeState, NodeDrawPos nodePos,
                                              Font nodeFont, Object itemData)
        {
            var taskItem = (itemData as MindMapTaskItem);
            var realItem = GetRealTaskItem(taskItem);

            bool      isSelected = (nodeState != NodeDrawState.None);
            Rectangle iconRect   = Rectangle.Empty;

            if (taskItem.IsTask) // not root
            {
                // Checkbox
                Rectangle checkRect = CalcCheckboxRect(rect);

                if (m_ShowCompletionCheckboxes)
                {
                    CheckBoxRenderer.DrawCheckBox(graphics, checkRect.Location, GetItemCheckboxState(realItem));
                }

                // Task icon
                if (TaskHasIcon(realItem))
                {
                    iconRect = CalcIconRect(rect);

                    if (m_TaskIcons.Get(realItem.ID))
                    {
                        m_TaskIcons.Draw(graphics, iconRect.X, iconRect.Y);
                    }

                    rect.Width = (rect.Right - iconRect.Right - 2);
                    rect.X     = iconRect.Right + 2;
                }
                else if (m_ShowCompletionCheckboxes)
                {
                    rect.Width = (rect.Right - checkRect.Right - 2);
                    rect.X     = checkRect.Right + 2;
                }
            }

            // Text Colour
            Color textColor = SystemColors.WindowText;

            if (!taskItem.TextColor.IsEmpty)
            {
                if (m_TaskColorIsBkgnd && !isSelected && !realItem.IsDone(true))
                {
                    textColor = DrawingColor.GetBestTextColor(taskItem.TextColor);
                }
                else if (isSelected)
                {
                    textColor = DrawingColor.SetLuminance(taskItem.TextColor, 0.3f);
                }
                else
                {
                    textColor = taskItem.TextColor;
                }
            }

            switch (nodeState)
            {
            case NodeDrawState.Selected:
                UIExtension.SelectionRect.Draw(this.Handle, graphics, rect.X, rect.Y, rect.Width, rect.Height, this.Focused, false);     // opaque
                break;

            case NodeDrawState.DropTarget:
                UIExtension.SelectionRect.Draw(this.Handle, graphics, rect.X, rect.Y, rect.Width, rect.Height, false, false);     // opaque
                break;

            case NodeDrawState.None:
                if (DebugMode())
                {
                    graphics.DrawRectangle(new Pen(Color.Green), rect);
                }
                break;
            }

            // Text
            var format = DefaultLabelFormat(nodePos, isSelected);

            graphics.DrawString(label, nodeFont, new SolidBrush(textColor), rect, format);

            // Draw Windows shortcut icon if task is a reference
            if (taskItem.IsReference)
            {
                if (iconRect == Rectangle.Empty)
                {
                    iconRect = rect;
                }
                else
                {
                    iconRect.Y = (rect.Bottom - iconRect.Height);                     // don't want shortcut icon centred vertically
                }
                UIExtension.ShortcutOverlay.Draw(graphics, iconRect.X, iconRect.Y, iconRect.Width, iconRect.Height);
            }
        }
Ejemplo n.º 5
0
        protected override void DrawNodeLabel(Graphics graphics, String label, Rectangle rect,
                                              NodeDrawState nodeState, NodeDrawPos nodePos,
                                              Font nodeFont, Object itemData)
        {
            var  taskItem   = (itemData as MindMapTaskItem);
            bool isSelected = (nodeState != NodeDrawState.None);

            if (taskItem.IsTask) // real task
            {
                // Checkbox
                Rectangle checkRect = CalcCheckboxRect(rect);

                if (m_ShowCompletionCheckboxes)
                {
                    CheckBoxRenderer.DrawCheckBox(graphics, checkRect.Location, GetItemCheckboxState(taskItem));
                }

                // Task icon
                if (TaskHasIcon(taskItem))
                {
                    Rectangle iconRect = CalcIconRect(rect);

                    if (m_TaskIcons.Get(taskItem.ID))
                    {
                        m_TaskIcons.Draw(graphics, iconRect.X, iconRect.Y);
                    }

                    rect.Width = (rect.Right - iconRect.Right - 2);
                    rect.X     = iconRect.Right + 2;
                }
                else if (m_ShowCompletionCheckboxes)
                {
                    rect.Width = (rect.Right - checkRect.Right - 2);
                    rect.X     = checkRect.Right + 2;
                }
            }

            // Text background
            Brush textColor = SystemBrushes.WindowText;
            Brush backColor = null;
            Color taskColor = taskItem.TextColor;

            if (!taskColor.IsEmpty)
            {
                if (m_TaskColorIsBkgnd && !isSelected && !taskItem.IsDone(true))
                {
                    backColor = new SolidBrush(taskColor);
                    textColor = new SolidBrush(DrawingColor.GetBestTextColor(taskColor));
                }
                else
                {
                    if (nodeState != MindMapControl.NodeDrawState.None)
                    {
                        taskColor = DrawingColor.SetLuminance(taskColor, 0.3f);
                    }

                    textColor = new SolidBrush(taskColor);
                }
            }

            switch (nodeState)
            {
            case NodeDrawState.Selected:
                m_SelectionRect.Draw(graphics, rect.X, rect.Y, rect.Width, rect.Height, this.Focused);
                break;

            case NodeDrawState.DropTarget:
                m_SelectionRect.Draw(graphics, rect.X, rect.Y, rect.Width, rect.Height, false);
                break;

            case NodeDrawState.None:
            {
                if (backColor != null)
                {
                    var prevSmoothing = graphics.SmoothingMode;
                    graphics.SmoothingMode = SmoothingMode.None;

                    graphics.FillRectangle(backColor, rect);
                    graphics.SmoothingMode = prevSmoothing;
                }

                if (DebugMode())
                {
                    graphics.DrawRectangle(new Pen(Color.Green), rect);
                }
            }
            break;
            }

            // Text
            var format = DefaultLabelFormat(nodePos, isSelected);

            graphics.DrawString(label, nodeFont, textColor, rect, format);
        }
Ejemplo n.º 6
0
        public override void DrawAppointment(System.Drawing.Graphics g, System.Drawing.Rectangle rect, Calendar.Appointment appointment, bool isSelected, System.Drawing.Rectangle gripRect)
        {
            if (appointment == null)
            {
                throw new ArgumentNullException("appointment");
            }

            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            if (rect.Width != 0 && rect.Height != 0)
            {
                CalendarItem taskItem = (appointment as CalendarItem);
                bool         longAppt = taskItem.IsLongAppt();

                if (!longAppt && (taskItem.StartDate.TimeOfDay.TotalHours == 0.0))
                {
                    rect.Y++;
                    rect.Height--;
                }

                rect.Width--;

                // Recalculate colours
                Color textColor   = taskItem.TaskTextColor;
                Color borderColor = taskItem.TaskTextColor;
                Color fillColor   = DrawingColor.SetLuminance(taskItem.TaskTextColor, 0.95f);
                Color barColor    = taskItem.TaskTextColor;

                if (taskItem.HasTaskTextColor)
                {
                    if (isSelected)
                    {
                        textColor = DrawingColor.SetLuminance(taskItem.TaskTextColor, 0.3f);
                    }
                    else if (m_TaskColorIsBkgnd && !taskItem.IsDone)
                    {
                        textColor   = DrawingColor.GetBestTextColor(taskItem.TaskTextColor);
                        borderColor = DrawingColor.AdjustLighting(taskItem.TaskTextColor, -0.5f, true);
                        barColor    = taskItem.TaskTextColor;
                        fillColor   = taskItem.TaskTextColor;
                    }
                }

                using (StringFormat format = new StringFormat())
                {
                    format.Alignment     = StringAlignment.Near;
                    format.LineAlignment = (longAppt ? StringAlignment.Center : StringAlignment.Near);

                    // Draw the background of the appointment
                    if (isSelected)
                    {
                        m_SelectionRect.Draw(m_hWnd, g, rect.Left, rect.Top, rect.Width, rect.Height);
                    }
                    else
                    {
                        using (SolidBrush brush = new SolidBrush(fillColor))
                            g.FillRectangle(brush, rect);
                    }

                    //  Draw appointment border if needed
                    if (!isSelected && taskItem.DrawBorder)
                    {
                        using (Pen pen = new Pen(borderColor, 1))
                            g.DrawRectangle(pen, rect);
                    }

                    // Draw appointment icon
                    bool hasIcon = false;
                    taskItem.IconRect = Rectangle.Empty;

                    if (TaskHasIcon(taskItem))
                    {
                        Rectangle rectIcon;
                        int       imageSize = DPIScaling.Scale(16);

                        if (taskItem.IsLongAppt())
                        {
                            int yCentre = ((rect.Top + rect.Bottom + 1) / 2);
                            rectIcon = new Rectangle((rect.Left + 2), (yCentre - (imageSize / 2)), imageSize, imageSize);
                        }
                        else
                        {
                            rectIcon = new Rectangle(rect.Left + 2, rect.Top + 2, imageSize, imageSize);
                        }

                        if (Rectangle.Round(g.VisibleClipBounds).Contains(rectIcon) && m_TaskIcons.Get(taskItem.Id))
                        {
                            if (longAppt)
                            {
                                rectIcon.X = (gripRect.Right + 2);
                            }
                            else
                            {
                                gripRect.Y      += (imageSize + 2);
                                gripRect.Height -= (imageSize + 2);
                            }

                            m_TaskIcons.Draw(g, rectIcon.X, rectIcon.Y);

                            hasIcon           = true;
                            taskItem.IconRect = rectIcon;

                            rect.Width -= (rectIcon.Right - rect.Left);
                            rect.X      = rectIcon.Right;
                        }
                    }

                    // Draw gripper bar
                    if (gripRect.Width > 0)
                    {
                        using (SolidBrush brush = new SolidBrush(barColor))
                            g.FillRectangle(brush, gripRect);

                        // Draw gripper border
                        using (Pen pen = new Pen(DrawingColor.AdjustLighting(barColor, -0.5f, true), 1))
                            g.DrawRectangle(pen, gripRect);

                        if (!hasIcon)
                        {
                            rect.X      = gripRect.Right;
                            rect.Width -= (gripRect.Width + 4);
                        }
                    }

                    // draw appointment text
                    rect.Y += 3;

                    if (longAppt)
                    {
                        rect.Height = m_BaseFont.Height;
                    }
                    else
                    {
                        rect.Height -= 3;
                    }

                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                    using (SolidBrush brush = new SolidBrush(textColor))
                        g.DrawString(appointment.Title, this.BaseFont, brush, rect, format);

                    g.TextRenderingHint = TextRenderingHint.SystemDefault;
                }
            }
        }