-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgressForm.cs
More file actions
49 lines (43 loc) · 1.33 KB
/
ProgressForm.cs
File metadata and controls
49 lines (43 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FF13Randomizer
{
public partial class ProgressForm : Form
{
Action<BackgroundWorker> action;
public ProgressForm(string text, Action<BackgroundWorker> action)
{
InitializeComponent();
this.Activate();
this.ControlBox = false;
this.Text = "";
this.action = action;
label1.Text = text;
progressBar1.Maximum = 100;
progressBar1.Step = 1;
progressBar1.Value = 0;
backgroundWorker1.RunWorkerAsync();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
action.Invoke(backgroundWorker1);
}
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
throw new Exception("Randomizer Error", e.Error);
this.Close();
}
}
}