Example #1
0
        public bool IsLicensed()
        {
            EncryptedLicenseProvider provider = new EncryptedLicenseProvider();
            EncryptedLicense         license  = provider.GetLicense(LicenseBO.ValidationParameters, GetLicenseFile());

            return(license != null);
        }
Example #2
0
 protected virtual bool InstallLicenseKey(string key)
 {
     try {
         if (_licenseType == null)
         {
             _license = LicenseProvider.InstallLicense(_licenseFile, key);
         }
         else
         {
             _license = LicenseProvider.InstallLicense(_licenseType, key);
         }
         if (_license == null)
         {
             //MessageBox.Show(invalidKeyMsg.Text, invalidKeyTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
             MessageForm frm = new LlamaCarbonCopy.Controls.Forms.MessageForm();
             frm.Msg = invalidKeyMsg;
             frm.ShowDialog();
         }
         return(_license != null);
     }
     catch {
         //MessageBox.Show(errorMsg.Text, errorTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
         MessageForm frm = new LlamaCarbonCopy.Controls.Forms.MessageForm();
         frm.Msg = errorMsg;
         frm.ShowDialog();
     }
     return(false);
 }
        //Comment Add for other path.
        //static string _licenseFile =Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\LicensedApp\LicensedApp.lic";
        //static string _licenseFile = AppDomain.CurrentDomain.BaseDirectory + @"\LicensedApp\LicensedApp.lic";
        //static string _licenseFile = Application.ExecutablePath + @"\LicensedApp\LicensedApp.lic";


        /// <summary>
        /// Function used for Check the License
        /// </summary>
        /// <returns>bool</returns>
        public static bool CheckLicense()
        {
            if (LicenseManager.CurrentContext.UsageMode == LicenseUsageMode.Runtime)
            {
                return(true);
            }
            Application.EnableVisualStyles();

            // check if there is a valid license for the application

            EncryptedLicenseProvider provider = new EncryptedLicenseProvider();

            _license = provider.GetLicense(LICENSE_PARAMETERS, _licenseFile);
            // if there is no installed license then display the evaluation dialog until
            // the user installs a license or selects Exit or Continue

            while (_license == null)
            {
                EvaluationMonitor evaluationMonitor = new RegistryEvaluationMonitor("MyEvaluationPassword");
                EvaluationDialog  evaluationDialog  = new EvaluationDialog(evaluationMonitor, "Guru Components");
                evaluationDialog.EvaluationMessage = " Thank for you evaluating Guru Components Netrix Professional v2.0. To continue your evaluation please click the Continue Evaluation button";
                evaluationDialog.ExtendedTrialDays = 60;
                evaluationDialog.TrialDays         = 60;
                EvaluationDialogResult dialogResult = evaluationDialog.ShowDialog();
                if (dialogResult == EvaluationDialogResult.Exit)
                {
                    return(false);                                                //exit the app
                }
                if (dialogResult == EvaluationDialogResult.Continue)
                {
                    break;                                                       //exit the loop
                }
                if (dialogResult == EvaluationDialogResult.InstallLicense)
                {
                    EncryptedLicenseInstallForm licenseForm = new EncryptedLicenseInstallForm();
                    _license = licenseForm.ShowDialog("HTML EDITOR", _licenseFile, null);
                }
            }

            return(true);
        }
Example #4
0
        public void AttemptLicense()
        {
            EncryptedLicenseProvider provider = new EncryptedLicenseProvider();
            EncryptedLicense         license  = provider.GetLicense(LicenseBO.ValidationParameters, GetLicenseFile());

            if (license != null)
            {
                MessageForm frm = new MessageForm();
                frm.Msg = "Your license is installed properly.  No further licensing is required.";
                frm.ShowDialog();
                return;
            }
            else
            {
                LicenseForm licfrm = new LicenseForm();
                license = licfrm.ShowDialog("Llama Carbon Copy", Properties.Settings.Default.Website, LicenseBO.GetLicenseFile());
                if (licfrm.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
                if (license != null)
                {
                    //congratulate
                    OnLicensed(EventArgs.Empty);
                    MessageForm frm = new MessageForm();
                    frm.Msg = "You have successfully installed your license.";
                    frm.ShowDialog();
                }
                else
                {
                    //ask if they want to try again
                    QuestionForm frm = new QuestionForm();
                    frm.Msg = "There was a problem creating your license.  Would you like to try again?";
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        AttemptLicense();
                    }
                }
            }
        }
