/// <summary>Draws the button.</summary> /// <param name="graphics">The graphics to draw on.</param> /// <param name="rectangle">The rectangle to draw on.</param> private void DrawContent(Graphics graphics, Rectangle rectangle) { Color _textColor = Enabled ? _foreColor : _textDisabledColor; if ((SelectedIndex != -1) && (_imageList != null) && _imageVisible) { VisualControlRenderer.DrawContent(graphics, rectangle, Text, Font, _textColor, _imageList.Images[SelectedIndex], _imageList.ImageSize, _textImageRelation); } else { StringFormat _stringFormat = new StringFormat { Alignment = _textAlignment, LineAlignment = _textLineAlignment }; VisualTextRenderer.RenderText(graphics, rectangle, Text, Font, _textColor, _stringFormat); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics graphics = e.Graphics; graphics.Clear(Parent.BackColor); graphics.FillRectangle(new SolidBrush(BackColor), ClientRectangle); Color _foreColor = Enabled ? ForeColor : TextStyle.Disabled; if (_reflection && (_orientation == Orientation.Vertical)) { textBoxRectangle = new Rectangle(TextManager.MeasureText(Text, Font, graphics).Height, 0, ClientRectangle.Width, ClientRectangle.Height); } else { textBoxRectangle = new Rectangle(0, 0, ClientRectangle.Width, ClientRectangle.Height); } // Draw the text outline if (_outline) { VisualTextRenderer.RenderTextOutline(graphics, _orientation, Text, Font, _outlineColor, _outlineLocation); } // Draw the shadow if (_shadow) { VisualTextRenderer.RenderTextShadow(graphics, _orientation, Text, Font, _shadowColor, ClientRectangle, _shadowLocation, _shadowSmooth, _shadowDepth, _shadowDirection, shadowOpacity); } // Draw the reflection text. if (_reflection) { VisualTextRenderer.RenderTextReflection(graphics, _orientation, Text, Font, _reflectionColor, ClientRectangle, _reflectionSpacing, textBoxRectangle.Location, _alignment, _lineAlignment); } graphics.DrawString(Text, Font, new SolidBrush(_foreColor), textBoxRectangle, VisualTextRenderer.GetOrientedStringFormat(_orientation, _alignment, _lineAlignment)); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); try { Graphics _graphics = e.Graphics; _graphics.Clear(Parent.BackColor); _graphics.SmoothingMode = SmoothingMode.HighQuality; _graphics.TextRenderingHint = TextStyle.TextRenderingHint; Rectangle _clientRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1); ControlGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(_clientRectangle, _border); _graphics.FillRectangle(new SolidBrush(BackColor), new Rectangle(ClientRectangle.X - 1, ClientRectangle.Y - 1, ClientRectangle.Width + 1, ClientRectangle.Height + 1)); Color _backColor = ControlColorState.BackColorState(BackColorState, Enabled, MouseState); e.Graphics.SetClip(ControlGraphicsPath); VisualBackgroundRenderer.DrawBackground(e.Graphics, _backColor, BackgroundImage, MouseState, _clientRectangle, _border); if (_image != null) { Color _textColor = Enabled ? ForeColor : TextStyle.Disabled; VisualControlRenderer.DrawContent(e.Graphics, ClientRectangle, Text, Font, _textColor, _image, _image.Size, _textImageRelation); } else { VisualTextRenderer.RenderText(e.Graphics, ClientRectangle, Text, Font, Enabled, MouseState, TextStyle); } VisualBorderRenderer.DrawBorderStyle(e.Graphics, _border, ControlGraphicsPath, MouseState); DrawAnimation(e.Graphics); e.Graphics.ResetClip(); } catch (Exception exception) { ConsoleEx.WriteDebug(exception); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics graphics = e.Graphics; if (messageBoxIcon != MessageBoxIcon.None) { dialogImage = GetSystemIconsImage(); } dialogImageRectangle = new Rectangle(BodyContainer.X + extraPadding, BodyContainer.Y, dialogImageSize.Width, dialogImageSize.Height); Rectangle textRectangle; if (dialogImage != null) { VisualImageRenderer.RenderImageFilled(graphics, dialogImageRectangle, dialogImage); int xTextLocation = dialogImageRectangle.Right + extraPadding; textRectangle = new Rectangle(xTextLocation, BodyContainer.Y, TextBlockWidth, TextBlockHeight); } else { textRectangle = new Rectangle(BodyContainer.Left + extraPadding, BodyContainer.Y, TextBlockWidth, TextBlockHeight); } StringFormat stringFormat = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center }; VisualTextRenderer.RenderText(graphics, textRectangle, messageText, Font, ForeColor, stringFormat); UpdateButtonsVisibility(); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); try { Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.CompositingQuality = CompositingQuality.GammaCorrected; Size textArea = StringUtil.MeasureText(Text, Font, graphics); Rectangle group = ConfigureStyleBox(textArea); Rectangle title = ConfigureStyleTitleBox(textArea); _titleBoxRectangle = new Rectangle(title.X, title.Y, title.Width - 1, title.Height); Rectangle _clientRectangle = new Rectangle(group.X, group.Y, group.Width, group.Height); ControlGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(_clientRectangle, _border); graphics.FillRectangle(new SolidBrush(BackColor), _clientRectangle); Color _backColor = Enabled ? BackColorState.Enabled : BackColorState.Disabled; VisualBackgroundRenderer.DrawBackground(e.Graphics, _backColor, BackgroundImage, MouseState, group, Border); if (_borderEdge.Visible) { _borderEdge.Location = new Point(_titleBoxRectangle.X + _border.Thickness, _titleBoxRectangle.Bottom); _borderEdge.Size = new Size(Width - _border.Thickness - 1, 1); } VisualBorderRenderer.DrawBorderStyle(e.Graphics, _border, ControlGraphicsPath, MouseState); if (_boxStyle == GroupBoxStyle.Classic) { Size _newSize; if (_image != null) { _newSize = _image.Size; } else { _newSize = new Size(0, 0); } _titleBoxRectangle = new Rectangle(5, 0, title.Width - 1, title.Height); Point _titleBoxBackground = RelationManager.GetTextImageRelationLocation(graphics, _textImageRelation, new Rectangle(new Point(0, 0), _newSize), Text, Font, _titleBoxRectangle, Relation.Text); graphics.FillRectangle(new SolidBrush(BackColorState.Enabled), new Rectangle(new Point(_titleBoxBackground.X, _titleBoxBackground.Y), new Size(_titleBoxRectangle.Width, _titleBoxRectangle.Height))); } if (_image != null) { VisualControlRenderer.DrawContent(e.Graphics, _titleBoxRectangle, Text, Font, ForeColor, _image, _image.Size, _textImageRelation); } else { StringFormat _stringFormat = new StringFormat { Alignment = _textAlignment, LineAlignment = _textLineAlignment }; VisualTextRenderer.RenderText(e.Graphics, _titleBoxRectangle, Text, Font, ForeColor, _stringFormat); } } catch (Exception exception) { Logger.WriteDebug(exception); } }