/// <summary> /// Paints the selected node in the control. /// </summary> /// <param name="e"></param> protected override void OnPaintContent(DropDownPaintEventArgs e) { base.OnPaintContent(e); Image img = GetNodeImage(_selectedNode); string text = _nullValue; if (_showCheckBoxes) { text = GetCheckedNodeString(); } else if (_selectedNode != null) { text = (_showPath) ? Path : _selectedNode.Text; } Rectangle imgBounds = (img == null) ? new Rectangle(1, 0, 0, 0) : new Rectangle(4, e.Bounds.Height / 2 - img.Height / 2, img.Width, img.Height); Rectangle txtBounds = new Rectangle(imgBounds.Right, 0, e.Bounds.Width - imgBounds.Right - 3, e.Bounds.Height); if (img != null) { e.Graphics.DrawImage(img, imgBounds); } TextRenderer.DrawText(e.Graphics, text, Font, txtBounds, Enabled ? ForeColor : SystemColors.GrayText, TEXT_FORMAT_FLAGS); // focus rectangle if (Focused && ShowFocusCues && !DroppedDown) { e.DrawFocusRectangle(); } }
protected override void OnPaintContent(DropDownPaintEventArgs e) { decimal sum = 0m; foreach (var node in this.CheckedNodes) { var pipe = node.Tag as Pipe; if (pipe != null) { sum += pipe.Volume; } } Rectangle txtBounds = new Rectangle(1, 0, e.Bounds.Width - 4, e.Bounds.Height); TextRenderer.DrawText(e.Graphics, String.Format("{0} m³", sum), Font, txtBounds, ForeColor, TEXT_FORMAT_FLAGS); if (Focused && ShowFocusCues && !DroppedDown) { e.DrawFocusRectangle(); } }
/// <summary> /// Paints the selected node in the control. /// </summary> /// <param name="e"></param> protected override void OnPaintContent(DropDownPaintEventArgs e) { base.OnPaintContent(e); Image img = GetNodeImage(selectedNode); string text = (selectedNode != null) ? ((showPath) ? Path : selectedNode.Text) : nullValue; Rectangle imgBounds = (img == null) ? new Rectangle(1, 0, 0, 0) : new Rectangle(4, e.Bounds.Height / 2 - img.Height / 2, img.Width, img.Height); Rectangle txtBounds = new Rectangle(imgBounds.Right, 0, e.Bounds.Width - imgBounds.Right - 3, e.Bounds.Height); if (img != null) { e.Graphics.DrawImage(img, imgBounds); } TextRenderer.DrawText(e.Graphics, text, Font, txtBounds, ForeColor, TEXT_FORMAT_FLAGS); // focus rectangle if (Focused && ShowFocusCues && !DroppedDown) { e.DrawFocusRectangle(); } }
/// <summary> /// Paints the selected node in the control. /// </summary> /// <param name="e"></param> protected override void OnPaintContent(DropDownPaintEventArgs e) { base.OnPaintContent(e); Image img = GetNodeImage(_selectedNode); string text = _nullValue; if (_showCheckBoxes) text = GetCheckedNodeString(); else if (_selectedNode != null) text = (_showPath) ? Path : _selectedNode.Text; Rectangle imgBounds = (img == null) ? new Rectangle(1,0,0,0) : new Rectangle(4, e.Bounds.Height / 2 - img.Height / 2, img.Width, img.Height); Rectangle txtBounds = new Rectangle(imgBounds.Right, 0, e.Bounds.Width - imgBounds.Right - 3, e.Bounds.Height); if (img != null) e.Graphics.DrawImage(img, imgBounds); TextRenderer.DrawText(e.Graphics, text, Font, txtBounds, ForeColor, TEXT_FORMAT_FLAGS); // focus rectangle if (Focused && ShowFocusCues && !DroppedDown) e.DrawFocusRectangle(); }