Files
panaceantech/ThirdParty/IntelliProtector/VS2010SampleNET (src)/VS2010SampleNET (src)/FormRegistrationByEmail.cs

73 lines
2.1 KiB
C#

using System;
using System.Windows.Forms;
using IntelliProtectorService;
namespace VS2010SampleNET
{
public partial class FormRegistrationByEmail : Form
{
private readonly string _certificateName;
public FormRegistrationByEmail(string certificateName)
{
_certificateName = certificateName;
InitializeComponent();
}
private void btnSaveCertificate_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(tbLicenseCode.Text))
{
MessageBox.Show(@"Please specify the license code", @"License is empty");
return;
}
using(SaveFileDialog saveFileDialog = new SaveFileDialog())
{
saveFileDialog.FileName = _certificateName;
saveFileDialog.OverwritePrompt = true;
saveFileDialog.InitialDirectory = Application.StartupPath;
saveFileDialog.Filter = @"Data Files (*.dat)|*.dat|All Files (*.*)|*.*";
if (saveFileDialog.ShowDialog() != DialogResult.OK)
return;
bool result = IntelliProtector.CreateRegistrationRequestCertificate(saveFileDialog.FileName, tbLicenseCode.Text);
if (result == false)
MessageBox.Show(@"Error, certificate is not saved!");
}
}
private void btnUseCertificate_Click(object sender, EventArgs e)
{
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.InitialDirectory = Application.StartupPath;
openFileDialog.Filter = @"Data Files (*.dat)|*.dat|All Files (*.*)|*.*";
if (openFileDialog.ShowDialog() != DialogResult.OK)
return;
bool result = IntelliProtector.UseRegistrationResponseCertificate(openFileDialog.FileName);
if (result == false)
MessageBox.Show(@"Error, certificate is not used!");
}
UpdateRegistrationStatus();
}
void UpdateRegistrationStatus()
{
lRegistrationStatus.Text = IntelliProtector.IsSoftwareRegistered() ? @"registered" : @"not registered";
}
private void btnClose_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void FormRegistrationByEmail_Load(object sender, EventArgs e)
{
UpdateRegistrationStatus();
}
}
}