protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); try { Graphics graphics = e.Graphics; graphics.Clear(BackColor); GraphicsPath _clientPath = VisualBorderRenderer.CreateBorderTypePath(GetBorderBounds(), _border); if (_border.Type != ShapeType.Rectangle) { graphics.SetClip(_clientPath); } graphics.FillRectangle(new SolidBrush(_background), new Rectangle(0, 0, Width, Height)); if (BackgroundImage != null) { Rectangle _windowWithoutTitleBar = new Rectangle(1, _textRectangle.Bottom, ClientRectangle.Width + 1, ClientRectangle.Height + 1); graphics.DrawImage(BackgroundImage, _windowWithoutTitleBar); } DrawWindowTitleBar(graphics); graphics.ResetClip(); VisualBorderRenderer.DrawBorderStyle(graphics, _border, _clientPath, State); } catch (Exception exception) { VisualExceptionDialog.Show(exception); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); try { Graphics graphics = e.Graphics; graphics.Clear(BackColor); graphics.SmoothingMode = SmoothingMode.Default; graphics.TextRenderingHint = TextRenderingHint.AntiAlias; Rectangle _clientRectangle; switch (_border.Type) { case ShapeType.Rectangle: { _clientRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width + 1, ClientRectangle.Height + 1); break; } case ShapeType.Rounded: { _clientRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1); break; } default: { throw new ArgumentOutOfRangeException(); } } GraphicsPath _clientPath = VisualBorderRenderer.CreateBorderTypePath(_clientRectangle, _border); graphics.SetClip(_clientPath); graphics.FillPath(new SolidBrush(_background), _clientPath); _statusBarBounds = new Rectangle(0, 0, Width, _windowBarHeight); graphics.FillRectangle(new SolidBrush(_windowBarColor), _statusBarBounds); DrawImageIcon(graphics); graphics.SetClip(_clientPath); DrawTitle(graphics); graphics.ResetClip(); VisualBorderRenderer.DrawBorderStyle(graphics, _border, _clientPath, State); } catch (Exception exception) { VisualExceptionDialog.Show(exception); } }
/// <summary>Draws the text title.</summary> /// <param name="graphics">The specified graphics to draw on.</param> private void DrawTitle(Graphics graphics) { try { Size _textSize = GraphicsManager.MeasureTextRenderer(Text, Font); // Fixes: Lower hanging characters like 'g'. _textSize.Height = _textSize.Height + 1; Point _titleLocation; switch (_titleAlignment) { case Alignment.TextAlignment.Center: { _titleLocation = new Point((Width / 2) - (_textSize.Width / 2), _textRectangle.Y); break; } case Alignment.TextAlignment.Left: { _titleLocation = new Point(_vsImage.Point.X + _vsImage.Size.Width + 1, _textRectangle.Y); break; } case Alignment.TextAlignment.Right: { _titleLocation = new Point(Width - _border.Thickness - _textSize.Width - _visualControlBox.Width - 1, _textRectangle.Y); break; } default: { throw new ArgumentOutOfRangeException(); } } _textRectangle = new Rectangle(_titleLocation.X, _titleLocation.Y, _textSize.Width, _textSize.Height); graphics.DrawString(Text, Font, new SolidBrush(ForeColor), _textRectangle); } catch (Exception e) { VisualExceptionDialog.Show(e); } }
/// <summary>Display the <see cref="VisualExceptionDialog" />.</summary> /// <param name="exception">The exception.</param> /// <param name="caption">The caption.</param> /// <param name="dialogWindow">The dialog Window.</param> /// <returns>The <see cref="DoWorkEventHandler" />.</returns> private static DoWorkEventHandler BackgroundWorker_DoShowWork(Exception exception, string caption, bool dialogWindow) { VisualExceptionDialog _exceptionDialog = new VisualExceptionDialog(exception) { Text = caption }; if (dialogWindow) { _exceptionDialog.ShowDialog(); } else { _exceptionDialog.Show(); } return(null); }
public void UpdateTheme(Theme theme) { try { _styleManager = new StyleManager(theme); _background = theme.OtherSettings.FormBackground; _border.Color = theme.BorderSettings.Normal; _border.HoverColor = theme.BorderSettings.Hover; ForeColor = theme.TextSetting.Enabled; Font = theme.TextSetting.Font; _windowBarColor = theme.OtherSettings.FormWindowBar; } catch (Exception e) { VisualExceptionDialog.Show(e); } OnThemeChanged(new ThemeEventArgs(theme)); }