Skip to content

Commit

Permalink
1.7.12
Browse files Browse the repository at this point in the history
[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
  • Loading branch information
Codectory committed Dec 7, 2021
1 parent ece24a8 commit e061e15
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 486 deletions.
Binary file modified Source/Externals/CodectoryCore.UI.Wpf.dll
Binary file not shown.
Binary file modified Source/Externals/CodectoryCore.Windows.FileSystem.dll
Binary file not shown.
Binary file modified Source/Externals/CodectoryCore.Windows.dll
Binary file not shown.
Binary file modified Source/Externals/CodectoryCore.dll
Binary file not shown.
5 changes: 4 additions & 1 deletion Source/HDRProfile/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@



<local:EnumLocaleConverter x:Key="EnumLocaleConverter"/>
<corewpf:EnumLocaleConverter x:Key="EnumLocaleConverter"/>
<corewpf:DialogService x:Key="DialogService" />
<corewpf:DialogService x:Key="ProfileDialogService" />
<corewpf:BitmapToBitmapImageConverter x:Key="BitmapToBitmapImageConverter"/>
Expand Down Expand Up @@ -875,6 +875,9 @@
<DataTemplate DataType="{x:Type info:LogsStorage}">
<views:AutoHDRLogsView></views:AutoHDRLogsView>
</DataTemplate>
<DataTemplate x:Key="ProfileItemTemplate" DataType="Profile">
<TextBlock Text="{Binding Name }"/>
</DataTemplate>
</Application.Resources>

</Application>
5 changes: 0 additions & 5 deletions Source/HDRProfile/AutoHDR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@
<Compile Include="Audio\AudioMasterChangedProvider.cs" />
<Compile Include="Audio\VolumeProvider.cs" />
<Compile Include="Displays\DisplayInterop.cs" />
<Compile Include="FastObservableCollection.cs" />
<Compile Include="Globals.cs" />
<Compile Include="Info\AutoHDRLicense.cs" />
<Compile Include="Info\LogsStorage.cs" />
Expand All @@ -206,7 +205,6 @@
<Compile Include="Info\AutoHDRInfo.cs" />
<Compile Include="Info\Github\GitHubData.cs" />
<Compile Include="Info\Github\GitHubIntegration.cs" />
<Compile Include="HDRProfileSettings.cs" />
<Compile Include="Info\ReleaseEntry.cs" />
<Compile Include="Profiles\Actions\IProfileAction.cs" />
<Compile Include="Profiles\Actions\ListOfProfileActions.cs" />
Expand All @@ -219,7 +217,6 @@
<DesignTime>True</DesignTime>
<DependentUpon>Locale_Texts.resx</DependentUpon>
</Compile>
<Compile Include="SortedObservableCollection.cs" />
<Compile Include="Views\AudioActionView.xaml.cs">
<DependentUpon>AudioActionView.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -328,8 +325,6 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="EnumLocaleConverter.cs" />
<Compile Include="HDRActivationMode.cs" />
<Compile Include="AutoHDRDaemon.cs" />
<Compile Include="UserAppSettings.cs" />
<Compile Include="Views\UserAppSettingsView.xaml.cs">
Expand Down
141 changes: 77 additions & 64 deletions Source/HDRProfile/AutoHDRDaemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void Initialize()
CheckForNewVersion();
InitializeDisplayManager();
InitializeAudioManager();
Globals.Instance.SaveSettings();
Globals.Instance.SaveSettings();
InitializeTrayMenuHelper();
CreateRelayCommands();
ShowView = !Settings.StartMinimizedToTray;
Expand Down Expand Up @@ -169,8 +169,8 @@ private void UpdateCurrentProfile(ApplicationItem application, ApplicationChange

if (profile == null)
return;
bool profileChanged = Equals(profile, CurrentProfile);
bool profileChanged = Equals(profile, CurrentProfile);

CurrentProfile = profile;
if (profileChanged)
Globals.Logs.Add($"Profile changed to {profile.Name}", false);
Expand Down Expand Up @@ -206,7 +206,7 @@ private void UpdateCurrentProfile(ApplicationItem application, ApplicationChange
CurrentProfile = null;
}
}

private void ActionLog(object sender, LogEntry entry)
{
Globals.Logs.AppendLogEntry(entry);
Expand Down Expand Up @@ -262,7 +262,7 @@ private void CreateRelayCommands()
ActivateHDRCommand = new RelayCommand(DisplayManager.Instance.ActivateHDR);
DeactivateHDRCommand = new RelayCommand(DisplayManager.Instance.DeactivateHDR);
AddAssignmentCommand = new RelayCommand(AddAssignment);
EditApplicationCommand = new RelayCommand<ApplicationProfileAssignment>(EditApplication);
EditApplicationCommand = new RelayCommand<ApplicationProfileAssignment>(EditApplication);
RemoveAssignmentCommand = new RelayCommand<ApplicationProfileAssignment>(RemoveAssignment);

MoveAssignmentUpCommand = new RelayCommand<ApplicationProfileAssignment>(MoveAssignmentUp);
Expand Down Expand Up @@ -307,6 +307,7 @@ private void LoadSettings()
{
Globals.Instance.LoadSettings();
FixAssignments();
Globals.Instance.SaveSettings();
Settings.ApplicationProfileAssignments.Sort(a => a.Position, ListSortDirection.Ascending);
Settings.ApplicationProfileAssignments.CollectionChanged += ApplicationProfileAssigments_CollectionChanged;
Settings.ApplicationProfiles.CollectionChanged += ApplicationProfiles_CollectionChanged;
Expand All @@ -317,9 +318,9 @@ private void LoadSettings()
ApplicationProfileAssigments_CollectionChanged(
Settings.ApplicationProfileAssignments, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Settings.ApplicationProfileAssignments.ToList()));

ApplicationProfiles_CollectionChanged( Settings.ApplicationProfiles, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Settings.ApplicationProfiles.ToList()));
ApplicationProfiles_CollectionChanged(Settings.ApplicationProfiles, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Settings.ApplicationProfiles.ToList()));

