using System;
using System.Windows.Forms;

namespace Quasar.Keygen
{
    public partial class FrmKeygen : Form
    {
        public FrmKeygen()
        {
            InitializeComponent();
        }

        private void btnGenerate_Click(object sender, EventArgs e)
        {
            string hardwareID = txtHardwareID.Text.Trim();

            if (string.IsNullOrEmpty(hardwareID))
            {
                MessageBox.Show("Please enter a Hardware ID.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            try
            {
                string bin = LicenseGenerator.GenerateBIN(hardwareID);
                txtBIN.Text = bin;
                btnCopy.Enabled = true;
                MessageBox.Show("BIN code generated successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error generating BIN: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void btnCopy_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtBIN.Text))
            {
                Clipboard.SetText(txtBIN.Text);
                MessageBox.Show("BIN code copied to clipboard!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}
