@@ -42,6 +42,7 @@ private void OnPropertyChanged(string propertyName)
4242 private bool _isLoading = true ;
4343
4444 private bool _isInTray ;
45+ private bool _restartApplication ;
4546 private bool _closeApplication ;
4647
4748 // Indicates a restart message, when settings changed
@@ -288,7 +289,7 @@ private void LoadApplicationList()
288289 private async void MetroWindowMain_Closing ( object sender , CancelEventArgs e )
289290 {
290291 // Hide the application to tray
291- if ( ! _closeApplication && SettingsManager . Current . Window_MinimizeInsteadOfTerminating )
292+ if ( ! _closeApplication && ! _restartApplication && SettingsManager . Current . Window_MinimizeInsteadOfTerminating )
292293 {
293294 e . Cancel = true ;
294295
@@ -298,7 +299,7 @@ private async void MetroWindowMain_Closing(object sender, CancelEventArgs e)
298299 }
299300
300301 // Confirm close
301- if ( ! _closeApplication && SettingsManager . Current . Window_ConfirmClose )
302+ if ( ! _closeApplication && ! _restartApplication && SettingsManager . Current . Window_ConfirmClose )
302303 {
303304 e . Cancel = true ;
304305
@@ -317,16 +318,8 @@ private async void MetroWindowMain_Closing(object sender, CancelEventArgs e)
317318 return ;
318319 }
319320
320- // Save templates
321- if ( TemplateManager . NetworkInterfaceConfigTemplatesChanged && ! ImportExportManager . ForceRestart )
322- TemplateManager . SaveNetworkInterfaceConfigTemplates ( ) ;
323-
324- if ( TemplateManager . WakeOnLANTemplatesChanged && ! ImportExportManager . ForceRestart )
325- TemplateManager . SaveWakeOnLANTemplates ( ) ;
326-
327- // Save settings
328- if ( SettingsManager . Current . SettingsChanged && ! ImportExportManager . ForceRestart )
329- SettingsManager . Save ( ) ;
321+ if ( ! _restartApplication && ! ImportExportManager . ForceRestart )
322+ SaveTemplatesAndSettings ( ) ;
330323
331324 // Unregister HotKeys
332325 if ( RegisteredHotKeys . Count > 0 )
@@ -336,6 +329,20 @@ private async void MetroWindowMain_Closing(object sender, CancelEventArgs e)
336329 if ( notifyIcon != null )
337330 notifyIcon . Dispose ( ) ;
338331 }
332+
333+ private void SaveTemplatesAndSettings ( )
334+ {
335+ // Save templates
336+ if ( TemplateManager . NetworkInterfaceConfigTemplatesChanged )
337+ TemplateManager . SaveNetworkInterfaceConfigTemplates ( ) ;
338+
339+ if ( TemplateManager . WakeOnLANTemplatesChanged )
340+ TemplateManager . SaveWakeOnLANTemplates ( ) ;
341+
342+ // Save settings
343+ if ( SettingsManager . Current . SettingsChanged )
344+ SettingsManager . Save ( ) ;
345+ }
339346 #endregion
340347
341348 #region Application Views
@@ -727,9 +734,11 @@ private void CloseApplicationAction()
727734
728735 private void RestartApplication ( )
729736 {
737+ SaveTemplatesAndSettings ( ) ;
738+
730739 Process . Start ( ConfigurationManager . Current . ApplicationFullName ) ;
731740
732- _closeApplication = true ;
741+ _restartApplication = true ;
733742 Close ( ) ;
734743 }
735744
0 commit comments