Skip to content

Commit c346592

Browse files
committed
progress bar turns red when there's an error now
1 parent 5faf35e commit c346592

6 files changed

Lines changed: 53 additions & 42 deletions

File tree

FlashpointSecurePlayer/FlashpointSecurePlayer.Designer.cs

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FlashpointSecurePlayer/FlashpointSecurePlayer.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ public FlashpointSecurePlayer() {
4747
}
4848

4949
private void ResetProgressBar() {
50-
registryBackupProgressBar.Style = ProgressBarStyle.Blocks;
51-
registryBackupProgressBar.Value = 0;
52-
SetProgressBarState(registryBackupProgressBar, PBST_NORMAL);
53-
registryBackupProgressBar.Style = ProgressBarStyle.Continuous;
50+
securePlaybackProgressBar.Style = ProgressBarStyle.Blocks;
51+
securePlaybackProgressBar.Value = 0;
52+
securePlaybackProgressBar.Style = ProgressBarStyle.Continuous;
53+
SetProgressBarState(securePlaybackProgressBar, PBST_NORMAL);
5454
}
5555

5656
private void ShowOutput() {
57-
SetProgressBarState(registryBackupProgressBar, PBST_NORMAL);
57+
securePlaybackProgressBar.Style = ProgressBarStyle.Continuous;
58+
SetProgressBarState(securePlaybackProgressBar, PBST_NORMAL);
5859
}
5960

