Skip to content

Commit e061e15

Browse files
committed
1.7.12
[New] - Allow the user to set a default profile to be used when adding new applications #54 [Bug fixes] - Profile selection wasn't possbile, if app name was too long. - Duplicate priorities after removing an app
1 parent ece24a8 commit e061e15

21 files changed

+120
-486
lines changed
512 Bytes
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.

Source/Externals/CodectoryCore.dll

2.5 KB
Binary file not shown.

Source/HDRProfile/App.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@
832832

833833

834834

835-
<local:EnumLocaleConverter x:Key="EnumLocaleConverter"/>
835+
<corewpf:EnumLocaleConverter x:Key="EnumLocaleConverter"/>
836836
<corewpf:DialogService x:Key="DialogService" />
837837
<corewpf:DialogService x:Key="ProfileDialogService" />
838838
<corewpf:BitmapToBitmapImageConverter x:Key="BitmapToBitmapImageConverter"/>
@@ -875,6 +875,9 @@
875875
<DataTemplate DataType="{x:Type info:LogsStorage}">
876876
<views:AutoHDRLogsView></views:AutoHDRLogsView>
877877
</DataTemplate>
878+
<DataTemplate x:Key="ProfileItemTemplate" DataType="Profile">
879+
<TextBlock Text="{Binding Name }"/>
880+
</DataTemplate>
878881
</Application.Resources>
879882

880883
</Application>

Source/HDRProfile/AutoHDR.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@
193193
<Compile Include="Audio\AudioMasterChangedProvider.cs" />
194194
<Compile Include="Audio\VolumeProvider.cs" />
195195
<Compile Include="Displays\DisplayInterop.cs" />
196-
<Compile Include="FastObservableCollection.cs" />
197196
<Compile Include="Globals.cs" />
198197
<Compile Include="Info\AutoHDRLicense.cs" />
199198
<Compile Include="Info\LogsStorage.cs" />
@@ -206,7 +205,6 @@
206205
<Compile Include="Info\AutoHDRInfo.cs" />
207206
<Compile Include="Info\Github\GitHubData.cs" />
208207
<Compile Include="Info\Github\GitHubIntegration.cs" />
209-
<Compile Include="HDRProfileSettings.cs" />
210208
<Compile Include="Info\ReleaseEntry.cs" />
211209
<Compile Include="Profiles\Actions\IProfileAction.cs" />
212210
<Compile Include="Profiles\Actions\ListOfProfileActions.cs" />
@@ -219,7 +217,6 @@
219217
<DesignTime>True</DesignTime>
220218
<DependentUpon>Locale_Texts.resx</DependentUpon>
221219
</Compile>
222-
<Compile Include="SortedObservableCollection.cs" />
223220
<Compile Include="Views\AudioActionView.xaml.cs">
224221
<DependentUpon>AudioActionView.xaml</DependentUpon>
225222
</Compile>
@@ -328,8 +325,6 @@
328325
<DependentUpon>App.xaml</DependentUpon>
329326
<SubType>Code</SubType>
330327
</Compile>
331-
<Compile Include="EnumLocaleConverter.cs" />
332-
<Compile Include="HDRActivationMode.cs" />
333328
<Compile Include="AutoHDRDaemon.cs" />
334329
<Compile Include="UserAppSettings.cs" />
335330
<Compile Include="Views\UserAppSettingsView.xaml.cs">

Source/HDRProfile/AutoHDRDaemon.cs

Lines changed: 77 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private void Initialize()
126126
CheckForNewVersion();
127127
InitializeDisplayManager();
128128
InitializeAudioManager();
129-
Globals.Instance.SaveSettings();
129+
Globals.Instance.SaveSettings();
130130
InitializeTrayMenuHelper();
131131
CreateRelayCommands();
132132
ShowView = !Settings.StartMinimizedToTray;
@@ -169,8 +169,8 @@ private void UpdateCurrentProfile(ApplicationItem application, ApplicationChange
169169

170170
if (profile == null)
171171
return;
172-
bool profileChanged = Equals(profile, CurrentProfile);
173-
172+
bool profileChanged = Equals(profile, CurrentProfile);
173+
174174
CurrentProfile = profile;
175175
if (profileChanged)
176176
Globals.Logs.Add($"Profile changed to {profile.Name}", false);
@@ -206,7 +206,7 @@ private void UpdateCurrentProfile(ApplicationItem application, ApplicationChange
206206
CurrentProfile = null;
207207
}
208208
}
209-
209+
210210
private void ActionLog(object sender, LogEntry entry)
211211
{
212212
Globals.Logs.AppendLogEntry(entry);
@@ -262,7 +262,7 @@ private void CreateRelayCommands()
262262
ActivateHDRCommand = new RelayCommand(DisplayManager.Instance.ActivateHDR);
263263
DeactivateHDRCommand = new RelayCommand(DisplayManager.Instance.DeactivateHDR);
264264
AddAssignmentCommand = new RelayCommand(AddAssignment);
265-
EditApplicationCommand = new RelayCommand<ApplicationProfileAssignment>(EditApplication);
265+
EditApplicationCommand = new RelayCommand<ApplicationProfileAssignment>(EditApplication);
266266
RemoveAssignmentCommand = new RelayCommand<ApplicationProfileAssignment>(RemoveAssignment);
267267

268268
MoveAssignmentUpCommand = new RelayCommand<ApplicationProfileAssignment>(MoveAssignmentUp);
@@ -307,6 +307,7 @@ private void LoadSettings()
307307
{
308308
Globals.Instance.LoadSettings();
309309
FixAssignments();
310+
Globals.Instance.SaveSettings();
310311
Settings.ApplicationProfileAssignments.Sort(a => a.Position, ListSortDirection.Ascending);
311312
Settings.ApplicationProfileAssignments.CollectionChanged += ApplicationProfileAssigments_CollectionChanged;
312313
Settings.ApplicationProfiles.CollectionChanged += ApplicationProfiles_CollectionChanged;
@@ -317,9 +318,9 @@ private void LoadSettings()
317318
ApplicationProfileAssigments_CollectionChanged(
318319
Settings.ApplicationProfileAssignments, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Settings.ApplicationProfileAssignments.ToList()));
319320

320-
ApplicationProfiles_CollectionChanged( Settings.ApplicationProfiles, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Settings.ApplicationProfiles.ToList()));
321+
ApplicationProfiles_CollectionChanged(Settings.ApplicationProfiles, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Settings.ApplicationProfiles.ToList()));
321322

322-
Monitors_CollectionChanged( Settings.Monitors, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Settings.Monitors.ToList()));
323+
Monitors_CollectionChanged(Settings.Monitors, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Settings.Monitors.ToList()));
323324

324325

325326
Globals.Logs.LogFileEnabled = Settings.CreateLogFile;
@@ -353,7 +354,7 @@ private void FixAssignments()
353354
do
354355
{
355356
assignment.Position = assignment.Position - 1;
356-
} while (Settings.ApplicationProfileAssignments.Count(a => a.Position == assignment.Position) > 1);
357+
} while (Settings.ApplicationProfileAssignments.Count(a => a.Position == assignment.Position) > 1);
357358
}
358359
}
359360

@@ -374,7 +375,7 @@ private void StartApplication(ApplicationItem application)
374375
DisplayManager.Instance.ActivateHDR();
375376
System.Threading.Thread.Sleep(2500);
376377
application.StartApplication();
377-
378+
378379
}
379380
catch (Exception ex)
380381
{
@@ -419,7 +420,7 @@ public void Start()
419420
DisplayManager.Instance.StartMonitoring();
420421
Globals.Logs.Add($"HDR Monitoring started", false);
421422
Started = true;
422-
// UpdateHDRModeBasedOnCurrentApplication();
423+
// UpdateHDRModeBasedOnCurrentApplication();
423424
}
424425
}
425426

@@ -451,7 +452,9 @@ private void AddAssignment()
451452
{
452453
if (!Settings.ApplicationProfileAssignments.Any(pi => pi.Application.ApplicationFilePath == adder.ApplicationItem.ApplicationFilePath))
453454
{
454-
ApplicationProfileAssignment.NewAssigment(adder.ApplicationItem);
455+
var assignment = ApplicationProfileAssignment.NewAssigment(adder.ApplicationItem);
456+
if (Settings.DefaultProfile != null)
457+
assignment.Profile = Settings.DefaultProfile;
455458
}
456459
Settings.ApplicationProfileAssignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending);
457460

@@ -615,76 +618,86 @@ private void ProfileActions_CollectionChanged(object sender, NotifyCollectionCha
615618
Globals.Instance.SaveSettings();
616619
}
617620

621+
readonly object _lockAssignments = new object();
622+
618623
private void ApplicationProfileAssigments_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
619624
{
620-
SortableObservableCollection<ApplicationProfileAssignment> collection = (SortableObservableCollection<ApplicationProfileAssignment>)sender;
621-
switch (e.Action)
625+
bool taken = Monitor.TryEnter(_lockAssignments);
626+
if (!taken)
627+
return;
628+
try
622629
{
623-
case NotifyCollectionChangedAction.Add:
624-
625-
foreach (ApplicationProfileAssignment assignment in e.NewItems)
626-
{
630+
SortableObservableCollection<ApplicationProfileAssignment> collection = (SortableObservableCollection<ApplicationProfileAssignment>)sender;
631+
switch (e.Action)
632+
{
633+
case NotifyCollectionChangedAction.Add:
627634

635+
foreach (ApplicationProfileAssignment assignment in e.NewItems)
636+
{
628637

629-
Globals.Logs.Add($"Application added: {assignment.Application.ApplicationName}", false);
630-
assignment.PropertyChanged += SaveSettingsOnPropertyChanged;
631-
ApplicationWatcher.AddProcess(assignment.Application);
632-
assignment.Application.PropertyChanged += SaveSettingsOnPropertyChanged;
633-
}
634-
635-
break;
636-
case NotifyCollectionChangedAction.Remove:
637-
foreach (ApplicationProfileAssignment assignment in e.OldItems)
638-
{
639-
Globals.Logs.Add($"Application removed: {assignment.Application.ApplicationName}", false);
640-
assignment.PropertyChanged -= SaveSettingsOnPropertyChanged;
641638

639+
Globals.Logs.Add($"Application added: {assignment.Application.ApplicationName}", false);
640+
assignment.PropertyChanged += SaveSettingsOnPropertyChanged;
641+
ApplicationWatcher.AddProcess(assignment.Application);
642+
assignment.Application.PropertyChanged += SaveSettingsOnPropertyChanged;
643+
}
642644

643-
int removedPosition = assignment.Position;
644-
foreach (ApplicationProfileAssignment a in collection)
645+
break;
646+
case NotifyCollectionChangedAction.Remove:
647+
foreach (ApplicationProfileAssignment assignment in e.OldItems)
645648
{
646-
if (a.Position >= removedPosition)
647-
a.Position = a.Position - 1;
649+
Globals.Logs.Add($"Application removed: {assignment.Application.ApplicationName}", false);
650+
assignment.PropertyChanged -= SaveSettingsOnPropertyChanged;
651+
652+
653+
int removedPosition = assignment.Position;
654+
foreach (ApplicationProfileAssignment a in collection)
655+
{
656+
if (a.Position >= removedPosition)
657+
a.Position = a.Position - 1;
658+
}
659+
ApplicationWatcher.RemoveProcess(assignment.Application);
660+
assignment.Application.PropertyChanged -= SaveSettingsOnPropertyChanged;
648661
}
649-
ApplicationWatcher.RemoveProcess(assignment.Application);
650-
assignment.Application.PropertyChanged -= SaveSettingsOnPropertyChanged;
651-
}
652662

653-
break;
654-
case NotifyCollectionChangedAction.Move:
663+
break;
664+
case NotifyCollectionChangedAction.Move:
665+
int downFrom = e.NewStartingIndex;
666+
int upFrom = e.OldStartingIndex;
655667

656-
int up, down, delta;
668+
if (e.OldStartingIndex == e.NewStartingIndex)
669+
break;
657670

658-
if (e.OldStartingIndex < e.NewStartingIndex)
659-
{
660-
up = e.OldStartingIndex + 1;
661-
down = e.NewStartingIndex;
662-
delta = -1;
663-
}
664-
else
665-
{
666-
up = e.NewStartingIndex;
667-
down = e.OldStartingIndex - 1;
668-
delta = 1;
669-
}
670671

671-
foreach (ApplicationProfileAssignment assingment in collection)
672-
{
673-
int position = assingment.Position;
674-
if (position == e.OldStartingIndex)
675-
{
676-
assingment.Position = e.NewStartingIndex;
677-
}
678-
else if (down <= position && position <= up)
672+
673+
foreach (ApplicationProfileAssignment assingment in collection)
679674
{
680-
assingment.Position = position + delta;
675+
int position = assingment.Position;
676+
if (position == e.OldStartingIndex)
677+
{
678+
assingment.Position = e.NewStartingIndex;
679+
}
680+
else if (e.OldStartingIndex > e.NewStartingIndex && position < e.OldStartingIndex && position >= e.NewStartingIndex)
681+
{
682+
assingment.Position = position + 1;
683+
}
684+
else if (e.OldStartingIndex < e.NewStartingIndex && position > e.OldStartingIndex && position <= e.NewStartingIndex)
685+
{
686+
assingment.Position = position - 1;
687+
}
681688
}
682-
}
683-
break;
689+
690+
break;
691+
}
692+
Globals.Instance.SaveSettings();
693+
}
694+
finally
695+
{
696+
if (taken)
697+
Monitor.Exit(_lockAssignments);
684698
}
685-
Globals.Instance.SaveSettings();
686699
}
687-
700+
688701

689702

690703
private void SaveSettingsOnPropertyChanged(object sender, PropertyChangedEventArgs e)

Source/HDRProfile/EnumLocaleConverter.cs

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)