16internal sealed class BlinkPopupForm : Form
35 private readonly System.Windows.Forms.Timer? _blinkTimer;
44 private bool _blinkPhase;
53 private readonly List<DreamineButton> _blinkButtons =
new();
63 public DialogResult Result {
get;
private set; } = DialogResult.Cancel;
93 FormBorderStyle = FormBorderStyle.None;
94 StartPosition = FormStartPosition.CenterScreen;
95 Size =
new Size(480, 260);
96 ShowInTaskbar =
false;
98 BackColor = options.
Color1;
102 Padding =
new Padding(2);
104 var titleLabel =
new Label
106 Text = options.Title ??
string.Empty,
108 Font =
new Font(
"Segoe UI", 20f, FontStyle.Bold),
109 Dock = DockStyle.Top,
111 TextAlign = ContentAlignment.MiddleCenter
114 var messageLabel =
new Label
116 Text = options.Message ??
string.Empty,
118 Font =
new Font(
"Segoe UI", 12f),
119 Dock = DockStyle.Fill,
120 TextAlign = ContentAlignment.MiddleCenter
123 var buttonPanel =
new FlowLayoutPanel
125 Dock = DockStyle.Bottom,
127 FlowDirection = FlowDirection.RightToLeft,
128 Padding =
new Padding(0, 0, 16, 16),
129 BackColor = Color.Transparent
132 if (!
string.IsNullOrEmpty(options.
OkText))
134 var okButton =
new DreamineButton { Content = options.
OkText, Width = 110, Height = 36, CornerRadius = 6, Margin =
new Padding(8, 12, 0, 0) };
135 okButton.MouseUp += (_, e) =>
137 if (e.Button == MouseButtons.Left && okButton.ClientRectangle.Contains(e.Location))
139 Result = DialogResult.OK;
143 buttonPanel.Controls.Add(okButton);
144 _blinkButtons.Add(okButton);
147 if (!
string.IsNullOrEmpty(options.
CancelText))
149 var cancelButton =
new DreamineButton { Content = options.
CancelText, Width = 110, Height = 36, CornerRadius = 6, Margin =
new Padding(8, 12, 0, 0) };
150 cancelButton.MouseUp += (_, e) =>
152 if (e.Button == MouseButtons.Left && cancelButton.ClientRectangle.Contains(e.Location))
154 Result = DialogResult.Cancel;
158 buttonPanel.Controls.Add(cancelButton);
159 _blinkButtons.Add(cancelButton);
170 _blinkTimer =
new System.Windows.Forms.Timer { Interval = options.BlinkIntervalMs };
171 _blinkTimer.Tick += (_, _) =>
173 _blinkPhase = !_blinkPhase;
174 var phaseColor = _blinkPhase ? options.Color2 : options.
Color1;
175 BackColor = phaseColor;
179 foreach (var btn
in _blinkButtons)
180 btn.BackColor = tinted;
202 protected override void OnPaint(PaintEventArgs e)
209 using var pen =
new Pen(Color.FromArgb(90, 255, 255, 255), 1.5f);
210 e.Graphics.DrawRectangle(pen, 0, 0, Width - 1, Height - 1);
229 protected override void Dispose(
bool disposing)
232 _blinkTimer?.Dispose();
233 base.Dispose(disposing);