Monitors_CollectionChanged( Settings.Monitors, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Settings.Monitors.ToList()));
Monitors_CollectionChanged(Settings.Monitors, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Settings.Monitors.ToList()));


Globals.Logs.LogFileEnabled = Settings.CreateLogFile;
Expand Down Expand Up @@ -353,7 +354,7 @@ private void FixAssignments()
do
{
assignment.Position = assignment.Position - 1;
} while (Settings.ApplicationProfileAssignments.Count(a => a.Position == assignment.Position) > 1);
} while (Settings.ApplicationProfileAssignments.Count(a => a.Position == assignment.Position) > 1);
}
}

Expand All @@ -374,7 +375,7 @@ private void StartApplication(ApplicationItem application)
DisplayManager.Instance.ActivateHDR();
System.Threading.Thread.Sleep(2500);
application.StartApplication();

}
catch (Exception ex)
{
Expand Down Expand Up @@ -419,7 +420,7 @@ public void Start()
DisplayManager.Instance.StartMonitoring();
Globals.Logs.Add($"HDR Monitoring started", false);
Started = true;
// UpdateHDRModeBasedOnCurrentApplication();
// UpdateHDRModeBasedOnCurrentApplication();
}
}

Expand Down Expand Up @@ -451,7 +452,9 @@ private void AddAssignment()
{
if (!Settings.ApplicationProfileAssignments.Any(pi => pi.Application.ApplicationFilePath == adder.ApplicationItem.ApplicationFilePath))
{
ApplicationProfileAssignment.NewAssigment(adder.ApplicationItem);
var assignment = ApplicationProfileAssignment.NewAssigment(adder.ApplicationItem);
if (Settings.DefaultProfile != null)
assignment.Profile = Settings.DefaultProfile;
}
Settings.ApplicationProfileAssignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending);

