This repository has been archived on 2022-09-30. You can view files and clone it, but cannot push or open issues or pull requests.
bookmark-manager/RyzStudio/Windows/ThemedForms/UserControl.cs

54 lines
1.8 KiB
C#
Raw Permalink Normal View History

namespace RyzStudio.Windows.ThemedForms
{
using System;
using System.Drawing;
using System.Windows.Forms;
using RyzStudio.Drawing;
using System.ComponentModel;
public partial class UserControl : System.Windows.Forms.UserControl
{
2019-04-23 20:57:35 +00:00
//protected ThemeStyle styleActive = new ThemeStyle(1, 3, 2, Color.FromArgb(112, 112, 112), Color.White);
protected ThemeStyle styleActive = new ThemeStyle(1, 3, 2, Color.FromArgb(212, 212, 212), Color.White);
public UserControl()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.BackColor = Color.Transparent;
}
protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground(e);
Graphics g = e.Graphics;
//// g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
//// g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
//// g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
//// g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
updateBackground(g, styleActive);
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new Padding Padding { get { return base.Padding; } set { base.Padding = value; } }
protected virtual void updateBackground(Graphics g, ThemeStyle style)
{
int b = (styleActive.BorderWidth + 1) + styleActive.BorderPadding;
this.Padding = new Padding(b, b, (b - 1), (b - 1));
Rectangoid area = new Rectangoid(this.ClientRectangle, style.BorderRadius, style.BorderWidth);
g.FillPath(new SolidBrush(style.BackColour), area.ToGraphicsPath());
g.DrawPath(new Pen(new SolidBrush(style.BorderColour), style.BorderWidth), area.ToGraphicsPath());
}
}
}