Exemple #1
0
        private void PDFTextBox_Paint(object sender, PaintEventArgs e)
        {
            UpdateControl();

            // Draw TextBox Border.
            FormFieldControl.DrawBorder(e.Graphics, this, this.ClientSize, _focus);
        }
Exemple #2
0
        private void PDFListBox_Paint(object sender, PaintEventArgs e)
        {
            if (!_isBorderStyleUpdated)
            {
                this.FieldBorderStyle = _fieldBorderStyle;
                _isBorderStyleUpdated = true;
            }

            // Draw ListBox Border.
            FormFieldControl.DrawBorder(e.Graphics, this, this.ClientSize, _focus);
        }
Exemple #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.Clear(this.BackColor);

            Rectangle innerRect      = new Rectangle((_borderThickness), (_borderThickness), this.ClientSize.Width - (_borderThickness * 2), this.ClientSize.Height - (_borderThickness * 2));
            Rectangle backgroundRect = new Rectangle((_borderThickness), (_borderThickness), this.ClientSize.Width - (_borderThickness * 2), this.ClientSize.Height - (_borderThickness * 2));

            switch (_fieldBorderStyle)
            {
            case FieldBorderStyle.Beveled:
                backgroundRect.Inflate(-this._borderThickness, -this._borderThickness);
                break;

            case FieldBorderStyle.Inset:
                backgroundRect.Inflate(-this._borderThickness, -this._borderThickness);
                break;

            case FieldBorderStyle.Underlined:
                backgroundRect = new Rectangle(0, 0, this.ClientSize.Width, this.ClientSize.Height - _borderThickness);
                break;
            }

            backgroundRect.Width  = backgroundRect.Width == 0 ? 1 : backgroundRect.Width;
            backgroundRect.Height = backgroundRect.Height == 0 ? 1 : backgroundRect.Height;

            // Draw CheckBox Border.
            FormFieldControl.DrawBorder(e.Graphics, this, this.ClientSize, _focus);

            // Draw Check Box Background.
            e.Graphics.FillRectangle(new SolidBrush(_backgroundColor), backgroundRect);

            // Draw Check Mark.
            if (this.Checked)
            {
                int       checkMarkHeight = innerRect.Height >= innerRect.Width ? innerRect.Width : innerRect.Height;
                Point     checkMarkOffset = new Point(innerRect.X + ((innerRect.Width - checkMarkHeight) / 2), innerRect.Y + ((innerRect.Height - checkMarkHeight) / 2));
                Rectangle checkMarkRect   = new Rectangle(checkMarkOffset.X, checkMarkOffset.Y, checkMarkHeight, checkMarkHeight);

                Font font = new Font("Verdana", checkMarkRect.Height, FontStyle.Bold);

                font = FitTextToControlHeight(font, checkMarkRect.Height);

                TextRenderer.DrawText(e.Graphics, "✓", font, new Point(checkMarkRect.X, checkMarkRect.Y), Color.Black);
            }
        }
Exemple #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            // Draw ComboBox Border.
            FormFieldControl.DrawBorder(e.Graphics, this, this.Parent.Size, _focus);

            Rectangle innerRect = GetInnerRect();

            using (e.Graphics.Clip = new Region(innerRect))
            {
                // Draw Background Rectangle
                using (SolidBrush brush = new SolidBrush(this.BackgroundColor))
                {
                    e.Graphics.FillRectangle(brush, innerRect);
                }

                // Draw Selected Item String
                using (SolidBrush brush = new SolidBrush(this.ForeColor))
                {
                    string selectetItem = this.SelectedItem == null ? "" : this.SelectedItem.ToString();

                    string text = string.IsNullOrEmpty(ContentText) ? selectetItem : this.ContentText;

                    SizeF textSize = e.Graphics.MeasureString(text, this.Font);

                    float centerY = innerRect.Y + (innerRect.Height - textSize.Height) / 2;

                    e.Graphics.DrawString(text, this.Font, brush, innerRect.X, centerY);
                }

                // Draw Combo Button
                Rectangle comboButtonRect = new Rectangle(innerRect.X + innerRect.Width - 15, innerRect.Y, 15, innerRect.Height);

                ControlPaint.DrawComboButton(e.Graphics, comboButtonRect, ButtonState.Normal);
            }
        }