blob: 71a494212431e1f19df8854a96418400d909e0bb (
plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace UVtools.GUI.Forms
{
public partial class FrmLoading : Form
{
public Stopwatch StopWatch { get; } = new Stopwatch();
public FrmLoading()
{
InitializeComponent();
}
public FrmLoading(string description) : this()
{
SetDescription(description);
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
e.Handled = true;
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
e.Handled = true;
}
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
e.Handled = true;
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
StopWatch.Restart();
timer.Start();
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
timer.Stop();
StopWatch.Stop();
}
public void SetDescription(string description)
{
Text =
lbDescription.Text = description;
}
public void SetProgress(int value)
{
progressBar.Style = ProgressBarStyle.Blocks;
progressBar.Value = value;
}
private void timer_Tick(object sender, EventArgs e)
{
lbElapsedTime.Text = $"Elapsed Time: {StopWatch.ElapsedMilliseconds}ms";
}
}
}
|