From 3f5182ade89b3d2d2c2b4de246c477d7a000d60c Mon Sep 17 00:00:00 2001 From: emoacht Date: Fri, 16 Dec 2022 05:47:20 +0900 Subject: [PATCH 1/3] Add another interval to display watcher --- Source/Monitorian.Core/Models/Watcher/DisplayWatcher.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Monitorian.Core/Models/Watcher/DisplayWatcher.cs b/Source/Monitorian.Core/Models/Watcher/DisplayWatcher.cs index 4a238e1a..d33d4d14 100644 --- a/Source/Monitorian.Core/Models/Watcher/DisplayWatcher.cs +++ b/Source/Monitorian.Core/Models/Watcher/DisplayWatcher.cs @@ -11,7 +11,7 @@ internal class DisplayWatcher : TimerWatcher { private Action _onDisplaySettingsChanged; - public DisplayWatcher() : base(1, 4, 5) + public DisplayWatcher() : base(1, 4, 5, 10) { } public void Subscribe(Action onDisplaySettingsChanged) From 3df7d276e27e9a77fdbd55e32286b907bb7b8f93 Mon Sep 17 00:00:00 2001 From: emoacht Date: Fri, 16 Dec 2022 05:47:52 +0900 Subject: [PATCH 2/3] Refactor --- Source/Monitorian.Core/AppControllerCore.cs | 9 +++++++-- Source/Monitorian.Core/Models/Watcher/PowerWatcher.cs | 3 ++- Source/Monitorian.Core/Models/Watcher/TimerWatcher.cs | 2 +- .../Views/Input/Touchpad/TouchpadTracker.cs | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/Monitorian.Core/AppControllerCore.cs b/Source/Monitorian.Core/AppControllerCore.cs index 45d1668e..b3789831 100644 --- a/Source/Monitorian.Core/AppControllerCore.cs +++ b/Source/Monitorian.Core/AppControllerCore.cs @@ -208,11 +208,16 @@ protected virtual async void OnSettingsChanged(object sender, PropertyChangedEve #region Monitors - protected virtual async void OnMonitorsChangeInferred(object sender = null, ICountEventArgs e = null) + protected virtual async void OnMonitorsChangeInferred(object sender, ICountEventArgs e = null) { await Recorder.RecordAsync($"{nameof(OnMonitorsChangeInferred)} ({sender}{e?.Description})"); - if (e?.Count == 0) + await ProceedScanAsync(e); + } + + protected virtual async Task ProceedScanAsync(ICountEventArgs e) + { + if (e is { Count: 0 }) return; await ScanAsync(TimeSpan.FromSeconds(3)); diff --git a/Source/Monitorian.Core/Models/Watcher/PowerWatcher.cs b/Source/Monitorian.Core/Models/Watcher/PowerWatcher.cs index 83c050dd..0ebd4502 100644 --- a/Source/Monitorian.Core/Models/Watcher/PowerWatcher.cs +++ b/Source/Monitorian.Core/Models/Watcher/PowerWatcher.cs @@ -85,7 +85,8 @@ private void OnDisplayStateChanged(DisplayStates state) { switch (state) { - case DisplayStates.On or DisplayStates.Dimmed: + case DisplayStates.On: + case DisplayStates.Dimmed: RaiseDisplayStateChanged(state, 0); _stateWatcher.TimerStart(state); break; diff --git a/Source/Monitorian.Core/Models/Watcher/TimerWatcher.cs b/Source/Monitorian.Core/Models/Watcher/TimerWatcher.cs index 617471f7..a26c9938 100644 --- a/Source/Monitorian.Core/Models/Watcher/TimerWatcher.cs +++ b/Source/Monitorian.Core/Models/Watcher/TimerWatcher.cs @@ -18,7 +18,7 @@ internal abstract class TimerWatcher : IDisposable /// Sequence of timer intervals in seconds protected TimerWatcher(params int[] intervals) { - if (intervals?.Length is not > 0) + if (intervals is not { Length: > 0 }) throw new ArgumentNullException(nameof(intervals)); if (intervals.Any(x => x <= 0)) throw new ArgumentOutOfRangeException(nameof(intervals), intervals.First(x => x <= 0), "An interval must be positive."); diff --git a/Source/Monitorian.Core/Views/Input/Touchpad/TouchpadTracker.cs b/Source/Monitorian.Core/Views/Input/Touchpad/TouchpadTracker.cs index 79883b74..947a0093 100644 --- a/Source/Monitorian.Core/Views/Input/Touchpad/TouchpadTracker.cs +++ b/Source/Monitorian.Core/Views/Input/Touchpad/TouchpadTracker.cs @@ -53,7 +53,7 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b { case TouchpadHelper.WM_INPUT: var contacts = TouchpadHelper.ParseInput(lParam); - if (contacts?.Length > 1) + if (contacts is { Length: > 1 }) { Check(contacts[0]); handled = true; From e946a5c75277f754c064b988dad354457a29d0ca Mon Sep 17 00:00:00 2001 From: emoacht Date: Fri, 16 Dec 2022 05:49:53 +0900 Subject: [PATCH 3/3] Increment build number --- Source/Installer/Product.wxs | 2 +- Source/Monitorian.Core/Properties/AssemblyInfo.cs | 4 ++-- Source/Monitorian/Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Installer/Product.wxs b/Source/Installer/Product.wxs index 022e93b6..39085a9d 100644 --- a/Source/Installer/Product.wxs +++ b/Source/Installer/Product.wxs @@ -1,6 +1,6 @@  -