From 05eeb5716218fbed44b60bbecb3dc8a870427548 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Sat, 6 Apr 2024 04:10:39 +0300 Subject: [PATCH] Update NuGet packages --- .../LightBulb.Core.Tests.csproj | 10 ++--- LightBulb.Core.Tests/LocationSpecs.cs | 6 +-- LightBulb.Core/LightBulb.Core.csproj | 2 +- LightBulb.PlatformInterop/GlobalHotKey.cs | 37 ++++++++----------- .../LightBulb.PlatformInterop.csproj | 2 +- .../PowerSettingNotification.cs | 22 +++++------ LightBulb.PlatformInterop/SystemEvent.cs | 7 ++-- LightBulb/Framework/ViewManager.cs | 3 +- LightBulb/LightBulb.csproj | 12 +++--- .../Components/DashboardViewModel.cs | 6 +-- ...plicationWhitelistSettingsTabView.axaml.cs | 3 +- 11 files changed, 50 insertions(+), 60 deletions(-) diff --git a/LightBulb.Core.Tests/LightBulb.Core.Tests.csproj b/LightBulb.Core.Tests/LightBulb.Core.Tests.csproj index ccc5046f..62502da7 100644 --- a/LightBulb.Core.Tests/LightBulb.Core.Tests.csproj +++ b/LightBulb.Core.Tests/LightBulb.Core.Tests.csproj @@ -10,13 +10,13 @@ - - + + - - - + + + diff --git a/LightBulb.Core.Tests/LocationSpecs.cs b/LightBulb.Core.Tests/LocationSpecs.cs index 91d0c7b9..aabb246b 100644 --- a/LightBulb.Core.Tests/LocationSpecs.cs +++ b/LightBulb.Core.Tests/LocationSpecs.cs @@ -55,14 +55,12 @@ SolarTimes expectedSolarTimes // Assert solarTimes - .Sunrise - .ToTimeSpan() + .Sunrise.ToTimeSpan() .Should() .BeCloseTo(expectedSolarTimes.Sunrise.ToTimeSpan(), TimeSpan.FromMinutes(3)); solarTimes - .Sunset - .ToTimeSpan() + .Sunset.ToTimeSpan() .Should() .BeCloseTo(expectedSolarTimes.Sunset.ToTimeSpan(), TimeSpan.FromMinutes(3)); } diff --git a/LightBulb.Core/LightBulb.Core.csproj b/LightBulb.Core/LightBulb.Core.csproj index 4ee3eeb5..d5e5f015 100644 --- a/LightBulb.Core/LightBulb.Core.csproj +++ b/LightBulb.Core/LightBulb.Core.csproj @@ -1,7 +1,7 @@ - + diff --git a/LightBulb.PlatformInterop/GlobalHotKey.cs b/LightBulb.PlatformInterop/GlobalHotKey.cs index 36e62b76..24fe88be 100644 --- a/LightBulb.PlatformInterop/GlobalHotKey.cs +++ b/LightBulb.PlatformInterop/GlobalHotKey.cs @@ -15,31 +15,26 @@ public partial class GlobalHotKey : NativeResource public GlobalHotKey(int id, Action callback) : base(id) { - _wndProcRegistration = WndProcSponge - .Default - .Listen( - 0x312, - m => + _wndProcRegistration = WndProcSponge.Default.Listen( + 0x312, + m => + { + // Filter out other hotkey events + if (m.WParam != Handle) + return; + + // Throttle triggers + lock (_lock) { - // Filter out other hotkey events - if (m.WParam != Handle) + if ((DateTimeOffset.Now - _lastTriggerTimestamp).Duration().TotalSeconds < 0.05) return; - // Throttle triggers - lock (_lock) - { - if ( - (DateTimeOffset.Now - _lastTriggerTimestamp).Duration().TotalSeconds - < 0.05 - ) - return; - - _lastTriggerTimestamp = DateTimeOffset.Now; - } - - callback(); + _lastTriggerTimestamp = DateTimeOffset.Now; } - ); + + callback(); + } + ); } protected override void Dispose(bool disposing) diff --git a/LightBulb.PlatformInterop/LightBulb.PlatformInterop.csproj b/LightBulb.PlatformInterop/LightBulb.PlatformInterop.csproj index 838fe0e2..ee4042e5 100644 --- a/LightBulb.PlatformInterop/LightBulb.PlatformInterop.csproj +++ b/LightBulb.PlatformInterop/LightBulb.PlatformInterop.csproj @@ -1,7 +1,7 @@  - + \ No newline at end of file diff --git a/LightBulb.PlatformInterop/PowerSettingNotification.cs b/LightBulb.PlatformInterop/PowerSettingNotification.cs index 77174f7a..e7971f79 100644 --- a/LightBulb.PlatformInterop/PowerSettingNotification.cs +++ b/LightBulb.PlatformInterop/PowerSettingNotification.cs @@ -7,19 +7,17 @@ namespace LightBulb.PlatformInterop; public partial class PowerSettingNotification(nint handle, Guid powerSettingId, Action callback) : NativeResource(handle) { - private readonly IDisposable _wndProcRegistration = WndProcSponge - .Default - .Listen( - 0x218, - m => - { - // Filter out other power events - if (m.GetLParam().PowerSettingId != powerSettingId) - return; + private readonly IDisposable _wndProcRegistration = WndProcSponge.Default.Listen( + 0x218, + m => + { + // Filter out other power events + if (m.GetLParam().PowerSettingId != powerSettingId) + return; - callback(); - } - ); + callback(); + } + ); protected override void Dispose(bool disposing) { diff --git a/LightBulb.PlatformInterop/SystemEvent.cs b/LightBulb.PlatformInterop/SystemEvent.cs index 69849d11..2b9437f3 100644 --- a/LightBulb.PlatformInterop/SystemEvent.cs +++ b/LightBulb.PlatformInterop/SystemEvent.cs @@ -5,9 +5,10 @@ namespace LightBulb.PlatformInterop; public partial class SystemEvent(int eventId, Action callback) : IDisposable { - private readonly IDisposable _wndProcRegistration = WndProcSponge - .Default - .Listen(eventId, _ => callback()); + private readonly IDisposable _wndProcRegistration = WndProcSponge.Default.Listen( + eventId, + _ => callback() + ); public void Dispose() => _wndProcRegistration.Dispose(); } diff --git a/LightBulb/Framework/ViewManager.cs b/LightBulb/Framework/ViewManager.cs index c2f1f996..ca3284c3 100644 --- a/LightBulb/Framework/ViewManager.cs +++ b/LightBulb/Framework/ViewManager.cs @@ -10,8 +10,7 @@ public partial class ViewManager { var name = viewModel .GetType() - .FullName - ?.Replace("ViewModel", "View", StringComparison.Ordinal); + .FullName?.Replace("ViewModel", "View", StringComparison.Ordinal); if (string.IsNullOrWhiteSpace(name)) return null; diff --git a/LightBulb/LightBulb.csproj b/LightBulb/LightBulb.csproj index 10d5623d..d7061118 100644 --- a/LightBulb/LightBulb.csproj +++ b/LightBulb/LightBulb.csproj @@ -17,16 +17,16 @@ - - - + + + - + - - + + diff --git a/LightBulb/ViewModels/Components/DashboardViewModel.cs b/LightBulb/ViewModels/Components/DashboardViewModel.cs index b991385d..95db0d5e 100644 --- a/LightBulb/ViewModels/Components/DashboardViewModel.cs +++ b/LightBulb/ViewModels/Components/DashboardViewModel.cs @@ -305,9 +305,9 @@ bool IsPausedByFullScreen() => bool IsPausedByWhitelistedApplication() => _settingsService.IsApplicationWhitelistEnabled && _settingsService.WhitelistedApplications is not null - && _settingsService - .WhitelistedApplications - .Contains(_externalApplicationService.TryGetForegroundApplication()); + && _settingsService.WhitelistedApplications.Contains( + _externalApplicationService.TryGetForegroundApplication() + ); IsPaused = IsPausedByFullScreen() || IsPausedByWhitelistedApplication(); } diff --git a/LightBulb/Views/Components/Settings/ApplicationWhitelistSettingsTabView.axaml.cs b/LightBulb/Views/Components/Settings/ApplicationWhitelistSettingsTabView.axaml.cs index c6104c45..706468df 100644 --- a/LightBulb/Views/Components/Settings/ApplicationWhitelistSettingsTabView.axaml.cs +++ b/LightBulb/Views/Components/Settings/ApplicationWhitelistSettingsTabView.axaml.cs @@ -44,8 +44,7 @@ private void WhitelistedApplicationsListBox_OnSelectionChanged( SelectionChangedEventArgs args ) => DataContext.WhitelistedApplications = WhitelistedApplicationsListBox - .SelectedItems - ?.Cast() + .SelectedItems?.Cast() .ToArray(); public void Dispose() => _eventRoot.Dispose();