C# Windows Form Изменение цвета рамки для FormWindowState Normal и Maximized
public Form1() { InitializeComponent(); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (WindowState == FormWindowState.Normal) { //if (!Focused) //{ // using (Pen borderPen = new Pen(Color.FromArgb(86, 4, 55), 1)) // { // Rectangle borderRect = new Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width - 1, ClientRectangle.Height - 1); // e.Graphics.DrawRectangle(borderPen, borderRect); // } //} //else //{ using (Pen borderPen = new Pen(Color.FromArgb(255, 0, 121, 203), 1)) { Rectangle borderRect = new Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width - 1, ClientRectangle.Height - 1); e.Graphics.DrawRectangle(borderPen, borderRect); } //} } else if (WindowState == FormWindowState.Maximized) { using (Pen borderPen = new Pen(Color.FromArgb(255, 66, 66, 69), 1)) { Rectangle borderRect = new Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width - 1, ClientRectangle.Height - 1); e.Graphics.DrawRectangle(borderPen, borderRect); } } } protected override void OnResize(EventArgs e) { base.OnResize(e); if (WindowState == FormWindowState.Normal || WindowState == FormWindowState.Maximized) { Invalidate(); } }