コード例 #1
0
ファイル: MainForm.cs プロジェクト: pklompPCCA/Windows.Forms
        /// <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();
        }
コード例 #2
0
        /// <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());
        }