236 lines
7.3 KiB
C#
236 lines
7.3 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
using System.Windows.Forms;
|
|
|
|
namespace PokerGameSetup;
|
|
|
|
internal sealed class RouletteControl : Control
|
|
{
|
|
public double Angle;
|
|
|
|
public RouletteControl()
|
|
{
|
|
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
|
|
}
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
{
|
|
Graphics g = e.Graphics;
|
|
g.SmoothingMode = SmoothingMode.AntiAlias;
|
|
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
|
|
|
float cx = (float)Width / 2f;
|
|
float cy = (float)Height / 2f;
|
|
float maxR = Math.Min(cx, cy) - 4f;
|
|
|
|
// 1. Ambient Warm Radial Glow behind the wheel
|
|
using (GraphicsPath glowPath = new GraphicsPath())
|
|
{
|
|
glowPath.AddEllipse(cx - maxR - 4f, cy - maxR - 4f, (maxR + 4f) * 2f, (maxR + 4f) * 2f);
|
|
using (PathGradientBrush pgb = new PathGradientBrush(glowPath))
|
|
{
|
|
pgb.CenterColor = Color.FromArgb(40, 229, 190, 112);
|
|
pgb.SurroundColors = new Color[] { Color.Transparent };
|
|
g.FillPath(pgb, glowPath);
|
|
}
|
|
}
|
|
|
|
// 2. Outer Mahogany Wood Rim
|
|
float woodR = maxR;
|
|
using (LinearGradientBrush woodBrush = new LinearGradientBrush(
|
|
new RectangleF(cx - woodR, cy - woodR, woodR * 2f, woodR * 2f),
|
|
Color.FromArgb(76, 40, 24),
|
|
Color.FromArgb(42, 20, 12),
|
|
45f))
|
|
{
|
|
g.FillEllipse(woodBrush, cx - woodR, cy - woodR, woodR * 2f, woodR * 2f);
|
|
}
|
|
|
|
// Outer wood rim border
|
|
using (Pen woodPen = new Pen(Color.FromArgb(105, 58, 32), 1.5f))
|
|
{
|
|
g.DrawEllipse(woodPen, cx - woodR, cy - woodR, woodR * 2f, woodR * 2f);
|
|
}
|
|
|
|
// 16 Golden Brass Studs / Rivets around wood rim
|
|
float rivetR = woodR - 5f;
|
|
for (int r = 0; r < 16; r++)
|
|
{
|
|
double rad = r * Math.PI * 2.0 / 16.0;
|
|
float rx = cx + (float)Math.Cos(rad) * rivetR;
|
|
float ry = cy + (float)Math.Sin(rad) * rivetR;
|
|
using (SolidBrush studBrush = new SolidBrush(Color.FromArgb(235, 205, 130)))
|
|
{
|
|
g.FillEllipse(studBrush, rx - 1.5f, ry - 1.5f, 3f, 3f);
|
|
}
|
|
}
|
|
|
|
// 3. Brass Ball Track
|
|
float brassR = woodR - 10f;
|
|
using (LinearGradientBrush brassBrush = new LinearGradientBrush(
|
|
new RectangleF(cx - brassR, cy - brassR, brassR * 2f, brassR * 2f),
|
|
Color.FromArgb(215, 175, 95),
|
|
Color.FromArgb(145, 110, 50),
|
|
135f))
|
|
{
|
|
g.FillEllipse(brassBrush, cx - brassR, cy - brassR, brassR * 2f, brassR * 2f);
|
|
}
|
|
|
|
// Inner track step
|
|
float innerTrackR = brassR - 4f;
|
|
using (SolidBrush trackBed = new SolidBrush(Color.FromArgb(30, 24, 18)))
|
|
{
|
|
g.FillEllipse(trackBed, cx - innerTrackR, cy - innerTrackR, innerTrackR * 2f, innerTrackR * 2f);
|
|
}
|
|
|
|
// 4. Numbered Pockets Ring (37 slots)
|
|
float pocketOuterR = innerTrackR - 1f;
|
|
float pocketInnerR = pocketOuterR * 0.68f;
|
|
|
|
for (int i = 0; i < 37; i++)
|
|
{
|
|
Color pocketColor;
|
|
if (i == 0)
|
|
{
|
|
pocketColor = Color.FromArgb(25, 120, 65); // 0 Green
|
|
}
|
|
else
|
|
{
|
|
pocketColor = (i % 2 == 0) ? Color.FromArgb(165, 32, 42) : Color.FromArgb(22, 26, 28);
|
|
}
|
|
|
|
float startAngle = (float)Angle + (float)i * 360f / 37f;
|
|
float sweepAngle = 360f / 37f + 0.2f;
|
|
|
|
using (SolidBrush pBrush = new SolidBrush(pocketColor))
|
|
{
|
|
g.FillPie(pBrush, cx - pocketOuterR, cy - pocketOuterR, pocketOuterR * 2f, pocketOuterR * 2f, startAngle, sweepAngle);
|
|
}
|
|
}
|
|
|
|
// Divider frets (thin gold lines between pockets)
|
|
using (Pen fretPen = new Pen(Color.FromArgb(210, 180, 110), 1f))
|
|
{
|
|
for (int i = 0; i < 37; i++)
|
|
{
|
|
double rad = ((Angle + i * 360.0 / 37.0) * Math.PI) / 180.0;
|
|
float x1 = cx + (float)Math.Cos(rad) * pocketInnerR;
|
|
float y1 = cy + (float)Math.Sin(rad) * pocketInnerR;
|
|
float x2 = cx + (float)Math.Cos(rad) * pocketOuterR;
|
|
float y2 = cy + (float)Math.Sin(rad) * pocketOuterR;
|
|
g.DrawLine(fretPen, x1, y1, x2, y2);
|
|
}
|
|
}
|
|
|
|
// Pocket border rings
|
|
using (Pen pocketBorder = new Pen(InstallerForm.Gold, 1.2f))
|
|
{
|
|
g.DrawEllipse(pocketBorder, cx - pocketOuterR, cy - pocketOuterR, pocketOuterR * 2f, pocketOuterR * 2f);
|
|
g.DrawEllipse(pocketBorder, cx - pocketInnerR, cy - pocketInnerR, pocketInnerR * 2f, pocketInnerR * 2f);
|
|
}
|
|
|
|
// 5. Emerald Center Felt
|
|
using (LinearGradientBrush feltBrush = new LinearGradientBrush(
|
|
new RectangleF(cx - pocketInnerR, cy - pocketInnerR, pocketInnerR * 2f, pocketInnerR * 2f),
|
|
Color.FromArgb(18, 55, 38),
|
|
Color.FromArgb(10, 32, 22),
|
|
90f))
|
|
{
|
|
g.FillEllipse(feltBrush, cx - pocketInnerR, cy - pocketInnerR, pocketInnerR * 2f, pocketInnerR * 2f);
|
|
}
|
|
|
|
// 6. Brass Turret Cone (Center Spindle)
|
|
float coneR = pocketInnerR * 0.62f;
|
|
using (LinearGradientBrush coneBrush = new LinearGradientBrush(
|
|
new RectangleF(cx - coneR, cy - coneR, coneR * 2f, coneR * 2f),
|
|
Color.FromArgb(245, 215, 135),
|
|
Color.FromArgb(150, 110, 50),
|
|
45f))
|
|
{
|
|
g.FillEllipse(coneBrush, cx - coneR, cy - coneR, coneR * 2f, coneR * 2f);
|
|
}
|
|
using (Pen coneBorder = new Pen(Color.FromArgb(255, 235, 160), 1.2f))
|
|
{
|
|
g.DrawEllipse(coneBorder, cx - coneR, cy - coneR, coneR * 2f, coneR * 2f);
|
|
}
|
|
|
|
// 7. Rotating 4-Way Brass Cross Handles with Spherical Ball Knobs
|
|
GraphicsState gstate = g.Save();
|
|
g.TranslateTransform(cx, cy);
|
|
g.RotateTransform((float)Angle);
|
|
|
|
float spokeLen = coneR * 1.35f;
|
|
using (Pen spokePen = new Pen(Color.FromArgb(235, 200, 115), 3.5f))
|
|
{
|
|
spokePen.StartCap = LineCap.Round;
|
|
spokePen.EndCap = LineCap.Round;
|
|
g.DrawLine(spokePen, -spokeLen, 0, spokeLen, 0);
|
|
g.DrawLine(spokePen, 0, -spokeLen, 0, spokeLen);
|
|
}
|
|
|
|
// 4 Spherical Gold Knobs on handle tips
|
|
float[] knobAngles = new float[] { 0, 90, 180, 270 };
|
|
foreach (float a in knobAngles)
|
|
{
|
|
double rad = a * Math.PI / 180.0;
|
|
float kx = (float)Math.Cos(rad) * spokeLen;
|
|
float ky = (float)Math.Sin(rad) * spokeLen;
|
|
|
|
using (SolidBrush knobBrush = new SolidBrush(Color.FromArgb(255, 225, 140)))
|
|
{
|
|
g.FillEllipse(knobBrush, kx - 3.5f, ky - 3.5f, 7f, 7f);
|
|
}
|
|
using (Pen knobBorder = new Pen(Color.FromArgb(160, 120, 55), 1f))
|
|
{
|
|
g.DrawEllipse(knobBorder, kx - 3.5f, ky - 3.5f, 7f, 7f);
|
|
}
|
|
}
|
|
|
|
// Central Acorn Dome / Finial
|
|
float domeR = 7f;
|
|
using (LinearGradientBrush domeBrush = new LinearGradientBrush(
|
|
new RectangleF(-domeR, -domeR, domeR * 2f, domeR * 2f),
|
|
Color.FromArgb(255, 240, 180),
|
|
Color.FromArgb(170, 130, 60),
|
|
45f))
|
|
{
|
|
g.FillEllipse(domeBrush, -domeR, -domeR, domeR * 2f, domeR * 2f);
|
|
}
|
|
// Specular pin highlight on central dome
|
|
using (SolidBrush specBrush = new SolidBrush(Color.FromArgb(230, 255, 255, 255)))
|
|
{
|
|
g.FillEllipse(specBrush, -2.5f, -2.5f, 2.5f, 2.5f);
|
|
}
|
|
|
|
g.Restore(gstate);
|
|
|
|
// 8. 3D Ivory Ball with Drop Shadow
|
|
double ballAngle = (0.0 - Angle * 1.85) * Math.PI / 180.0;
|
|
float ballOrbitR = (innerTrackR + brassR) / 2f - 1f;
|
|
float bx = cx + (float)Math.Cos(ballAngle) * ballOrbitR;
|
|
float by = cy + (float)Math.Sin(ballAngle) * ballOrbitR;
|
|
|
|
// Drop shadow
|
|
using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(90, 0, 0, 0)))
|
|
{
|
|
g.FillEllipse(shadowBrush, bx - 3f, by - 2f, 9f, 9f);
|
|
}
|
|
|
|
// Ivory ball body
|
|
RectangleF ballRect = new RectangleF(bx - 4.5f, by - 4.5f, 9f, 9f);
|
|
using (LinearGradientBrush ballBrush = new LinearGradientBrush(
|
|
ballRect,
|
|
Color.FromArgb(255, 255, 250),
|
|
Color.FromArgb(215, 210, 195),
|
|
45f))
|
|
{
|
|
g.FillEllipse(ballBrush, ballRect);
|
|
}
|
|
// Specular gleam on ball
|
|
using (SolidBrush gleamBrush = new SolidBrush(Color.White))
|
|
{
|
|
g.FillEllipse(gleamBrush, bx - 2.5f, by - 2.5f, 2.8f, 2.8f);
|
|
}
|
|
}
|
|
}
|