-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
FrmPleaseWaitBox.cs
129 lines (117 loc) · 4.82 KB
/
FrmPleaseWaitBox.cs
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using GeoTagNinja.Helpers;
namespace GeoTagNinja;
public partial class FrmPleaseWaitBox : Form
{
private FrmMainApp _frmMainAppInstance =
(FrmMainApp)Application.OpenForms[name: "FrmMainApp"];
public FrmPleaseWaitBox()
{
InitializeComponent();
Debug.Assert(condition: _frmMainAppInstance != null, message: $"{nameof(_frmMainAppInstance)} != null");
lbl_CancelPressed.Visible = false;
HelperControlThemeManager.SetThemeColour(themeColour: HelperVariables.UserSettingUseDarkMode
? ThemeColour.Dark
: ThemeColour.Light, parentControl: this);
lbl_PleaseWaitBoxActionScanning.Visible = false;
lbl_PleaseWaitBoxActionParsing.Visible = false;
lbl_PleaseWaitBoxActionPopulatingListView.Visible = false;
}
private void btn_Cancel_Click(object sender, EventArgs e)
{
// Check if `_cts` is already disposed or null
if (_frmMainAppInstance._cts == null ||
_frmMainAppInstance._cts.Token.IsCancellationRequested)
{
Console.WriteLine(value: "Cancellation already requested or `_cts` disposed.");
return;
}
// Request cancellation
_frmMainAppInstance._cts.Cancel();
Enabled = false;
lbl_CancelPressed.Visible = true;
}
private void FrmPleaseWaitBox_Load(object sender, EventArgs e)
{
HelperControlAndMessageBoxHandling.ReturnControlText(cItem: this, senderForm: this);
_frmMainAppInstance.Enabled = false;
HelperNonStatic helperNonstatic = new();
IEnumerable<Control> c = helperNonstatic.GetAllControls(control: this);
foreach (Control cItem in c)
{
if (
cItem is Button ||
cItem is CheckBox ||
cItem is GroupBox ||
cItem is Label ||
cItem is RadioButton ||
cItem is TabPage
)
{
// gets logged inside.
HelperControlAndMessageBoxHandling.FakeControlTypes fakeControlType = cItem switch
{
Button => HelperControlAndMessageBoxHandling.FakeControlTypes.Button,
CheckBox => HelperControlAndMessageBoxHandling.FakeControlTypes.CheckBox,
GroupBox => HelperControlAndMessageBoxHandling.FakeControlTypes.GroupBox,
Label => HelperControlAndMessageBoxHandling.FakeControlTypes.Label,
RadioButton => HelperControlAndMessageBoxHandling.FakeControlTypes.RadioButton,
TabPage => HelperControlAndMessageBoxHandling.FakeControlTypes.TabPage,
_ => HelperControlAndMessageBoxHandling.FakeControlTypes.Undefined
};
cItem.Text = HelperControlAndMessageBoxHandling.ReturnControlText(controlName: cItem.Name,
fakeControlType: fakeControlType);
}
}
}
private void FrmPleaseWaitBox_FormClosing(object sender, FormClosingEventArgs e)
{
_frmMainAppInstance.Enabled = true;
}
internal void UpdateLabels(ActionStages stage)
{
if (stage == ActionStages.SCANNING)
{
lbl_ParsingFolders.Visible = false;
lbl_CancelPressed.Visible = false;
lbl_PleaseWaitBoxMessage.Visible = false;
lbl_PressCancelToStop.Visible = true;
btn_Cancel.Visible = true;
lbl_PleaseWaitBoxActionScanning.Visible = true;
lbl_PleaseWaitBoxActionParsing.Visible = false;
lbl_PleaseWaitBoxActionPopulatingListView.Visible = false;
}
else if (stage == ActionStages.PARSING)
{
lbl_ParsingFolders.Visible = true;
lbl_CancelPressed.Visible = false;
lbl_PleaseWaitBoxMessage.Visible = true;
lbl_PressCancelToStop.Visible = false;
btn_Cancel.Visible = false;
lbl_PleaseWaitBoxActionScanning.Visible = false;
lbl_PleaseWaitBoxActionParsing.Visible = true;
lbl_PleaseWaitBoxActionPopulatingListView.Visible = false;
}
else if (stage == ActionStages.POPULATING_LISTVIEW)
{
lbl_ParsingFolders.Visible = false;
lbl_CancelPressed.Visible = false;
lbl_PleaseWaitBoxMessage.Visible = true;
lbl_PressCancelToStop.Visible = false;
btn_Cancel.Visible = false;
lbl_PleaseWaitBoxActionScanning.Visible = false;
lbl_PleaseWaitBoxActionParsing.Visible = false;
lbl_PleaseWaitBoxActionPopulatingListView.Visible = true;
}
Application.DoEvents();
}
internal enum ActionStages
{
SCANNING,
PARSING,
POPULATING_LISTVIEW
}
}