using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace BiskLog_Point_Of_Sale.Classes { class GradientCurve : Panel { Color TopColor; Color BottomColor; int wh = 20; public int BorderRadius { get { return wh; } set { wh = value; Invalidate(); } } public Color ColorTopColor { get { return TopColor; } set { TopColor = value; Invalidate(); } } public Color ColorBottomColor { get { return BottomColor; } set { BottomColor = value; Invalidate(); } } [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")] private static extern IntPtr CreateRoundRectRgn ( int nLeftRect, // x-coordinate of upper-left corner int nTopColorRect, // y-coordinate of upper-left corner int nRightRect, // x-coordinate of lower-right corner int nBottomColorRect, // y-coordinate of lower-right corner int nWidthEllipse, // height of ellipse int nHeightEllipse // width of ellipse ); public GradientCurve() { DoubleBuffered = true; } protected override void OnPaint(PaintEventArgs e) { Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.HighQuality; GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddArc(new Rectangle(0, 0, wh, wh), 180, 90); graphicsPath.AddArc(new Rectangle(Width - wh, 0, wh, wh), -90, 90); graphicsPath.AddArc(new Rectangle(Width - wh, Height - wh, wh, wh), 0, 90); graphicsPath.AddArc(new Rectangle(0, Height - wh, wh, wh), 90, 90); e.Graphics.FillPath(new LinearGradientBrush(this.ClientRectangle, this.ColorTopColor,this.ColorBottomColor, 90F), graphicsPath); base.OnPaint(e); } } }