Expand Down Expand Up @@ -615,76 +618,86 @@ private void ProfileActions_CollectionChanged(object sender, NotifyCollectionCha
Globals.Instance.SaveSettings();
}

readonly object _lockAssignments = new object();

private void ApplicationProfileAssigments_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
SortableObservableCollection<ApplicationProfileAssignment> collection = (SortableObservableCollection<ApplicationProfileAssignment>)sender;
switch (e.Action)
bool taken = Monitor.TryEnter(_lockAssignments);
if (!taken)
return;
try
{
case NotifyCollectionChangedAction.Add:

foreach (ApplicationProfileAssignment assignment in e.NewItems)
{
SortableObservableCollection<ApplicationProfileAssignment> collection = (SortableObservableCollection<ApplicationProfileAssignment>)sender;
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:

foreach (ApplicationProfileAssignment assignment in e.NewItems)
{

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

break;
case NotifyCollectionChangedAction.Remove:
foreach (ApplicationProfileAssignment assignment in e.OldItems)
{
Globals.Logs.Add($"Application removed: {assignment.Application.ApplicationName}", false);
assignment.PropertyChanged -= SaveSettingsOnPropertyChanged;

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

int removedPosition = assignment.Position;
foreach (ApplicationProfileAssignment a in collection)
break;
case NotifyCollectionChangedAction.Remove:
foreach (ApplicationProfileAssignment assignment in e.OldItems)
{
if (a.Position >= removedPosition)
a.Position = a.Position - 1;
Globals.Logs.Add($"Application removed: {assignment.Application.ApplicationName}", false);
assignment.PropertyChanged -= SaveSettingsOnPropertyChanged;


int removedPosition = assignment.Position;
foreach (ApplicationProfileAssignment a in collection)
{
if (a.Position >= removedPosition)
a.Position = a.Position - 1;
}
ApplicationWatcher.RemoveProcess(assignment.Application);
assignment.Application.PropertyChanged -= SaveSettingsOnPropertyChanged;
}
ApplicationWatcher.RemoveProcess(assignment.Application);
assignment.Application.PropertyChanged -= SaveSettingsOnPropertyChanged;
}

break;
case NotifyCollectionChangedAction.Move:
break;
case NotifyCollectionChangedAction.Move:
int downFrom = e.NewStartingIndex;
int upFrom = e.OldStartingIndex;

int up, down, delta;
if (e.OldStartingIndex == e.NewStartingIndex)
break;

if (e.OldStartingIndex < e.NewStartingIndex)
{
up = e.OldStartingIndex + 1;
down = e.NewStartingIndex;
delta = -1;
}
else
{
up = e.NewStartingIndex;
down = e.OldStartingIndex - 1;
delta = 1;
}

foreach (ApplicationProfileAssignment assingment in collection)
{
int position = assingment.Position;
if (position == e.OldStartingIndex)
{
assingment.Position = e.NewStartingIndex;
}
else if (down <= position && position <= up)

foreach (ApplicationProfileAssignment assingment in collection)
{
assingment.Position = position + delta;
int position = assingment.Position;
if (position == e.OldStartingIndex)
{
assingment.Position = e.NewStartingIndex;
}
else if (e.OldStartingIndex > e.NewStartingIndex && position < e.OldStartingIndex && position >= e.NewStartingIndex)
{
assingment.Position = position + 1;
}
else if (e.OldStartingIndex < e.NewStartingIndex && position > e.OldStartingIndex && position <= e.NewStartingIndex)
{
assingment.Position = position - 1;
}
}
}
break;

break;
}
Globals.Instance.SaveSettings();
}
finally
{
if (taken)
Monitor.Exit(_lockAssignments);
}
Globals.Instance.SaveSettings();
}



private void SaveSettingsOnPropertyChanged(object sender, PropertyChangedEventArgs e)
Expand Down
29 changes: 0 additions & 29 deletions Source/HDRProfile/EnumLocaleConverter.cs

This file was deleted.

Loading

0 comments on commit e061e15

Please sign in to comment.