From 9ff528964d521e0be1c0b8593ccc4d26644d4d03 Mon Sep 17 00:00:00 2001 From: Alessandro Bellia Date: Mon, 17 Apr 2023 19:21:09 +0200 Subject: [PATCH] Fixed persistence (#23) Signed-off-by: Alessandro Bellia --- DwmLutGUI/DwmLutGUI.sln | 16 ++++++++++++++-- DwmLutGUI/DwmLutGUI/AboutWindow.xaml | 2 +- DwmLutGUI/DwmLutGUI/MainViewModel.cs | 26 ++++++++++++++++++++++++++ DwmLutGUI/DwmLutGUI/MainWindow.xaml | 2 +- DwmLutGUI/DwmLutGUI/MainWindow.xaml.cs | 10 ++++++---- DwmLutGUI/DwmLutGUI/MonitorData.cs | 6 +++--- 6 files changed, 51 insertions(+), 11 deletions(-) diff --git a/DwmLutGUI/DwmLutGUI.sln b/DwmLutGUI/DwmLutGUI.sln index 40902c0..5f1ee73 100644 --- a/DwmLutGUI/DwmLutGUI.sln +++ b/DwmLutGUI/DwmLutGUI.sln @@ -1,20 +1,32 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31205.134 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DwmLutGUI", "DwmLutGUI\DwmLutGUI.csproj", "{7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}.Debug|Any CPU.Build.0 = Debug|Any CPU {7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}.Debug|x64.ActiveCfg = Debug|x64 {7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}.Debug|x64.Build.0 = Debug|x64 + {7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}.Debug|x86.ActiveCfg = Debug|Any CPU + {7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}.Debug|x86.Build.0 = Debug|Any CPU + {7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}.Release|Any CPU.Build.0 = Release|Any CPU {7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}.Release|x64.ActiveCfg = Release|x64 {7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}.Release|x64.Build.0 = Release|x64 + {7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}.Release|x86.ActiveCfg = Release|Any CPU + {7FA75ADD-B7F9-4A7F-9198-BAC492FFF80C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/DwmLutGUI/DwmLutGUI/AboutWindow.xaml b/DwmLutGUI/DwmLutGUI/AboutWindow.xaml index 1fd10fb..32d5a51 100644 --- a/DwmLutGUI/DwmLutGUI/AboutWindow.xaml +++ b/DwmLutGUI/DwmLutGUI/AboutWindow.xaml @@ -11,7 +11,7 @@ SnapsToDevicePixels="True"> - dwm_lut v3.9.4 by lauralex (original by ledoge) + dwm_lut v3.9.5 by lauralex (original by ledoge) Licensed under GPLv3 diff --git a/DwmLutGUI/DwmLutGUI/MainViewModel.cs b/DwmLutGUI/DwmLutGUI/MainViewModel.cs index 5a00da2..4ff98a0 100644 --- a/DwmLutGUI/DwmLutGUI/MainViewModel.cs +++ b/DwmLutGUI/DwmLutGUI/MainViewModel.cs @@ -19,6 +19,7 @@ internal class MainViewModel : INotifyPropertyChanged private string _activeText; private MonitorData _selectedMonitor; private bool _isActive; + private Key _toggleKey; private readonly string _configPath; @@ -83,6 +84,7 @@ private void UpdateConfigChanged() private void SaveConfig() { var xElem = new XElement("monitors", + new XAttribute("lut_toggle", _toggleKey), _allMonitors.Select(x => new XElement("monitor", new XAttribute("path", x.DevicePath), x.SdrLutPath != null ? new XAttribute("sdr_lut", x.SdrLutPath) : null, @@ -122,6 +124,18 @@ public string HdrLutPath get => SelectedMonitor?.HdrLutPath; } + public Key ToggleKey + { + set + { + if (value == _toggleKey) return; + _toggleKey = value; + OnPropertyChanged(); + SaveConfig(); + } + get => _toggleKey; + } + public bool IsActive { set @@ -147,6 +161,18 @@ public void UpdateMonitors() if (File.Exists(_configPath)) { config = XElement.Load(_configPath).Descendants("monitor").ToList(); + try + { + _toggleKey = (Key)Enum.Parse(typeof(Key), (string)XElement.Load(_configPath).Attribute("lut_toggle")); + } + catch + { + _toggleKey = Key.Pause; + } + } + else + { + _toggleKey = Key.Pause; } var paths = WindowsDisplayAPI.DisplayConfig.PathInfo.GetActivePaths(); diff --git a/DwmLutGUI/DwmLutGUI/MainWindow.xaml b/DwmLutGUI/DwmLutGUI/MainWindow.xaml index d3c260c..527517a 100644 --- a/DwmLutGUI/DwmLutGUI/MainWindow.xaml +++ b/DwmLutGUI/DwmLutGUI/MainWindow.xaml @@ -46,7 +46,7 @@