Provides a mechanism for managing time/usage limited evaluations of products.

Instantiate an instance of this class to read/write the evaluation parameters for the given product. The FirstUseDate is set the first time that the class is instantiated. The LastUseDate is set each time the class is instantiated. The UsageCount is incremented each time the class is instantiated.

Note that evaluation data must be stored somewhere on the users hard disk. It is therefore not too difficult for a sophisticated user to determine the changes made either to registry keys or files (using file/registry monitoring software) and restore the state of these to their pre-installation state (thus resetting the evaluation period). For this reason it is recommended that you don't rely on this mechanism alone. You should also consider limiting the functionality of your product in some way or adding nag screens to discourage long term use of evaluation versions.

If you have a data oriented application you can increase the security of evaluations by storing the current UsageCount somewhere in your database each time the application runs and cross checking this with the number returned by the EvaluationMonitor.

Inheritance: IDisposable
        /// <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;
        }