コード例 #1
0
        /// <summary>
        /// Raises the <see cref="E:Paint"/> event.
        /// </summary>
        /// <param name="pevent">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
        protected override void OnPaint(PaintEventArgs pevent)
        {
            if (this.UseVisualStyleBackColor)
            {
                CheckBoxRenderer.DrawParentBackground(pevent.Graphics, pevent.ClipRectangle, this);
            }
            else
            {
                pevent.Graphics.Clear(this.BackColor);
            }
            Rectangle glyphBounds, focusBounds, textBounds, subtextBounds;
            int       h = GetElementBounds(pevent.Graphics, pevent.ClipRectangle, out glyphBounds, out textBounds, out subtextBounds, out focusBounds);

            if (this.AutoSize && h != this.Height)
            {
                this.Height = h;
            }
            CheckBoxRenderer.DrawCheckBox(pevent.Graphics, glyphBounds.Location, GetCheckBoxState());
            TextRenderer.DrawText(pevent.Graphics, this.Text, this.Font, textBounds, this.ForeColor, this.TextFormatFlags);
            if (subtextBounds != Rectangle.Empty)
            {
                TextRenderer.DrawText(pevent.Graphics, Subtext, this.SubtextFont, subtextBounds, this.SubtextForeColor, this.TextFormatFlags);
            }
            if (this.Focused)
            {
                ControlPaint.DrawFocusRectangle(pevent.Graphics, focusBounds);
            }
        }
コード例 #2
0
    protected override void OnDrawNode(DrawTreeNodeEventArgs e)
    {
        TreeNode3 n = e.Node as TreeNode3;

        if (n == null)
        {
            e.DrawDefault = true; return;
        }
        CheckBoxState cbyTrue  = CheckBoxState.CheckedNormal;
        CheckBoxState cbyFalse = CheckBoxState.UncheckedNormal;
        Rectangle     rect     = new Rectangle(e.Bounds.Location,
                                               new Size(ClientSize.Width, e.Bounds.Height));

        glyph = CheckBoxRenderer.GetGlyphSize(e.Graphics, cbyTrue);
        if (n.IsSelected)
        {
            e.Graphics.FillRectangle(SystemBrushes.MenuHighlight, rect);
            e.Graphics.DrawString(n.Label, Font, Brushes.White,
                                  e.Bounds.X + 55, e.Bounds.Y);
        }
        else
        {
            CheckBoxRenderer.DrawParentBackground(e.Graphics, e.Bounds, this);
            e.Graphics.DrawString(n.Label, Font, Brushes.Black,
                                  e.Bounds.X + 55, e.Bounds.Y);
        }
        CheckBoxState bs1 = n.Check1 ? cbyTrue : cbyFalse;
        CheckBoxState bs2 = n.Check2 ? cbyTrue : cbyFalse;
        CheckBoxState bs3 = n.Check3 ? cbyTrue : cbyFalse;

        CheckBoxRenderer.DrawCheckBox(e.Graphics, cbx(e.Bounds, 0).Location, bs1);
        CheckBoxRenderer.DrawCheckBox(e.Graphics, cbx(e.Bounds, 1).Location, bs2);
        CheckBoxRenderer.DrawCheckBox(e.Graphics, cbx(e.Bounds, 2).Location, bs3);
    }
コード例 #3
0
        private void DoPaint(PaintEventArgs pevent)
        {
            CheckBoxRenderer.DrawParentBackground(pevent.Graphics, pevent.ClipRectangle, this);

            RadioButtonState radioButtonState;

            if (Checked)
            {
                radioButtonState = RadioButtonState.CheckedNormal;
                if (Focused)
                {
                    radioButtonState = RadioButtonState.CheckedHot;
                }
                if (!Enabled)
                {
                    radioButtonState = RadioButtonState.CheckedDisabled;
                }
            }
            else
            {
                radioButtonState = RadioButtonState.UncheckedNormal;
                if (Focused)
                {
                    radioButtonState = RadioButtonState.UncheckedHot;
                }
                if (!Enabled)
                {
                    radioButtonState = RadioButtonState.UncheckedDisabled;
                }
            }

            Size      glyphSize = RadioButtonRenderer.GetGlyphSize(pevent.Graphics, radioButtonState);
            Rectangle rect      = ClientRectangle;

            rect.Width   -= glyphSize.Width;
            rect.Location = new Point(rect.Left + glyphSize.Width, 0); // rect.Top);

            //RadioButtonRenderer.DrawRadioButton(pevent.Graphics, new System.Drawing.Point(0, rect.Height / 2 - glyphSize.Height / 2), rect, this.Text, this.Font, this.Focused, radioButtonState);
            RadioButtonRenderer.DrawRadioButton(pevent.Graphics, new System.Drawing.Point(0, 2), rect, this.Text, this.Font, false, radioButtonState);
        }