/// <summary>Calculates a new EffectiveEndDate.</summary>
        /// <param name="duration">The number of days the license should last.</param>
        /// <param name="extendExisting">If true, the existing, non-expired license will be extended by the number of days specified in the duration argument.</param>
        /// <returns>The new EffectiveEndDate</returns>
        internal DateTime CalculateNewEffectiveEndDate(int duration, bool extendExisting)
        {
            if (duration > 0 && extendExisting)
            {
                int currentDaysLeft = (int)EffectiveEndDate.Subtract(DateTime.UtcNow.Date).TotalDays;
                if (currentDaysLeft > 0)
                {
                    duration += currentDaysLeft;
                }
            }

            return(DateTime.UtcNow.Date.AddDays(duration));
        }
        /// <summary>Generates the license status text to display.</summary>
        /// <remarks><para>This method is called from <see cref="InitializeLicenseStatusEntries"/>.</para></remarks>
        /// <returns>Returns a string containing the license status text displayed to the user.</returns>
        internal LicenseStatusEntry GenerateLicenseStatusEntry(bool lastValidationSuccessful)
        {
            LicenseStatusIcon entryIcon;
            StringBuilder     status = new StringBuilder();

            if (lastValidationSuccessful)
            {
                //The license is valid, so just set the status text to "Ok."
                entryIcon = LicenseStatusIcon.Ok;
                if (LicenseTypes.Unlicensed == TypeOfLicense)
                {
                    status.Append("Evaluation");
                }
                else
                {
                    status.Append("OK");
                }

                if (ProductOption.OptionType == LicenseProductOption.ProductOptionType.VolumeLicense)
                {
                    status.Append(" (Volume License)");
                }
                else if (ProductOption.OptionType == LicenseProductOption.ProductOptionType.DownloadableLicenseWithTriggerCodeValidation)
                {
                    status.Append(" (Downloaded, Validated)");
                }

                //If it is a time-limited or evaluation license, then show additional information about its expiration.
                if (LicenseTypes.TimeLimited == TypeOfLicense ||
                    LicenseTypes.Unlicensed == TypeOfLicense)
                {
                    DateTime local    = EffectiveEndDate.ToLocalTime();
                    TimeSpan timeLeft = local.Subtract(DateTime.Now.Date);

                    status.Append(" - Expires ");
                    if (1 > timeLeft.TotalDays)
                    {
                        status.Append(local.ToShortTimeString() + " today.");
                    }
                    else if (1 == (int)timeLeft.TotalDays)
                    {
                        status.Append("tomorrow.");
                    }
                    else
                    {
                        status.Append(local.ToLongDateString());
                        status.Append(" (" + ((int)timeLeft.TotalDays).ToString() + " days).");
                    }

                    if (timeLeft.TotalDays <= LicenseConfiguration.TimeLimitedWarningDays)
                    {
                        entryIcon = LicenseStatusIcon.Warning;
                    }
                }
            }
            else
            {
                entryIcon = LicenseStatusIcon.Error;
                status.Append(GenerateLicenseErrorString());
            }

            return(new LicenseStatusEntry(entryIcon, "License", status.ToString()));
        }