Ejemplo n.º 1
0
 /// <summary>Handles the Main Form close event</summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">Event arguments</param>
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (m_Semaphore != null)
     {
         m_Semaphore.Close(); // close our network session if it is open
         m_Semaphore = null;
     }
 }
Ejemplo n.º 2
0
        /// <summary>Reloads the license file and refreshes the status on the main form.</summary>
        public void ReloadLicense()
        {
            if (!m_License.LoadFile(LicenseConfiguration.LicenseFilePath))
            {
                refreshLicenseButton.Enabled = false;
                deactivateButton.Enabled     = false;

                if (m_License.LastError.ErrorNumber == LicenseError.ERROR_PLUS_EVALUATION_INVALID)
                {
                    //Invalid Protection PLUS 5 SDK evaluation envelope.
                    statusTextLabel.Text           = m_License.LastError.ErrorString;
                    activateButton.Enabled         = false;
                    activateManuallyButton.Enabled = false;
                }
                else
                {
                    switch (m_License.LastError.ErrorNumber)
                    {
                    case LicenseError.ERROR_COULD_NOT_LOAD_LICENSE:
                        statusTextLabel.Text = string.Format("No license found - activation is required.", m_License.LastError.ErrorNumber);
                        break;

                    case LicenseError.ERROR_LICENSE_NOT_EFFECTIVE_YET:
                        string effectiveAsOf;

                        DateTime local = m_License.EffectiveStartDate.ToLocalTime();
                        int      daysUntilEffective = (int)local.Subtract(DateTime.Now.Date).TotalDays;

                        if (1 < daysUntilEffective)
                        {
                            effectiveAsOf = string.Format("{0} ({1} days).", local.ToLongDateString(), daysUntilEffective);
                        }
                        else if (1 == daysUntilEffective)
                        {
                            effectiveAsOf = "tomorrow.";
                        }
                        else
                        {
                            effectiveAsOf = string.Format("{0} today.", local.ToShortTimeString());
                        }

                        statusTextLabel.Text = string.Format("The license is not effective until {1}", m_License.LastError.ErrorNumber);
                        break;

                    default:
                        statusTextLabel.Text = "Invalid.  " + m_License.LastError.ErrorString;
                        break;
                    }
                }

                userCountLabel.Text = "N/A";

                if (m_Semaphore != null)
                {
                    m_Semaphore.Close(); // close our network session if it is open
                    m_Semaphore = null;
                }

                return;
            }

            refreshLicenseButton.Enabled = true;
            deactivateButton.Enabled     = true;

            RefreshLicenseStatus();
        }