Skip to content

Commit 47f7ac9

Browse files
committed
1.9.2
[Bug fixes] - Display selection gets overriden in display action settings ( Profile's setting not being saved #86)
1 parent 6cd748d commit 47f7ac9

13 files changed

+242
-39
lines changed

Source/AutoHDR.Updater/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>AutoHDR.Updater</RootNamespace>
10+
<AssemblyName>AutoHDR.Updater</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Program.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<None Include="App.config" />
51+
</ItemGroup>
52+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
53+
</Project>

Source/AutoHDR.Updater/Program.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace AutoHDR.Updater
8+
{
9+
class Program
10+
{
11+
static void Main(string[] args)
12+
{
13+
string zip = args[0];
14+
string targetFolder = args[0];
15+
}
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// Allgemeine Informationen über eine Assembly werden über die folgenden
6+
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
7+
// die einer Assembly zugeordnet sind.
8+
[assembly: AssemblyTitle("AutoHDR.Updater")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("AutoHDR.Updater")]
13+
[assembly: AssemblyCopyright("Copyright © 2022")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
18+
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
19+
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
20+
[assembly: ComVisible(false)]
21+
22+
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
23+
[assembly: Guid("5df058e2-c5ab-42de-8eed-d22ff39960ad")]
24+
25+
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
26+
//
27+
// Hauptversion
28+
// Nebenversion
29+
// Buildnummer
30+
// Revision
31+
//
32+
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
33+
// indem Sie "*" wie unten gezeigt eingeben:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

Source/AutoHDR.sln

+14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoHDR.Threading", "AutoHD
1515
EndProject
1616
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoHDR.Audio", "AutoHDR.Audio\AutoHDR.Audio.csproj", "{FC3B898C-2F23-43BE-A924-8A74D800E942}"
1717
EndProject
18+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoHDR.Updater", "AutoHDR.Updater\AutoHDR.Updater.csproj", "{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}"
19+
EndProject
1820
Global
1921
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2022
Debug|Any CPU = Debug|Any CPU
@@ -97,6 +99,18 @@ Global
9799
{FC3B898C-2F23-43BE-A924-8A74D800E942}.Release|x64.Build.0 = Release|Any CPU
98100
{FC3B898C-2F23-43BE-A924-8A74D800E942}.Release|x86.ActiveCfg = Release|Any CPU
99101
{FC3B898C-2F23-43BE-A924-8A74D800E942}.Release|x86.Build.0 = Release|Any CPU
102+
{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
103+
{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
104+
{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}.Debug|x64.ActiveCfg = Debug|Any CPU
105+
{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}.Debug|x64.Build.0 = Debug|Any CPU
106+
{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}.Debug|x86.ActiveCfg = Debug|Any CPU
107+
{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}.Debug|x86.Build.0 = Debug|Any CPU
108+
{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
109+
{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}.Release|Any CPU.Build.0 = Release|Any CPU
110+
{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}.Release|x64.ActiveCfg = Release|Any CPU
111+
{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}.Release|x64.Build.0 = Release|Any CPU
112+
{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}.Release|x86.ActiveCfg = Release|Any CPU
113+
{5DF058E2-C5AB-42DE-8EED-D22FF39960AD}.Release|x86.Build.0 = Release|Any CPU
100114
EndGlobalSection
101115
GlobalSection(SolutionProperties) = preSolution
102116
HideSolutionNode = FALSE

Source/AutoHDR/AutoHDRDaemon.cs

+29
Original file line numberDiff line numberDiff line change
@@ -325,19 +325,24 @@ private void LoadSettings()
325325
Globals.Instance.LoadSettings();
326326
FixAssignments();
327327
Globals.Instance.SaveSettings();
328+
328329
Settings.ApplicationProfileAssignments.Sort(a => a.Position, ListSortDirection.Ascending);
329330
Settings.ApplicationProfileAssignments.CollectionChanged += ApplicationProfileAssigments_CollectionChanged;
330331
Settings.ApplicationProfiles.CollectionChanged += ApplicationProfiles_CollectionChanged;
331332
Settings.ActionShortcuts.CollectionChanged += ActionShortcuts_CollectionChanged;
332333
Settings.Displays.CollectionChanged += Monitors_CollectionChanged;
333334

335+
336+
334337
Settings.PropertyChanged += Settings_PropertyChanged;
335338

336339
ApplicationProfileAssigments_CollectionChanged(
337340
Settings.ApplicationProfileAssignments, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Settings.ApplicationProfileAssignments.ToList()));
338341

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

344+
345+
341346
Monitors_CollectionChanged(Settings.Displays, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Settings.Displays.ToList()));
342347

343348

@@ -616,6 +621,10 @@ private void ApplicationProfiles_CollectionChanged(object sender, NotifyCollecti
616621
profile.ApplicationStarted.CollectionChanged += ProfileActions_CollectionChanged;
617622
profile.ApplicationLostFocus.CollectionChanged += ProfileActions_CollectionChanged;
618623
profile.ApplicationGotFocus.CollectionChanged += ProfileActions_CollectionChanged;
624+
ProfileActions_CollectionChanged(profile.ApplicationClosed, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, profile.ApplicationClosed.ToList()));
625+
ProfileActions_CollectionChanged(profile.ApplicationStarted, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, profile.ApplicationStarted.ToList()));
626+
ProfileActions_CollectionChanged(profile.ApplicationLostFocus, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, profile.ApplicationLostFocus.ToList()));
627+
ProfileActions_CollectionChanged(profile.ApplicationGotFocus, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, profile.ApplicationGotFocus.ToList()));
619628
profile.PropertyChanged += SaveSettingsOnPropertyChanged;
620629
}
621630
break;
@@ -631,6 +640,8 @@ private void ApplicationProfiles_CollectionChanged(object sender, NotifyCollecti
631640
}
632641
break;
633642
}
643+
644+
634645
Globals.Instance.SaveSettings();
635646

636647
}
@@ -663,6 +674,24 @@ private void ActionShortcuts_CollectionChanged(object sender, NotifyCollectionCh
663674

664675
private void ProfileActions_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
665676
{
677+
switch (e.Action)
678+
{
679+
680+
case NotifyCollectionChangedAction.Add:
681+
foreach (IProfileAction action in e.NewItems)
682+
{
683+
Globals.Logs.Add($"Action added: {action.ActionDescription}", false);
684+
((BaseViewModel)action).PropertyChanged += SaveSettingsOnPropertyChanged;
685+
}
686+
break;
687+
case NotifyCollectionChangedAction.Remove:
688+
foreach (IProfileAction action in e.OldItems)
689+
{
690+
Globals.Logs.Add($"Action removed: {action.ActionDescription}", false);
691+
((BaseViewModel)action).PropertyChanged -= SaveSettingsOnPropertyChanged;
692+
}
693+
break;
694+
}
666695
Globals.Instance.SaveSettings();
667696
}
668697

Source/AutoHDR/Globals.cs

+8-6
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ public class Globals : BaseViewModel
2727

2828
private UserAppSettings _settings;
2929
public UserAppSettings Settings { get => _settings; set { _settings = value; OnPropertyChanged(); } }
30-
private bool _settingsLoadedOnce = false;
30+
public bool SettingsLoadedOnce { get; private set; } = false;
31+
32+
public event EventHandler SettingsLoaded;
3133

3234
public void SaveSettings(bool force = false)
3335
{
34-
if (!force && !_settingsLoadedOnce)
36+
if (!force && !SettingsLoadedOnce)
3537
return;
3638
Globals.Logs.Add("Saving settings..", false);
3739
try
@@ -53,22 +55,22 @@ public void LoadSettings()
5355
if (File.Exists(SettingsPath))
5456
{
5557
Settings = UserAppSettings.ReadSettings(SettingsPath);
56-
_settingsLoadedOnce = true;
58+
SettingsLoadedOnce = true;
5759
}
5860
else if (File.Exists(SettingsPathCompatible))
5961
{
6062
Settings = UserAppSettings.ReadSettings(SettingsPathCompatible);
61-
_settingsLoadedOnce = true;
63+
SettingsLoadedOnce = true;
6264
}
6365
else
6466
{
6567
Globals.Logs.Add("No settings found. Creating settings file...", false);
6668
Settings = new UserAppSettings();
6769
Settings.ApplicationProfiles.Add(Profile.DefaultProfile());
68-
_settingsLoadedOnce = true;
70+
SettingsLoadedOnce = true;
6971
}
7072
SaveSettings();
71-
73+
SettingsLoaded?.Invoke(this, EventArgs.Empty);
7274
}
7375
catch (Exception ex)
7476
{

Source/AutoHDR/Profiles/Actions/DisplayAction.cs

+49-19
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,15 @@ public List<Display> AllDisplays
3434
[JsonProperty]
3535
public Display Display
3636
{
37-
get => _display;
38-
set
39-
{
40-
_display = value;
37+
get => _display;
38+
set
39+
{
40+
_display = value;
4141
OnPropertyChanged();
42-
if (value.IsAllDisplay())
43-
{
44-
Resolution = AllDisplays[1].Resolution;
45-
RefreshRate = AllDisplays[1].RefreshRate;
46-
}
47-
else
48-
{
49-
Resolution = value.Resolution;
50-
RefreshRate = value.RefreshRate;
51-
}
52-
}
42+
43+
Resolution = value.Resolution;
44+
RefreshRate = value.RefreshRate;
45+
}
5346
}
5447
public override string ActionTypeName => ProjectResources.ProjectLocales.DisplayAction;
5548

@@ -82,17 +75,54 @@ public Display Display
8275
private Size _resolution;
8376

8477
[JsonProperty]
85-
public Size Resolution { get => _resolution; set { _resolution = value; OnPropertyChanged(); } }
78+
public Size Resolution
79+
{
80+
get
81+
{
82+
try
83+
{
84+
if (Display.IsAllDisplay())
85+
return AllDisplays[1].Resolution;
86+
}
87+
catch { }
88+
return _resolution;
89+
}
90+
set { _resolution = value; OnPropertyChanged(); }
91+
}
8692

8793
private int _refreshRate;
8894

8995
[JsonProperty]
90-
public int RefreshRate { get => _refreshRate; set { _refreshRate = value; OnPropertyChanged(); } }
96+
public int RefreshRate
97+
{
98+
get
99+
{
100+
try
101+
{
102+
if (Display.IsAllDisplay())
103+
return AllDisplays[1].RefreshRate;
104+
}
105+
catch { }
106+
return _refreshRate;
107+
}
108+
set { _refreshRate = value; OnPropertyChanged(); } }
91109

92110
ColorDepth _colorDepth;
93111

94112
[JsonProperty]
95-
public ColorDepth ColorDepth { get => _colorDepth; set { _colorDepth = value; OnPropertyChanged(); } }
113+
public ColorDepth ColorDepth
114+
{
115+
get
116+
{
117+
try
118+
{
119+
if (Display.IsAllDisplay())
120+
return AllDisplays[1].ColorDepth;
121+
}
122+
catch { }
123+
return _colorDepth;
124+
}
125+
set { _colorDepth = value; OnPropertyChanged(); } }
96126

97127
public IEnumerable<ColorDepth> ColorDepthValues { get => Enum.GetValues(typeof(ColorDepth)).Cast<ColorDepth>(); }
98128

@@ -118,7 +148,7 @@ public override string ActionDescription
118148

119149
public DisplayAction() : base()
120150
{
121-
Display = Display.AllDisplays;
151+
_display = Display.AllDisplays;
122152
}
123153

124154
public override ActionEndResult RunAction(ApplicationChangedType applicationChangedType)

Source/AutoHDR/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@
5252
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
5353
// indem Sie "*" wie unten gezeigt eingeben:
5454
// [assembly: AssemblyVersion("1.0.*")]
55-
[assembly: AssemblyVersion("1.9.1.0")]
56-
[assembly: AssemblyFileVersion("1.9.1.0")]
55+
[assembly: AssemblyVersion("1.9.2.0")]
56+
[assembly: AssemblyFileVersion("1.9.2.0")]

Source/AutoHDR/UserAppSettings.cs

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Collections.ObjectModel;
99
using System.IO;
1010
using System.Linq;
11+
using System.Windows;
1112
using System.Xml.Serialization;
1213

1314
namespace AutoHDR
@@ -26,6 +27,8 @@ public class UserAppSettings : BaseViewModel
2627
private bool _checkForNewVersion = true;
2728
readonly object _audioDevicesLock = new object();
2829
private Guid _defaultProfileGuid = Guid.Empty;
30+
private Size _windowSize = new Size(1280, 800);
31+
2932

3033
private SortableObservableCollection<ApplicationProfileAssignment> _applicationProfileAssignments;
3134
private DispatchingObservableCollection<Profile> _applicationProfiles;
@@ -71,6 +74,10 @@ public class UserAppSettings : BaseViewModel
7174
[JsonProperty]
7275
public DispatchingObservableCollection<ProfileActionShortcut> ActionShortcuts { get => _actionShortcuts; set { _actionShortcuts = value; OnPropertyChanged(); } }
7376

77+
[JsonProperty]
78+
public Size WindowSize { get => _windowSize; set { _windowSize = value; OnPropertyChanged(); } }
79+
80+
7481
public UserAppSettings()
7582
{
7683
ApplicationProfileAssignments = new SortableObservableCollection<ApplicationProfileAssignment>(new ObservableCollection<ApplicationProfileAssignment>());

0 commit comments

Comments
 (0)