private void DrawSelected(LayoutItem layoutItem) { Rectangle rect = Rectangle.Inflate(Rectangle.Round(layoutItem.Rectangle), -1, -1); m_SelectionRect.Draw(m_Graphics, rect.Left, rect.Top, rect.Width, rect.Height, m_Ctrl.Focused); DrawEmphasizedText(layoutItem, true); }
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; } }
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); }
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; } } }