/// <summary>Deactivate License button click event handler</summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void deactivateButton_Click(object sender, EventArgs e) { if (!m_IsEvaluation) { if (m_License.DeactivateOnline()) { m_EvaluationLicense = new SampleSelfSignedLicense(); File.Delete(LicenseConfiguration.LicenseFilePath); if (m_EvaluationLicense.CreateExpiredEvaluation()) { m_CurrentLicense = m_EvaluationLicense; MessageBox.Show("The license has been deactivated successfully.", "License Deactivation", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("The license was not deactivated. Error: (" + m_License.LastError.ErrorNumber + ")" + m_License.LastError.ErrorString, "License Deactivation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("The license was not deactivated. Error: (" + m_License.LastError.ErrorNumber + ")" + m_License.LastError.ErrorString, "License Deactivation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } ReloadLicense(); } }
/// <summary>If license is trial license enabled all application features</summary> /// <param name="features">Features - object</param> /// <param name="license">ReadOnlyLicense - license object</param> public static void InitializeTrialFeatures(Features features, SampleSelfSignedLicense license) { features.ListFeatures.Clear(); Enum e = LicenseFeatures.Copy; foreach (object name in Enum.GetValues(e.GetType())) { features.AddFeature(new Feature(name.ToString(), true, Features.GetDisplayName((LicenseFeatures)name))); } }
/// <summary>Reloads the license file and refreshes the status on the main form.</summary> public void ReloadLicense() { m_License = new SampleReadOnlyLicense(); m_EvaluationLicense = new SampleSelfSignedLicense(); m_CurrentLicense = m_License; if (!m_License.LoadFile(LicenseConfiguration.LicenseFilePath)) { 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; refreshLicenseButton.Enabled = false; deactivateButton.Enabled = false; return; } m_CurrentLicense = m_EvaluationLicense; m_IsEvaluation = true; if (!m_EvaluationLicense.LoadFile(LicenseConfiguration.LicenseFilePath)) { if (!m_EvaluationLicense.CreateFreshEvaluation()) { statusTextLabel.Text = "Invalid. " + m_License.LastError.ErrorString; return; } else { if (!m_EvaluationLicense.LoadFile(LicenseConfiguration.LicenseFilePath)) { statusTextLabel.Text = "Invalid. " + m_License.LastError.ErrorString; return; } } } } else { m_CurrentLicense = m_License; m_IsEvaluation = false; } RefreshLicenseStatus(); }
/// <summary>Reloads the license file and refreshes the status on the main form.</summary> /// <returns>bool</returns> public bool ReloadLicense() { m_License = new SampleReadOnlyLicense(); m_EvaluationLicense = new SampleSelfSignedLicense(); //Get the Evaluation Encryption envelope warning message. if (m_License.LastError.ErrorNumber == LicenseError.ERROR_PLUS_EVALUATION_WARNING) { m_WarningMessage = "Warning: (" + m_License.LastError.ErrorNumber + ") " + m_License.LastError.ErrorString; } m_CurrentLicense = m_License; m_IsEvaluation = false; bool successful = m_License.LoadFile(LicenseConfiguration.LicenseFilePath); if (!successful) { m_EvaluationLicense = new SampleSelfSignedLicense(); m_CurrentLicense = m_EvaluationLicense; m_IsEvaluation = true; successful = m_EvaluationLicense.LoadFile(LicenseConfiguration.LicenseFilePath); if (!successful) { successful = m_EvaluationLicense.CreateFreshEvaluation(); if (successful) { successful = m_EvaluationLicense.LoadFile(LicenseConfiguration.LicenseFilePath); } } } if (m_IsEvaluation) { SplashScreen.InitializeTrialFeatures(m_Features, m_EvaluationLicense); } else { SplashScreen.InitializeFeatures(m_Features, m_License, successful); } this.mnuNew.Enabled = newToolStripButton.Enabled = m_Features.CheckStatus(LicenseFeatures.New.ToString()); this.mnuOpen.Enabled = openToolStripButton.Enabled = m_Features.CheckStatus(LicenseFeatures.Open.ToString()); this.mnuPrint.Enabled = printToolStripButton.Enabled = m_Features.CheckStatus(LicenseFeatures.Print.ToString()); this.mnuFind.Enabled = findToolStripButton.Enabled = m_Features.CheckStatus(LicenseFeatures.Find.ToString()); this.mnuSave.Enabled = saveToolStripButton.Enabled = m_Features.CheckStatus(LicenseFeatures.Save.ToString()); this.mnuSelectAll.Enabled = m_Features.CheckStatus(LicenseFeatures.SelectAll.ToString()); this.mnuCut.Enabled = cutToolStripButton.Enabled = m_Features.CheckStatus(LicenseFeatures.Cut.ToString()); this.mnuCopy.Enabled = copyToolStripButton.Enabled = m_Features.CheckStatus(LicenseFeatures.Copy.ToString()); this.mnuPaste.Enabled = pasteToolStripButton.Enabled = m_Features.CheckStatus(LicenseFeatures.Paste.ToString()); this.mnuSaveAs.Enabled = m_Features.CheckStatus(LicenseFeatures.SaveAs.ToString()); this.mnuReplace.Enabled = m_Features.CheckStatus(LicenseFeatures.Replace.ToString()); if (!successful) { mnuRefreshLicense.Enabled = false; UpdateLicenseStatusProperty(); return(false); } return(RefreshLicenseStatus()); }