Ejemplo n.º 1
0
        /// <summary>Initializes application features</summary>
        /// <param name="features">Features - object</param>
        /// <param name="license">ReadOnlyLicense - license object</param>
        /// <param name="successful">Whether license is reloaded successfully or not</param>
        public static void InitializeFeatures(Features features, SampleReadOnlyLicense license, bool successful)
        {
            XmlNode optionsNode = null;

            features.ListFeatures.Clear();
            Enum e = LicenseFeatures.Copy;

            //Get the SimpleTextEditorOptions node from License custom data string
            if (!string.IsNullOrEmpty(license.LicenseCustomData))
            {
                optionsNode = GetCustomDataXml(license.LicenseCustomData);
            }

            //If LicenseCustomData does not contains settings for SimpleTextEditor Options then fall back to Product Option CustomData
            if (optionsNode == null && !string.IsNullOrEmpty(license.ProductOption.CustomData))
            {
                //Get the SimpleTextEditorOptions node from Product option custom data string
                optionsNode = GetCustomDataXml(license.ProductOption.CustomData);
            }

            foreach (object name in Enum.GetValues(e.GetType()))
            {
                features.AddFeature(new Feature(name.ToString(), !successful ? false : Features.GetFeatureEnabled(optionsNode, (LicenseFeatures)name), Features.GetDisplayName((LicenseFeatures)name)));
            }
        }
Ejemplo n.º 2
0
        /// <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();
        }
Ejemplo n.º 3
0
 /// <summary>Default main form constructor</summary>
 public MainForm()
 {
     InitializeComponent();
     m_License        = new SampleReadOnlyLicense();
     m_CurrentLicense = m_License;
 }
Ejemplo n.º 4
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());
        }