コード例 #1
0
        /// <summary>Activate button click event handler</summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void activateButton_Click(object sender, EventArgs e)
        {
            string lfContent  = "";
            bool   successful = false;

            activateButton.Enabled = false;
            Cursor = Cursors.WaitCursor;

            //TODO: set the value of m_license.CurrentSessionCode to the value stored when the Generate button was clicked
            successful = m_License.ProcessActivateInstallationLicenseFileResponse(activationCodeTextBox.Text, ref lfContent);

            activateButton.Enabled = true;
            Cursor = Cursors.Default;

            //TODO: clear the stored session code value here
            if (!successful)
            {
                MessageBox.Show(this, "Activation Failed.  Reason: " + m_License.LastError.ErrorString, "Manual Activation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (m_License.SaveLicenseFile(lfContent))
            {
                MessageBox.Show(this, "Activation Successful!", "Manual Activation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                m_License.ResetSessionCode();
                m_MainDialog.ReloadLicense();
                Close();
            }
            else
            {
                MessageBox.Show(this, "Activation Failed.  Reason: " + m_License.LastError.ErrorString, "Manual Activation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }