From 149ce5ccc2b2f0c26964e85c11444f3727a006ab Mon Sep 17 00:00:00 2001 From: Taiizor <41683699+Taiizor@users.noreply.github.com> Date: Tue, 3 Oct 2023 03:14:09 +0300 Subject: [PATCH] Preparing Display Preferences Dialog --- .../Views/Controls/Display/Duplicate.xaml | 2 +- .../Views/Controls/Display/Expand.xaml | 4 +- .../Views/Controls/Display/Screen.xaml | 2 +- .../Views/Controls/DisplayPreferences.xaml.cs | 58 +++++++++++++++++-- 4 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/Portal/Sucrose.Portal/Views/Controls/Display/Duplicate.xaml b/src/Portal/Sucrose.Portal/Views/Controls/Display/Duplicate.xaml index bbdea49fb..7211dffef 100644 --- a/src/Portal/Sucrose.Portal/Views/Controls/Display/Duplicate.xaml +++ b/src/Portal/Sucrose.Portal/Views/Controls/Display/Duplicate.xaml @@ -3,7 +3,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d"> diff --git a/src/Portal/Sucrose.Portal/Views/Controls/Display/Expand.xaml b/src/Portal/Sucrose.Portal/Views/Controls/Display/Expand.xaml index 7860083bf..07bfa0e52 100644 --- a/src/Portal/Sucrose.Portal/Views/Controls/Display/Expand.xaml +++ b/src/Portal/Sucrose.Portal/Views/Controls/Display/Expand.xaml @@ -3,13 +3,13 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d"> - + \ No newline at end of file diff --git a/src/Portal/Sucrose.Portal/Views/Controls/Display/Screen.xaml b/src/Portal/Sucrose.Portal/Views/Controls/Display/Screen.xaml index ebac48800..aa081f58d 100644 --- a/src/Portal/Sucrose.Portal/Views/Controls/Display/Screen.xaml +++ b/src/Portal/Sucrose.Portal/Views/Controls/Display/Screen.xaml @@ -3,7 +3,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d"> diff --git a/src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml.cs b/src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml.cs index 7fc106855..bf00b55c5 100644 --- a/src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml.cs +++ b/src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml.cs @@ -14,7 +14,12 @@ using SPVCDE = Sucrose.Portal.Views.Controls.Display.Expand; using SPVCDS = Sucrose.Portal.Views.Controls.Display.Screen; using SSDEDT = Sucrose.Shared.Dependency.Enum.DisplayType; +using SSLHK = Sucrose.Shared.Live.Helper.Kill; +using SSLHR = Sucrose.Shared.Live.Helper.Run; using SSRER = Sucrose.Shared.Resources.Extension.Resources; +using SSSHL = Sucrose.Shared.Space.Helper.Live; +using SSSHP = Sucrose.Shared.Space.Helper.Processor; +using SSSMI = Sucrose.Shared.Space.Manage.Internal; using SWUS = Skylark.Wing.Utility.Screene; using TextBlock = System.Windows.Controls.TextBlock; @@ -36,6 +41,19 @@ public DisplayPreferences() : base(SPMI.ContentDialogService.GetContentPresenter InitializeComponent(); } + private void Restart() + { + if ((!SMMM.ClosePerformance && !SMMM.PausePerformance) || !SSSHP.Work(SSSMI.Backgroundog)) + { + if (SSSHL.Run()) + { + SSLHK.Stop(); + } + + SSLHR.Start(); + } + } + private async Task ScreenMonitor() { Contents.Children.Clear(); @@ -75,7 +93,7 @@ private async Task ExpandMonitor() SPVCDE Expand = new(); - Expand.Content.Text = SSRER.GetValue("Portal", "DisplayPreferences", "Expand", "Monitor"); + Expand.Title.Text = SSRER.GetValue("Portal", "DisplayPreferences", "Expand", "Monitor"); Contents.Children.Add(Expand); @@ -131,7 +149,13 @@ private async void ScreenChecked() ExpanderCustomContent.Visibility = Visibility.Collapsed; ExpanderExpandContent.Visibility = Visibility.Collapsed; ExpanderDuplicateContent.Visibility = Visibility.Collapsed; - SMMI.EngineSettingManager.SetSetting(SMC.DisplayType, SSDEDT.Screen); + + if (SPMM.DisplayType != SSDEDT.Screen) + { + SMMI.EngineSettingManager.SetSetting(SMC.DisplayType, SSDEDT.Screen); + + Restart(); + } } private async void ExpandChecked() @@ -141,7 +165,13 @@ private async void ExpandChecked() ExpanderCustomContent.Visibility = Visibility.Visible; ExpanderExpandContent.Visibility = Visibility.Visible; ExpanderDuplicateContent.Visibility = Visibility.Collapsed; - SMMI.EngineSettingManager.SetSetting(SMC.DisplayType, SSDEDT.Expand); + + if (SPMM.DisplayType != SSDEDT.Expand) + { + SMMI.EngineSettingManager.SetSetting(SMC.DisplayType, SSDEDT.Expand); + + Restart(); + } } private async void DuplicateChecked() @@ -151,17 +181,33 @@ private async void DuplicateChecked() ExpanderCustomContent.Visibility = Visibility.Visible; ExpanderExpandContent.Visibility = Visibility.Collapsed; ExpanderDuplicateContent.Visibility = Visibility.Visible; - SMMI.EngineSettingManager.SetSetting(SMC.DisplayType, SSDEDT.Duplicate); + + if (SPMM.DisplayType != SSDEDT.Duplicate) + { + SMMI.EngineSettingManager.SetSetting(SMC.DisplayType, SSDEDT.Duplicate); + + Restart(); + } } private void ExpandScreenTypeChecked(SEEST Type) { - SMMI.EngineSettingManager.SetSetting(SMC.ExpandScreenType, Type); + if (SPMM.ExpandScreenType != Type) + { + SMMI.EngineSettingManager.SetSetting(SMC.ExpandScreenType, Type); + + Restart(); + } } private void DuplicateScreenTypeChecked(SEDST Type) { - SMMI.EngineSettingManager.SetSetting(SMC.DuplicateScreenType, Type); + if (SPMM.DuplicateScreenType != Type) + { + SMMI.EngineSettingManager.SetSetting(SMC.DuplicateScreenType, Type); + + Restart(); + } } private void ContentDialog_Loaded(object sender, RoutedEventArgs e)