6061
private void ShowOutput(string errorLabelText) {
@@ -64,8 +65,9 @@ private void ShowOutput(string errorLabelText) {
6465

6566
private void ShowError() {
6667
// TODO: why won't the progress bar change colour
67-
SetProgressBarState(registryBackupProgressBar, PBST_ERROR);
68-
registryBackupProgressBar.Value = 100;
68+
securePlaybackProgressBar.Style = ProgressBarStyle.Continuous;
69+
securePlaybackProgressBar.Value = 100;
70+
SetProgressBarState(securePlaybackProgressBar, PBST_ERROR);
6971
}
7072

7173
private void ShowError(string errorLabelText) {
@@ -117,7 +119,7 @@ private async Task ActivateModificationsAsync(string commandLine, ErrorDelegate
117119
ModificationsElement modificationsElement = null;
118120

119121
try {
120-
modificationsElement = GetModificationsElement(true, ModificationsName);
122+
modificationsElement = GetModificationsElement(false, ModificationsName);
121123
} catch (System.Configuration.ConfigurationErrorsException) {
122124
errorDelegate(Properties.Resources.ConfigurationFailedLoad);
123125
}
@@ -251,9 +253,8 @@ private async Task DeactivateModificationsAsync(ErrorDelegate errorDelegate) {
251253

252254
if (activeModificationsElement != null) {
253255
activeModificationsElement.Active = ACTIVE_EXE_CONFIGURATION_NAME;
256+
SetFlashpointSecurePlayerSection(ACTIVE_EXE_CONFIGURATION_NAME);
254257
}
255-
256-
SetFlashpointSecurePlayerSection(ModificationsName);
257258
} catch (System.Configuration.ConfigurationErrorsException) {
258259
errorDelegate(Properties.Resources.ConfigurationFailedLoad);
259260
}
@@ -304,7 +305,7 @@ private async Task StartSecurePlayback() {
304305
return;
305306
}
306307

307-
registryBackupProgressBar.Value = 17;
308+
securePlaybackProgressBar.Value = 17;
308309

309310
// next, uninstall the control
310311
// in case it was already installed before this whole process
@@ -317,7 +318,7 @@ private async Task StartSecurePlayback() {
317318
return;
318319
}
319320

320-
registryBackupProgressBar.Value = 33;
321+
securePlaybackProgressBar.Value = 33;
321322

322323
try {
323324
await RegistryBackup.StartImportAsync(ModificationsName, binaryType).ConfigureAwait(true);
@@ -340,7 +341,7 @@ private async Task StartSecurePlayback() {
340341
return;
341342
}
342343

343-
registryBackupProgressBar.Value = 50;
344+
securePlaybackProgressBar.Value = 50;
344345

345346
// a registry backup is running, install the control
346347
try {
@@ -350,7 +351,7 @@ private async Task StartSecurePlayback() {
350351
return;
351352
}
352353

353-
registryBackupProgressBar.Value = 67;
354+
securePlaybackProgressBar.Value = 67;
354355

355356
try {
356357
await RegistryBackup.StopImportAsync().ConfigureAwait(true);
@@ -366,7 +367,7 @@ private async Task StartSecurePlayback() {
366367
return;
367368
}
368369

369-
registryBackupProgressBar.Value = 83;
370+
securePlaybackProgressBar.Value = 83;
370371

371372
// the registry backup is stopped, uninstall the control
372373
// this will leave the control uninstalled on the system
@@ -379,7 +380,7 @@ private async Task StartSecurePlayback() {
379380
return;
380381
}
381382

382-
registryBackupProgressBar.Value = 100;
383+
securePlaybackProgressBar.Value = 100;
383384
ShowOutput(Properties.Resources.RegistryBackupWasSuccessful);
384385
return;
385386
} else if (!String.IsNullOrEmpty(Server)) {
@@ -404,7 +405,7 @@ await ActivateModificationsAsync(null, delegate (string text) {
404405

405406
Server serverForm = new Server(new Uri(Server));
406407

407-
registryBackupProgressBar.Value = 100;
408+
securePlaybackProgressBar.Value = 100;
408409
Hide();
409410
serverForm.Show();
410411
return;
@@ -428,7 +429,7 @@ await ActivateModificationsAsync(Software, delegate (string text) {
428429
return;
429430
}
430431

431-
registryBackupProgressBar.Value = 50;
432+
securePlaybackProgressBar.Value = 50;
432433

433434
try {
434435
// default to zero in case of error
@@ -457,7 +458,7 @@ await ActivateModificationsAsync(Software, delegate (string text) {
457458
return;
458459
}
459460

460-
registryBackupProgressBar.Value = 100;
461+
securePlaybackProgressBar.Value = 100;
461462
Hide();
462463

463464
if (!process.HasExited) {

FlashpointSecurePlayer/Program.cs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ public enum BINARY_TYPE : uint {
9696
[DllImport("KERNEL32.DLL")]
9797
public static extern bool GetBinaryType(string applicationNamePointer, out BINARY_TYPE binaryTypePointer);
9898

99-
public const int PBM_SETSTATE = 0x0410;
100-
public static readonly IntPtr PBST_NORMAL = (IntPtr)0;
101-
public static readonly IntPtr PBST_ERROR = (IntPtr)1;
102-
public static readonly IntPtr PBST_PAUSED = (IntPtr)2;
99+
public const uint PBM_SETSTATE = 0x0410;
100+
public static readonly IntPtr PBST_NORMAL = (IntPtr)1;
101+
public static readonly IntPtr PBST_ERROR = (IntPtr)2;
102+
public static readonly IntPtr PBST_PAUSED = (IntPtr)3;
103103

104104
[DllImport("USER32.DLL", CharSet = CharSet.Auto, SetLastError = false)]
105105
public static extern IntPtr SendMessage(IntPtr windowHandle, uint message, IntPtr wParam, IntPtr lParam);
@@ -901,7 +901,7 @@ private static Configuration GetActiveEXEConfiguration() {
901901
}
902902

903903
// where should ConfigurationErrorsExceptions all be caught? Review this
904-
private static Configuration GetEXEConfiguration(string name) {
904+
private static Configuration GetEXEConfiguration(bool create, string name) {
905905
// active
906906
if (String.IsNullOrEmpty(name)) {
907907
return GetActiveEXEConfiguration();
@@ -957,12 +957,22 @@ private static Configuration GetEXEConfiguration(string name) {
957957
}
958958
}
959959

960-
EXEConfiguration = exeConfiguration ?? throw new ConfigurationErrorsException();
960+
if (exeConfiguration == null) {
961+
throw new ConfigurationErrorsException();
962+
}
963+
964+
if (!create) {
965+
if (!exeConfiguration.HasFile) {
966+
throw new ConfigurationErrorsException();
967+
}
968+
}
969+
970+
EXEConfiguration = exeConfiguration;
961971
EXEConfigurationName = name;
962972
return EXEConfiguration;
963973
}
964974

965-
public static FlashpointSecurePlayerSection GetFlashpointSecurePlayerSection(string exeConfigurationName) {
975+
public static FlashpointSecurePlayerSection GetFlashpointSecurePlayerSection(bool create, string exeConfigurationName) {
966976
FlashpointSecurePlayerSection flashpointSecurePlayerSection = null;
967977
Configuration exeConfiguration = null;
968978

@@ -977,7 +987,7 @@ public static FlashpointSecurePlayerSection GetFlashpointSecurePlayerSection(str
977987
return Shared.flashpointSecurePlayerSection;
978988
}
979989

980-
exeConfiguration = GetEXEConfiguration(exeConfigurationName);
990+
exeConfiguration = GetEXEConfiguration(create, exeConfigurationName);
981991
}
982992

983993
try {
@@ -1021,7 +1031,7 @@ public static void SetFlashpointSecurePlayerSection(string exeConfigurationName)
10211031
activeEXEConfiguration.Save(ConfigurationSaveMode.Modified);
10221032

10231033
if (!String.IsNullOrEmpty(exeConfigurationName)) {
1024-
Configuration exeConfiguration = GetEXEConfiguration(exeConfigurationName);
1034+
Configuration exeConfiguration = GetEXEConfiguration(true, exeConfigurationName);
10251035
exeConfiguration.Save(ConfigurationSaveMode.Modified);
10261036
}
10271037

@@ -1031,7 +1041,7 @@ public static void SetFlashpointSecurePlayerSection(string exeConfigurationName)
10311041
// does not save!
10321042
public static FlashpointSecurePlayerSection.ModificationsElementCollection.ModificationsElement GetModificationsElement(bool createModificationsElement, string exeConfigurationName) {
10331043
// need the section to operate on
1034-
FlashpointSecurePlayerSection flashpointSecurePlayerSection = GetFlashpointSecurePlayerSection(exeConfigurationName);
1044+
FlashpointSecurePlayerSection flashpointSecurePlayerSection = GetFlashpointSecurePlayerSection(createModificationsElement, exeConfigurationName);
10351045
// get the element
10361046
FlashpointSecurePlayerSection.ModificationsElementCollection.ModificationsElement modificationsElement = flashpointSecurePlayerSection.Modifications.Get(exeConfigurationName) as FlashpointSecurePlayerSection.ModificationsElementCollection.ModificationsElement;
10371047

@@ -1063,7 +1073,7 @@ public static FlashpointSecurePlayerSection.ModificationsElementCollection.Modif
10631073
// does not save!
10641074
public static void SetModificationsElement(FlashpointSecurePlayerSection.ModificationsElementCollection.ModificationsElement modificationsElement, string exeConfigurationName) {
10651075
// need the section to operate on
1066-
FlashpointSecurePlayerSection flashpointSecurePlayerSection = GetFlashpointSecurePlayerSection(exeConfigurationName);
1076+
FlashpointSecurePlayerSection flashpointSecurePlayerSection = GetFlashpointSecurePlayerSection(true, exeConfigurationName);
10671077
// set it, and forget it
10681078
// it gets replaced if it existed already
10691079
flashpointSecurePlayerSection.Modifications.Set(modificationsElement);

FlashpointSecurePlayer/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FlashpointSecurePlayer/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Please ensure Flashpoint is not corrupted, was extracted correctly, and is not r
131131
<value>Connection could not be established with the remote host.</value>
132132
</data>
133133
<data name="CurationMissingModificationName" xml:space="preserve">
134-
<value>This curation is missing a modification name. If you are not a curator, please report this bug.</value>
134+
<value>This curation is missing a modification name.</value>
135135
</data>
136136
<data name="EnvironmentVariablesFailed" xml:space="preserve">
137137
<value>The Environment Variables failed.</value>

FlashpointSecurePlayer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,10 @@ You may notice that because the Flashpoint Secure Player is effectively capable
352352
- Currently, ActiveX Controls will be disabled if they are set to be disabled in Internet Options. The previous ActiveX implementation also had this issue, but I will be looking into the possibility of working around this.
353353
- Currently, only the registry value kind of String (REG_SZ) is supported. Other value kinds such as Binary (REG_BINARY) and MultiStrings (REG_MULTI_SZ) will be supported in a future version.
354354
- Currently, there is no way to edit configuration files other than manually, and a generic "configuration file failed to load" error occurs when there is a syntax error. It would be nice to have a seperate visual editor for configuration files.
355+
- Generally speaking, more specific error reporting would be nice.
355356
- Old CPU Simulator integration?
356357

357358
# <a name="known-issues"></a>Known Issues
358-
- The progress bar is intended to become red when an error occurs, but it does not.
359359
- The compatibility layers have no effect when using Server Mode.
360360

361361
# Questions And Answers

0 commit comments

Comments
 (0)