using SkullLabs; using System; using System.Drawing; using System.Windows.Forms; namespace SkullLabsAuthExample { public class Form1 : Form { private readonly AuthClient _auth = new AuthClient(); private TextBox _license; private Button _activateBtn; private Label _statusLabel; public Form1() { Text = "Skull Labs Auth - Activate License"; Size = new Size(420, 270); StartPosition = FormStartPosition.CenterScreen; FormBorderStyle = FormBorderStyle.FixedDialog; MaximizeBox = false; BackColor = Color.FromArgb(12, 13, 17); ForeColor = Color.FromArgb(230, 232, 238); Font = new Font("Segoe UI", 9.5f); var title = new Label { Text = "ACTIVATE LICENSE", Font = new Font("Consolas", 11f, FontStyle.Bold), ForeColor = Color.FromArgb(0, 229, 255), Location = new Point(24, 22), Size = new Size(360, 20), }; var hint = new Label { Text = "Paste your license key to verify it against the project.", ForeColor = Color.FromArgb(139, 143, 156), Location = new Point(24, 48), Size = new Size(360, 20), }; var lblKey = new Label { Text = "License key", Location = new Point(24, 80), Size = new Size(120, 18), ForeColor = Color.FromArgb(139, 143, 156) }; _license = new TextBox { Location = new Point(24, 100), Size = new Size(360, 26), BackColor = Color.FromArgb(20, 22, 28), ForeColor = Color.White, BorderStyle = BorderStyle.FixedSingle, Font = new Font("Consolas", 10f), }; _activateBtn = new Button { Text = "Activate", Location = new Point(24, 140), Size = new Size(360, 36), BackColor = Color.FromArgb(0, 229, 255), ForeColor = Color.Black, FlatStyle = FlatStyle.Flat, Font = new Font("Segoe UI", 9.5f, FontStyle.Bold), }; _activateBtn.FlatAppearance.BorderSize = 0; _activateBtn.Click += async (s, e) => await Activate(); _statusLabel = new Label { Location = new Point(24, 188), Size = new Size(360, 22), TextAlign = ContentAlignment.MiddleCenter, ForeColor = Color.FromArgb(139, 143, 156), Text = "Ready", }; AcceptButton = _activateBtn; Controls.AddRange(new Control[] { title, hint, lblKey, _license, _activateBtn, _statusLabel }); } private async System.Threading.Tasks.Task Activate() { _activateBtn.Enabled = false; SetStatus("Verifying...", Color.FromArgb(255, 181, 71)); try { var result = await _auth.LoginWithLicenseAsync(_license.Text.Trim()); if (!result.Ok) { SetStatus($"Activation failed: {result.Error}", Color.FromArgb(255, 51, 102)); return; } SetStatus("Activated.", Color.FromArgb(34, 211, 154)); Hide(); using (var f2 = new Form2(result, _license.Text.Trim())) { f2.ShowDialog(); } Application.Exit(); } catch (Exception ex) { SetStatus($"Error: {ex.Message}", Color.FromArgb(255, 51, 102)); } finally { _activateBtn.Enabled = true; } } private void SetStatus(string text, Color color) { _statusLabel.Text = text; _statusLabel.ForeColor = color; } } }