117 lines
3.0 KiB
C#
117 lines
3.0 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
|
|
namespace MicronSync.Components
|
|
{
|
|
public partial class DonationUI : Form
|
|
{
|
|
public static readonly string donateUrl = "http://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=K5TKEUREWNCA8";
|
|
public static readonly string websiteUrl = "http://reboundsoftware.weebly.com";
|
|
private bool userCloseForm = false;
|
|
private bool timerStopped = false;
|
|
|
|
public DonationUI()
|
|
{
|
|
InitializeComponent();
|
|
StartTimer();
|
|
}
|
|
|
|
private void StartTimer()
|
|
{
|
|
timerStopped = false;
|
|
|
|
bwTimer.DoWork += BwTimer_DoWork;
|
|
bwTimer.RunWorkerCompleted += BwTimer_RunWorkerCompleted;
|
|
bwTimer.ProgressChanged += BwTimer_ProgressChanged;
|
|
|
|
bwTimer.WorkerReportsProgress = true;
|
|
bwTimer.RunWorkerAsync();
|
|
}
|
|
|
|
#region Timer
|
|
|
|
BackgroundWorker bwTimer = new BackgroundWorker();
|
|
|
|
private void BwTimer_ProgressChanged(object sender, ProgressChangedEventArgs e)
|
|
{
|
|
progWait.PerformStep();
|
|
}
|
|
|
|
private void BwTimer_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
|
{
|
|
if (progWait.Value == 100)
|
|
{
|
|
userCloseForm = true;
|
|
btnContinue.Enabled = true;
|
|
}
|
|
}
|
|
|
|
private void BwTimer_DoWork(object sender, DoWorkEventArgs e)
|
|
{
|
|
int position = progWait.Value;
|
|
int stepAmount = progWait.Step;
|
|
|
|
while (progWait.Value < 100 &&
|
|
!timerStopped)
|
|
{
|
|
Thread.Sleep(250);
|
|
position += stepAmount;
|
|
bwTimer.ReportProgress(position);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Form
|
|
|
|
private void DonationUI_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
e.Cancel = true;
|
|
|
|
if (userCloseForm)
|
|
e.Cancel = false;
|
|
}
|
|
|
|
private void btnContinue_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void enterRegistrationKeyToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
timerStopped = true;
|
|
|
|
NewRegKeyUI newKey = new NewRegKeyUI();
|
|
newKey.ShowDialog();
|
|
|
|
if (!newKey.userKeyValid)
|
|
{
|
|
StartTimer();
|
|
}
|
|
else
|
|
{
|
|
bwTimer.Dispose();
|
|
|
|
userCloseForm = true;
|
|
Close();
|
|
}
|
|
}
|
|
|
|
private void donateToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
System.Diagnostics.Process.Start(
|
|
donateUrl);
|
|
}
|
|
|
|
private void websiteToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
System.Diagnostics.Process.Start(
|
|
websiteUrl);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|