using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; namespace PokerGameSetup; internal sealed class CasinoProgressBar : Control { private int value; private double shimmerPhase; public int Value { get => value; set { int clamped = Math.Max(0, Math.Min(100, value)); if (this.value != clamped) { this.value = clamped; Invalidate(); } } } public double ShimmerPhase { get => shimmerPhase; set { shimmerPhase = value; Invalidate(); } } public CasinoProgressBar() { SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); Font = new Font("Segoe UI", 9f, FontStyle.Bold); } protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; g.PixelOffsetMode = PixelOffsetMode.HighQuality; Rectangle rect = new Rectangle(0, 0, Width - 1, Height - 1); int radius = Math.Min(rect.Height - 1, 8); // Track background using (GraphicsPath trackPath = CreateRoundedRectangle(rect, radius)) { using (SolidBrush trackBrush = new SolidBrush(Color.FromArgb(20, 23, 25))) { g.FillPath(trackBrush, trackPath); } // Filled portion if (value > 0) { int fillWidth = (int)Math.Round((rect.Width - 2) * (value / 100.0)); if (fillWidth > 2) { Rectangle fillRect = new Rectangle(rect.X + 1, rect.Y + 1, fillWidth, rect.Height - 2); int fillRadius = Math.Min(fillRect.Height - 1, radius); using (GraphicsPath fillPath = CreateRoundedRectangle(fillRect, fillRadius)) { // Gold gradient using (LinearGradientBrush fillBrush = new LinearGradientBrush( fillRect, Color.FromArgb(245, 218, 140), Color.FromArgb(195, 150, 65), 90f)) { g.FillPath(fillBrush, fillPath); } // Top specular line using (Pen highlightPen = new Pen(Color.FromArgb(160, 255, 255, 255), 1f)) { g.DrawLine(highlightPen, fillRect.Left + 2, fillRect.Top + 1, fillRect.Right - 2, fillRect.Top + 1); } // Animated Shimmer glint wave int shimmerPos = (int)((shimmerPhase * (rect.Width + 120)) % (rect.Width + 120)) - 60; Rectangle shimmerRect = new Rectangle(shimmerPos, fillRect.Y, 50, fillRect.Height); if (shimmerRect.Right > fillRect.Left && shimmerRect.Left < fillRect.Right) { using (LinearGradientBrush shimmerBrush = new LinearGradientBrush( shimmerRect, Color.Transparent, Color.FromArgb(120, 255, 255, 240), 0f)) { ColorBlend blend = new ColorBlend(3); blend.Colors = new Color[] { Color.Transparent, Color.FromArgb(140, 255, 255, 255), Color.Transparent }; blend.Positions = new float[] { 0f, 0.5f, 1f }; shimmerBrush.InterpolationColors = blend; GraphicsState state = g.Save(); g.SetClip(fillPath); g.FillRectangle(shimmerBrush, shimmerRect); g.Restore(state); } } } } } // Track border using (Pen borderPen = new Pen(Color.FromArgb(90, 75, 52), 1f)) { g.DrawPath(borderPen, trackPath); } } } private static GraphicsPath CreateRoundedRectangle(Rectangle r, int d) { GraphicsPath path = new GraphicsPath(); if (d <= 0) { path.AddRectangle(r); return path; } int x = r.X; int y = r.Y; int w = r.Width; int h = r.Height; path.AddArc(x, y, d, d, 180, 90); path.AddArc(x + w - d, y, d, d, 270, 90); path.AddArc(x + w - d, y + h - d, d, d, 0, 90); path.AddArc(x, y + h - d, d, d, 90, 90); path.CloseFigure(); return path; } }