-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathFrmPleaseWaitBox.cs
More file actions
148 lines (134 loc) · 5.37 KB
/
Copy pathFrmPleaseWaitBox.cs
File metadata and controls
148 lines (134 loc) · 5.37 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
using GeoTagNinja.Helpers;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using Themer = WinFormsDarkThemerNinja.Themer;
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;
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(control: this, senderForm: this);
_frmMainAppInstance.Enabled = false;
GetControlNames();
Themer.ApplyThemeToControl(
control: this,
themeStyle: HelperVariables.UserSettingUseDarkMode ?
Themer.ThemeStyle.Custom :
Themer.ThemeStyle.Default
);
}
/// <summary>
/// Provides the localised labels for the various Control names
/// </summary>
private void GetControlNames()
{
HelperNonStatic helperNonstatic = new();
IEnumerable<Control> controls = helperNonstatic.GetAllControls(control: this);
foreach (Control control in controls)
{
if (
control is Button or
CheckBox or
GroupBox or
Label or
RadioButton or
TabPage
)
{
// gets logged inside.
HelperControlAndMessageBoxHandling.FakeControlTypes fakeControlType = control 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
};
control.Text = HelperControlAndMessageBoxHandling.ReturnControlText(
controlName: control.Name,
fakeControlType: fakeControlType);
}
}
}
private void FrmPleaseWaitBox_FormClosing(object sender, FormClosingEventArgs e)
{
_frmMainAppInstance.Enabled = true;
}
/// <summary>
/// Updates the individual Controls' visibilities depending on what stage/action we're on/at
/// </summary>
/// <param name="stage"></param>
internal void UpdateControlsVisibility(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 = true;
lbl_PleaseWaitBoxActionScanning.Visible = false;
// lbl_PleaseWaitBoxActionParsing.Visible = true;
lbl_PleaseWaitBoxActionPopulatingListView.Visible = false;
}
//// No longer relevant. Has been obsoleted by streaming data capability intro
//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
}
}