Пример #1
0
        /// <param name="version">The current version of your application</param>
        public static void Run(Guid projectId, string licenseKeyFormat, string version = null)
        {
            LicenseSystem.Initialize(projectId, licenseKeyFormat, version);
#endif
            var result = LicenseSystem.CheckComputer().Result;
            if (result == LicenseSystem.ComputerCheckResult.Valid)
            {
                return;
            }

            var form = new ActivationForm(licenseKeyFormat, ApplicationName ?? GetDefaultApplicationName(),
                                          ApplicationIcon ?? GetDefaultApplicationIcon());

            if (form.ShowDialog() != DialogResult.OK)
            {
                Environment.Exit(-1);
            }

            LicenseSystem.VerifyAccess().Wait();
        }
Пример #2
0
        private async void continueButton_Click(object sender, EventArgs e)
        {
            activationProgressBar.Style   = ProgressBarStyle.Marquee;
            activationProgressBar.Visible = true;

            licenseKeyTextBox.Enabled = false;
            continueButton.Enabled    = false;

            var result = await LicenseSystem.ActivateComputer(licenseKeyTextBox.Text);

            activationProgressBar.Style = ProgressBarStyle.Blocks;
            activationProgressBar.Value = 100;

            string errorMessage;

            switch (result)
            {
            case LicenseSystem.ComputerActivationResult.Valid:
                DialogResult = DialogResult.OK;
                return;

            case LicenseSystem.ComputerActivationResult.ConnectionFailed:
                errorMessage =
                    "The connection failed. Please make sure that your computer is connected to the internet and that your firewall allows the connection and try again.";
                break;

            case LicenseSystem.ComputerActivationResult.ProjectDisabled:
                errorMessage = "The project that hosts the licenses was disabled. Please contact the product owner.";
                break;

            case LicenseSystem.ComputerActivationResult.ProjectNotFound:
                errorMessage = "The project that hosts the licenses was not found. Please contact the product owner.";
                break;

            case LicenseSystem.ComputerActivationResult.LicenseSystemNotFound:
                errorMessage = "The license system was not found. Please contact the product owner.";
                break;

            case LicenseSystem.ComputerActivationResult.LicenseSystemDisabled:
                errorMessage = "The license system was disabled. Please contact the product owner.";
                break;

            case LicenseSystem.ComputerActivationResult.LicenseSystemExpired:
                errorMessage = "The license system expired. Please contact the product owner.";
                break;

            case LicenseSystem.ComputerActivationResult.LicenseNotFound:
                errorMessage = "The license key is not valid. Please try again.";
                break;

            case LicenseSystem.ComputerActivationResult.LicenseDeactivated:
                errorMessage = "The license was deactivated. Please contact the product owner if you think that is a mistake.";
                break;

            case LicenseSystem.ComputerActivationResult.LicenseExpired:
                errorMessage = "The license expired. Please renew your subscription.";
                break;

            case LicenseSystem.ComputerActivationResult.IpLimitExhausted:
                errorMessage = "The ip address limit of your license was exhausted. Please try again tomorrow.";
                break;

            case LicenseSystem.ComputerActivationResult.ActivationLimitExhausted:
                errorMessage = "The activation limit of your license was exhausted. Please contact the product owner, he can clear your existing activations.";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            MessageBox.Show(this, errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            activationProgressBar.Visible = false;
            licenseKeyTextBox.Enabled     = true;
            continueButton.Enabled        = true;
        }
Пример #3
0
        /// <summary>
        ///     Run the license UI service which will initialize the LicenseSystem, check if the current computer is already
        ///     activated and if not, show a dialog that will guide the user through the activation
        /// </summary>
        /// <param name="projectId">The guid of the license system project</param>
        /// <param name="licenseKeyFormat">The format of the license keys</param>
#if ALLOW_OFFLINE
        /// <param name="publicKey">The public key of your license system to validate offline licenses</param>
        /// <param name="version">The current version of your application</param>
        public static async Task Run(Guid projectId, string licenseKeyFormat, RSAParameters publicKey, string version =
                                     null)
        {
            LicenseSystem.Initialize(projectId, licenseKeyFormat, publicKey, version);
Пример #4
0
 private void licenseKeyTextBox_TextChanged(object sender, EventArgs e)
 {
     continueButton.Enabled = LicenseSystem.TryParseLicenseKey(licenseKeyTextBox.Text, out _);
 }