Save settings on log off or shutdown

This commit is contained in:
Travis Nickles 2020-01-13 20:49:36 -06:00
parent 3074bc1b6e
commit 489d13d02f
2 changed files with 18 additions and 1 deletions

View File

@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DS4WinWPF" xmlns:local="clr-namespace:DS4WinWPF"
Startup="Application_Startup" Exit="Application_Exit" ShutdownMode="OnExplicitShutdown"> Startup="Application_Startup" Exit="Application_Exit" ShutdownMode="OnExplicitShutdown" SessionEnding="Application_SessionEnding">
<Application.Resources> <Application.Resources>
<Style TargetType="{x:Type Button}" x:Key="NoBGHoverBtn"> <Style TargetType="{x:Type Button}" x:Key="NoBGHoverBtn">
<Setter Property="Background" Value="Transparent" /> <Setter Property="Background" Value="Transparent" />

View File

@ -429,6 +429,20 @@ namespace DS4WinWPF
} }
private void Application_Exit(object sender, ExitEventArgs e) private void Application_Exit(object sender, ExitEventArgs e)
{
Logger logger = logHolder.Logger;
logger.Info("Request App Shutdown");
CleanShutdown();
}
private void Application_SessionEnding(object sender, SessionEndingCancelEventArgs e)
{
Logger logger = logHolder.Logger;
logger.Info("User Session Ending");
CleanShutdown();
}
private void CleanShutdown()
{ {
if (runShutdown) if (runShutdown)
{ {
@ -456,6 +470,9 @@ namespace DS4WinWPF
if (ipcClassNameMMA != null) ipcClassNameMMA.Dispose(); if (ipcClassNameMMA != null) ipcClassNameMMA.Dispose();
if (ipcClassNameMMF != null) ipcClassNameMMF.Dispose(); if (ipcClassNameMMF != null) ipcClassNameMMF.Dispose();
LogManager.Flush();
LogManager.Shutdown();
} }
} }
} }