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); } }
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); }