Esempio n. 1
0
        private void btnFinish_Click(object sender, EventArgs e)
        {
            if (txtProductKey.Text.Length <= 0)
            {
                CMessageBox.Show("Product Key cannot be empty!", "Error", MessageBoxButtons.OK, Resources.error_64x64);
                lblActivationStatus.Text = "Status: The product key was empty.";
                Size = new Size(Size.Width, 168);
                return;
            }

            LicenseInfo temp = LicenseEngine.GetLicenseInfo(txtProductKey.Text);

            if (!temp.IsEmpty)
            {
                if (temp.Type == utility.Licensing.LicenseType.Trial)
                {
                    if (DateTime.Now.Date >= temp.ExpirationDate.Date)
                    {
                        CMessageBox.Show($"Trial key is no longer valid for use. " +
                                         $"It expired on: {temp.ExpirationDate.Date.ToShortDateString()}. " +
                                         "You can request a new one by using the \"Purchase New Product Key\" button.", "Error", MessageBoxButtons.OK, Resources.error_64x64);
                        lblActivationStatus.Text = "Status: Invalid trial key; expired.";
                        return;
                    }
                }

                lblActivationStatus.Text    = "Status: Successful!";
                Settings.Default.ProductKey = txtProductKey.Text;
                Settings.Default.Save();
                info = temp;

                infoPropGrid.SelectedObject = info;
                Size = new Size(Size.Width, 370);
            }
            else
            {
                CMessageBox.Show("Invalid product key!", "Error", MessageBoxButtons.OK, Resources.error_64x64);
                lblActivationStatus.Text = "Status: The product key you entered was invalid.";
                Size = new Size(Size.Width, 168);
                return;
            }
        }