99using System . ComponentModel ;
1010using System . Diagnostics ;
1111using System . Globalization ;
12- using System . IO ;
1312using System . Linq ;
1413using System . Threading ;
1514using System . Threading . Tasks ;
@@ -41,8 +40,8 @@ public class AutoHDRDaemon : BaseViewModel
4140
4241 public RelayCommand ActivateHDRCommand { get ; private set ; }
4342 public RelayCommand DeactivateHDRCommand { get ; private set ; }
44- public RelayCommand AddApplicationCommand { get ; private set ; }
45- public RelayCommand < ApplicationItem > RemoveApplicationCommand { get ; private set ; }
43+ public RelayCommand AddAssignmentCommand { get ; private set ; }
44+ public RelayCommand < ApplicationProfileAssignment > RemoveAssignmentCommand { get ; private set ; }
4645
4746 public RelayCommand AddProfileCommand { get ; private set ; }
4847 public RelayCommand < Profile > RemoveProfileCommand { get ; private set ; }
@@ -224,8 +223,8 @@ private void CreateRelayCommands()
224223 {
225224 ActivateHDRCommand = new RelayCommand ( MonitorManager . ActivateHDR ) ;
226225 DeactivateHDRCommand = new RelayCommand ( MonitorManager . DeactivateHDR ) ;
227- AddApplicationCommand = new RelayCommand ( AddAplication ) ;
228- RemoveApplicationCommand = new RelayCommand < ApplicationItem > ( RemoveApplication ) ;
226+ AddAssignmentCommand = new RelayCommand ( AddAssignment ) ;
227+ RemoveAssignmentCommand = new RelayCommand < ApplicationProfileAssignment > ( RemoveAssignment ) ;
229228 AddProfileCommand = new RelayCommand ( AddProfile ) ;
230229 RemoveProfileCommand = new RelayCommand < Profile > ( RemoveProfile ) ;
231230
@@ -265,12 +264,12 @@ private void LoadSettings()
265264 {
266265 Globals . Instance . LoadSettings ( ) ;
267266
268- Settings . ApplicationItems . CollectionChanged += ApplicationItems_CollectionChanged ;
267+ Settings . ApplicationProfileAssignments . CollectionChanged += ApplicationProfileAssigments_CollectionChanged ;
269268 Settings . PropertyChanged += Settings_PropertyChanged ;
270- foreach ( var application in Settings . ApplicationItems )
269+ foreach ( var assignment in Settings . ApplicationProfileAssignments )
271270 {
272- ApplicationWatcher . AddProcess ( application ) ;
273- application . PropertyChanged += ApplicationItem_PropertyChanged ;
271+ ApplicationWatcher . AddProcess ( assignment . Application ) ;
272+ assignment . Application . PropertyChanged += ApplicationItem_PropertyChanged ;
274273 }
275274 Tools . Logs . Add ( "Settings loaded" , false ) ;
276275 }
@@ -384,27 +383,27 @@ public void Stop()
384383
385384 #region Process handling
386385
387- private void ApplicationItems_CollectionChanged ( object sender , NotifyCollectionChangedEventArgs e )
386+ private void ApplicationProfileAssigments_CollectionChanged ( object sender , NotifyCollectionChangedEventArgs e )
388387 {
389388 lock ( _accessLock )
390389 {
391390 switch ( e . Action )
392391 {
393392 case NotifyCollectionChangedAction . Add :
394- foreach ( var applicationItem in e . NewItems )
393+ foreach ( var assignment in e . NewItems )
395394 {
396- Tools . Logs . Add ( $ "Application added: { ( ( ApplicationItem ) applicationItem ) . ApplicationName } ", false ) ;
397- ApplicationWatcher . AddProcess ( ( ( ApplicationItem ) applicationItem ) ) ;
398- ( ( ApplicationItem ) applicationItem ) . PropertyChanged += ApplicationItem_PropertyChanged ;
395+ Tools . Logs . Add ( $ "Application added: { ( ( ApplicationProfileAssignment ) assignment ) . Application . ApplicationName } ", false ) ;
396+ ApplicationWatcher . AddProcess ( ( ( ApplicationProfileAssignment ) assignment ) . Application ) ;
397+ ( ( ApplicationProfileAssignment ) assignment ) . PropertyChanged += ApplicationItem_PropertyChanged ;
399398 }
400399
401400 break ;
402401 case NotifyCollectionChangedAction . Remove :
403- foreach ( var applicationItem in e . OldItems )
402+ foreach ( var assignment in e . OldItems )
404403 {
405- Tools . Logs . Add ( $ "Application removed: { ( ( ApplicationItem ) applicationItem ) . ApplicationName } ", false ) ;
406- ApplicationWatcher . RemoveProcess ( ( ( ApplicationItem ) applicationItem ) ) ;
407- ( ( ApplicationItem ) applicationItem ) . PropertyChanged -= ApplicationItem_PropertyChanged ;
404+ Tools . Logs . Add ( $ "Application removed: { ( ( ApplicationProfileAssignment ) assignment ) . Application . ApplicationName } ", false ) ;
405+ ApplicationWatcher . RemoveProcess ( ( ( ApplicationProfileAssignment ) assignment ) . Application ) ;
406+ ( ( ApplicationProfileAssignment ) assignment ) . PropertyChanged -= ApplicationItem_PropertyChanged ;
408407
409408 }
410409 break ;
@@ -425,23 +424,25 @@ private void ApplicationItem_PropertyChanged(object sender, PropertyChangedEvent
425424 SaveSettings ( ) ;
426425 }
427426
428- private void AddAplication ( )
427+ private void AddAssignment ( )
429428 {
430429 ApplicationAdder adder = new ApplicationAdder ( ) ;
431430 adder . DialogService = DialogService ;
432431 adder . OKClicked += ( o , e ) =>
433432 {
434- if ( ! Settings . ApplicationItems . Any ( pi => pi . ApplicationFilePath == adder . ApplicationItem . ApplicationFilePath ) )
435- Settings . ApplicationItems . Add ( adder . ApplicationItem ) ;
433+ if ( ! Settings . ApplicationProfileAssignments . Any ( pi => pi . Application . ApplicationFilePath == adder . ApplicationItem . ApplicationFilePath ) )
434+ {
435+ ApplicationProfileAssignment . NewAssigment ( adder . ApplicationItem ) ;
436+ }
436437 } ;
437438 if ( DialogService != null )
438439 DialogService . ShowDialogModal ( adder , new System . Drawing . Size ( 640 , 450 ) ) ;
439440 }
440441
441442
442- private void RemoveApplication ( ApplicationItem process )
443+ private void RemoveAssignment ( ApplicationProfileAssignment process )
443444 {
444- Settings . ApplicationItems . Remove ( process ) ;
445+ Settings . ApplicationProfileAssignments . Remove ( process ) ;
445446
446447 }
447448
0 commit comments