Save current Opacity when hiding the form in order to be able to restore the value when form is restored

fixes #12
This commit is contained in:
pjunior 2017-08-25 14:40:07 -03:00 committed by Lorenz Cuno Klopfenstein
parent 01e13034a4
commit 9b0a007242
2 changed files with 7 additions and 3 deletions

View file

@ -73,7 +73,6 @@ namespace OnTopReplica {
//Reset special modes
FullscreenManager.SwitchBack();
ClickThroughEnabled = false;
Opacity = 1.0;
//Restore main form in a platform-dependent method
Program.Platform.RestoreForm(this);

View file

@ -7,6 +7,8 @@ namespace OnTopReplica.Platforms {
class WindowsSeven : WindowsVista {
private double? PreviousOpacity { get; set; }
public override void PreHandleFormInit() {
//Set Application ID
WindowsSevenMethods.SetCurrentProcessExplicitAppUserModelID("LorenzCunoKlopfenstein.OnTopReplica.MainForm");
@ -19,6 +21,7 @@ namespace OnTopReplica.Platforms {
}
public override void HideForm(MainForm form) {
PreviousOpacity = form.Opacity;
form.Opacity = 0;
}
@ -27,8 +30,10 @@ namespace OnTopReplica.Platforms {
}
public override void RestoreForm(MainForm form) {
if (form.Opacity == 0.0)
form.Opacity = 1.0;
if (form.Opacity == 0.0) {
form.Opacity = PreviousOpacity.GetValueOrDefault(1.0);
PreviousOpacity = null;
}
form.Show();
}