@@ -34,7 +34,7 @@ public class HDRProfileHandler : BaseViewModel
3434 private HDRProfileSettings _settings ;
3535 private MonitorManager _monitorManager ;
3636
37- Dictionary < ApplicationItem , ApplicationState > _lastRestartAppStates = new Dictionary < ApplicationItem , ApplicationState > ( ) ;
37+ Dictionary < ApplicationItem , ApplicationState > _lastAppStates = new Dictionary < ApplicationItem , ApplicationState > ( ) ;
3838
3939 private string SettingsPath => $ "{ System . AppDomain . CurrentDomain . BaseDirectory } HDRProfile_Settings.xml";
4040
@@ -160,7 +160,7 @@ private void MonitorManager_HDRIsActiveChanged(object sender, EventArgs e)
160160 private void MonitorManager_AutoHDRChanged ( object sender , EventArgs e )
161161 {
162162 SaveSettings ( ) ;
163- SetHDRBasedOnCurrentApplication ( ) ;
163+ UpdateHDRModeBasedOnCurrentApplication ( ) ;
164164 }
165165
166166 private void TrayMenuHelper_OpenViewRequested ( object sender , EventArgs e )
@@ -242,7 +242,7 @@ private void Settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
242242 Logs . AddException ( ex ) ;
243243 }
244244 if ( e . PropertyName . Equals ( nameof ( Settings . HDRMode ) ) )
245- SetHDRBasedOnCurrentApplication ( ) ;
245+ UpdateHDRModeBasedOnCurrentApplication ( ) ;
246246 Logs . LoggingEnabled = Settings . Logging ;
247247 SaveSettings ( ) ;
248248 }
@@ -316,7 +316,7 @@ public void Start()
316316 MonitorManager . StartMonitoring ( ) ;
317317 Logs . Add ( $ "HDR Monitoring started", false ) ;
318318 Started = true ;
319- SetHDRBasedOnCurrentApplication ( ) ;
319+ UpdateHDRModeBasedOnCurrentApplication ( ) ;
320320
321321 }
322322 }
@@ -394,6 +394,7 @@ private void ApplicationItem_PropertyChanged(object sender, PropertyChangedEvent
394394 private void AddAplication ( )
395395 {
396396 ApplicationAdder adder = new ApplicationAdder ( ) ;
397+ adder . DialogService = DialogService ;
397398 adder . OKClicked += ( o , e ) =>
398399 {
399400 if ( ! Settings . ApplicationItems . Any ( pi => pi . ApplicationFilePath == adder . ApplicationItem . ApplicationFilePath ) )
@@ -413,11 +414,11 @@ private void RemoveApplication(ApplicationItem process)
413414 private void ProcessWatcher_RunningOrFocusedChanged ( object sender , EventArgs e )
414415 {
415416 CurrentApplication = ProcessWatcher . CurrentRunningApplicationItem ;
416- SetHDRBasedOnCurrentApplication ( ) ;
417+ UpdateHDRModeBasedOnCurrentApplication ( ) ;
417418
418419 }
419420
420- private void SetHDRBasedOnCurrentApplication ( )
421+ private void UpdateHDRModeBasedOnCurrentApplication ( )
421422 {
422423 lock ( _accessLock )
423424 {
@@ -457,7 +458,8 @@ private void SetHDRBasedOnCurrentApplication()
457458 MonitorManager . DeactivateHDR ( monitor ) ;
458459 }
459460 }
460- UpdateRestartAppStates ( ( IDictionary < ApplicationItem , ApplicationState > ) ProcessWatcher . Applications , activateHDR ) ;
461+ var currentApplications = ProcessWatcher . Applications ;
462+ UpdateRestartAppStates ( ( IDictionary < ApplicationItem , ApplicationState > ) currentApplications , activateHDR ) ;
461463
462464 if ( MonitorManager . GlobalHDRIsActive )
463465 Logs . Add ( $ "HDR is active", false ) ;
@@ -472,24 +474,23 @@ private void SetHDRBasedOnCurrentApplication()
472474 }
473475 }
474476
475- private void UpdateRestartAppStates ( IDictionary < ApplicationItem , ApplicationState > applicationStates , bool restartIfNecessary )
477+ private void UpdateRestartAppStates ( IDictionary < ApplicationItem , ApplicationState > applicationStates , bool restartApps )
476478 {
477- Dictionary < ApplicationItem , ApplicationState > newLastStates = new Dictionary < ApplicationItem , ApplicationState > ( ) ;
479+ Dictionary < ApplicationItem , ApplicationState > newLastAppStates = new Dictionary < ApplicationItem , ApplicationState > ( ) ;
478480 foreach ( var applicationState in applicationStates )
479481 {
480- if ( ! applicationState . Key . RestartProcess )
481- continue ;
482- newLastStates . Add ( applicationState . Key , applicationState . Value ) ;
483- if ( restartIfNecessary )
482+ newLastAppStates . Add ( applicationState . Key , applicationState . Value ) ;
483+
484+ if ( restartApps )
484485 {
485- if ( ! _lastRestartAppStates . ContainsKey ( applicationState . Key ) && applicationState . Value != ApplicationState . None )
486+ if ( ! _lastAppStates . ContainsKey ( applicationState . Key ) && applicationState . Value != ApplicationState . None )
486487 RestartProcess ( applicationState . Key ) ;
487- else if ( _lastRestartAppStates . ContainsKey ( applicationState . Key ) && applicationState . Value != ApplicationState . None && _lastRestartAppStates [ applicationState . Key ] == ApplicationState . None )
488+ else if ( _lastAppStates . ContainsKey ( applicationState . Key ) && applicationState . Value != ApplicationState . None && _lastAppStates [ applicationState . Key ] == ApplicationState . None )
488489 RestartProcess ( applicationState . Key ) ;
489490 }
490491 }
491- _lastRestartAppStates . Clear ( ) ;
492- _lastRestartAppStates = newLastStates ;
492+ _lastAppStates . Clear ( ) ;
493+ _lastAppStates = newLastAppStates ;
493494 }
494495
495496 private void RestartProcess ( ApplicationItem application )
0 commit comments