Create a Better looking panel?
-
Hi My UserControl does not look properly, I would like very much someone to help me adjusting it, it only paints well when it is a perfect rectangle otherwise it does not! I would like a panel with this look but when resized displays perfect as well Here is the code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Drawing.Extended; namespace Teste17 { public partial class UserControl5 : UserControl { public UserControl5() { InitializeComponent(); } private void UserControl5_Paint(object sender, PaintEventArgs e) { LinearGradientBrush linearGradientBrush = new LinearGradientBrush(this.ClientRectangle, Color.Black, Color.Black, 45, false); ColorBlend colorBlend = new ColorBlend(); colorBlend.Positions = new float[4]; colorBlend.Positions[0] = 0.00f; colorBlend.Positions[1] = 0.49f; colorBlend.Positions[2] = 0.51f; colorBlend.Positions[3] = 1.00f; colorBlend.Colors = new Color[4]; colorBlend.Colors[0] = Color.FromKnownColor(KnownColor.Window); colorBlend.Colors[1] = Color.FromKnownColor(KnownColor.Window); colorBlend.Colors[2] = Color.FromKnownColor(KnownColor.ControlDark); colorBlend.Colors[3] = Color.FromKnownColor(KnownColor.ControlDark); linearGradientBrush.InterpolationColors = colorBlend; e.Graphics.SmoothingMode = SmoothingMode.HighQuality; ExtendedGraphics extendedGraphics = new ExtendedGraphics(e.Graphics); Pen pen = new Pen(linearGradientBrush); extendedGraphics.DrawRoundRectangle(pen, 0, 0, this.Width - 1, this.Height - 1, 5); } } } The code of using System.Drawing.Extended; is from a friend here in codeproject which name I cannot remenber at the moment...
-
Hi My UserControl does not look properly, I would like very much someone to help me adjusting it, it only paints well when it is a perfect rectangle otherwise it does not! I would like a panel with this look but when resized displays perfect as well Here is the code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Drawing.Extended; namespace Teste17 { public partial class UserControl5 : UserControl { public UserControl5() { InitializeComponent(); } private void UserControl5_Paint(object sender, PaintEventArgs e) { LinearGradientBrush linearGradientBrush = new LinearGradientBrush(this.ClientRectangle, Color.Black, Color.Black, 45, false); ColorBlend colorBlend = new ColorBlend(); colorBlend.Positions = new float[4]; colorBlend.Positions[0] = 0.00f; colorBlend.Positions[1] = 0.49f; colorBlend.Positions[2] = 0.51f; colorBlend.Positions[3] = 1.00f; colorBlend.Colors = new Color[4]; colorBlend.Colors[0] = Color.FromKnownColor(KnownColor.Window); colorBlend.Colors[1] = Color.FromKnownColor(KnownColor.Window); colorBlend.Colors[2] = Color.FromKnownColor(KnownColor.ControlDark); colorBlend.Colors[3] = Color.FromKnownColor(KnownColor.ControlDark); linearGradientBrush.InterpolationColors = colorBlend; e.Graphics.SmoothingMode = SmoothingMode.HighQuality; ExtendedGraphics extendedGraphics = new ExtendedGraphics(e.Graphics); Pen pen = new Pen(linearGradientBrush); extendedGraphics.DrawRoundRectangle(pen, 0, 0, this.Width - 1, this.Height - 1, 5); } } } The code of using System.Drawing.Extended; is from a friend here in codeproject which name I cannot remenber at the moment...
I suggest you abandon System.Drawing.Extended; it has some problems that are fundamental and honestly it's not that flexible. If you're willing to download a larger framework, the most beautiful extended Panel I have ever seen comes from the Ascend.Net project: http://www.codeplex.com/ASCENDNET[^] Absolutely beautiful set of controls.
------------ Cheers, Patrick