Example #5
0
        public bool IsActive()
        {
            EncryptedLicenseProvider provider = new EncryptedLicenseProvider();
            EncryptedLicense         license  = provider.GetLicense(LicenseBO.ValidationParameters, GetLicenseFile());

            if (license == null)
            {
                EvaluationMonitor monitor = new EvaluationMonitor("SpittingImage");
                if (monitor.DaysInUse > 15 || monitor.Invalid)
                {
                    QuestionForm frm = new QuestionForm();
                    frm.Msg = "Your trial license has expired.  Would you like to enter a license key to activate the software?";
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        LicenseForm licfrm = new LicenseForm();
                        license = licfrm.ShowDialog("Llama Carbon Copy", Properties.Settings.Default.Website, LicenseBO.GetLicenseFile());
                        if (license != null)
                        {
                            OnLicensed(EventArgs.Empty);
                        }
                    }
                }
                else
                {
                    MessageForm frm = new MessageForm();
                    frm.Msg = string.Format("You are on day {0} of your 15 day evaluation.", monitor.DaysInUse);
                    frm.ShowDialog();
                    return(true);
                }
            }
            if (license == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #6
0
        /// <summary>
        /// Perform licence checking actions.
        /// </summary>
        /// <param name="ribbon">Ribbon control reference.</param>
        protected void PerformLicenceChecking(KryptonRibbon ribbon)
        {
            // Define the encryted licence information
            EncryptedLicenseProvider.SetParameters(_licenseParameters);

            // If an error has already been shown, then no need to test license again
            bool validated = _usageShown;

            if (!validated)
            {
                // Is there a valid license registered?
                License license = null;
                validated = LicenseManager.IsValid(typeof(KryptonRibbon), ribbon, out license);

                // Valid license is not enough!
                if (validated)
                {
                    validated = false;
                    EncryptedLicense encryptedLicense = license as EncryptedLicense;

                    string[] productInfo = encryptedLicense.ProductInfo.Split(',');

                    // Must contain two fields separated by a comma
                    if (productInfo.Length == 2)
                    {
                        // Both fields must not be empty
                        if (!string.IsNullOrEmpty(productInfo[0]) &&
                            !string.IsNullOrEmpty(productInfo[1]))
                        {
                            // Product code must be ...
                            //    'S' = Krypton Suite
                            // And version number...
                            //    '400'
                            validated = (productInfo[1].Equals("400")) && (productInfo[0][0] == 'S');
                        }
                    }
                }
            }

            // If we need to indicate the invalid licensing state...
            if (!validated)
            {
                // Get hold of the assembly version number
                Version thisVersion = Assembly.GetExecutingAssembly().GetName().Version;

                // We want a unique 30 day evaluation period for each major/minor version
                EvaluationMonitor monitor = new EvaluationMonitor(_monitorId + thisVersion.Major.ToString() + thisVersion.Minor.ToString());

                // If the first time we have failed to get the licence or
                // the 30 days evaluation period has expired or the component
                // has been created over a 3000 times then...
                if ((monitor.UsageCount == 0) ||
                    (monitor.UsageCount > 3000) ||
                    (monitor.DaysInUse > 30))
                {
                    // At runtime show a NAG screen to prevent unauthorized use of the control
                    if (LicenseManager.CurrentContext.UsageMode == LicenseUsageMode.Runtime)
                    {
                        MessageBox.Show("This application was created using an unlicensed version of\n" +
                                        "the Krypton Suite control from Component Factory Pty Ltd.\n\n" +
                                        "You must contact your software supplier in order to resolve\n" +
                                        "the licencing issue.",
                                        "Unlicensed Application",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else
                    {
                        LicenseInstallForm form = new LicenseInstallForm();
                        form.ShowDialog(typeof(KryptonRibbon));
                    }
                }
            }

            // No need to perform check check more than once
            _usageShown = true;
        }
Example #7
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     this.DialogResult = DialogResult.Cancel;
     _license          = null;
     this.Close();
 }
 /// <summary>
 /// Install the license key entered by the user
 /// </summary>
 /// <param name="key">The key to install</param>
 /// <returns>True if the license was installed successfully</returns>
 protected virtual bool InstallLicenseKey(string key)
 {
     try
     {
         if (_licenseType == null)
             _license = LicenseProvider.InstallLicense(_licenseFile, key);
         else
             _license = LicenseProvider.InstallLicense(_licenseType, key);
         if (_license == null)
         {
             MessageBox.Show(invalidKeyMsg.Text, invalidKeyTitle.Text,
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         return (_license != null);
     }
     catch
     {
         MessageBox.Show(errorMsg.Text, errorTitle.Text,
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     return false;
 }
Example #9
0
 protected virtual bool InstallLicenseKey(string key)
 {
     try {
         if (_licenseType == null)
             _license = LicenseProvider.InstallLicense(_licenseFile, key);
         else
             _license = LicenseProvider.InstallLicense(_licenseType, key);
         if (_license == null) {
             //MessageBox.Show(invalidKeyMsg.Text, invalidKeyTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
             MessageForm frm = new LlamaCarbonCopy.Controls.Forms.MessageForm();
             frm.Msg = invalidKeyMsg;
             frm.ShowDialog();
         }
         return (_license != null);
     }
     catch {
         //MessageBox.Show(errorMsg.Text, errorTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
         MessageForm frm = new LlamaCarbonCopy.Controls.Forms.MessageForm();
         frm.Msg = errorMsg;
         frm.ShowDialog();
     }
     return false;
 }
Example #10
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     this.DialogResult = DialogResult.Cancel;
     _license = null;
     this.Close();
 }