diff --git a/.editorconfig b/.editorconfig index e68a880..9a29c85 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,3 +2,6 @@ # CA1416: Validate platform compatibility dotnet_diagnostic.CA1416.severity = none + +# IDE0022: Use block body for methods +dotnet_diagnostic.IDE0022.severity = none diff --git a/src/GitLurker.UI/Services/SurfaceDialService.cs b/src/GitLurker.UI/Services/SurfaceDialService.cs index 2470b50..160f3be 100644 --- a/src/GitLurker.UI/Services/SurfaceDialService.cs +++ b/src/GitLurker.UI/Services/SurfaceDialService.cs @@ -31,6 +31,10 @@ public class SurfaceDialService : IDisposable public event EventHandler RotatedRight; + public event EventHandler ControlAcquired; + + public event EventHandler ControlLost; + #endregion #region Methods @@ -51,10 +55,18 @@ public async Task Initialize(Window window) _controller.RotationChanged += Controller_RotationChanged; _controller.ButtonHolding += Controller_ButtonHolding; _controller.ButtonReleased += Controller_ButtonReleased; + _controller.ControlAcquired += Controller_ControlAcquired; + _controller.ControlLost += Controller_ControlLost; - RemoveSystemItems(handle); + ApplyConfigurations(handle); } + private void Controller_ControlLost(RadialController sender, object args) + => ControlLost?.Invoke(this, EventArgs.Empty); + + private void Controller_ControlAcquired(RadialController sender, RadialControllerControlAcquiredEventArgs args) + => ControlAcquired?.Invoke(this, EventArgs.Empty); + private void Controller_ButtonReleased(RadialController sender, RadialControllerButtonReleasedEventArgs args) { if (_holding) @@ -91,15 +103,15 @@ private void Controller_ButtonClicked(RadialController sender, RadialControllerB ButtonClicked?.Invoke(this, EventArgs.Empty); } - private void RemoveSystemItems(IntPtr hwnd) + private void ApplyConfigurations(IntPtr hwnd) { - RadialControllerConfiguration config; var radialControllerConfigInterop = (IRadialControllerConfigurationInterop)System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeMarshal.GetActivationFactory(typeof(RadialControllerConfiguration)); var guid = typeof(RadialControllerConfiguration).GetInterface("IRadialControllerConfiguration").GUID; - config = radialControllerConfigInterop.GetForWindow(hwnd, ref guid); - config.IsMenuSuppressed = true; - config.SetDefaultMenuItems(Enumerable.Empty()); + var configuration = radialControllerConfigInterop.GetForWindow(hwnd, ref guid); + var t = RadialControllerConfiguration.IsAppControllerEnabled; + configuration.IsMenuSuppressed = true; + configuration.SetDefaultMenuItems(Enumerable.Empty()); } public void Dispose() diff --git a/src/GitLurker.UI/ViewModels/ShellViewModel.cs b/src/GitLurker.UI/ViewModels/ShellViewModel.cs index 156cbf0..1f3f316 100644 --- a/src/GitLurker.UI/ViewModels/ShellViewModel.cs +++ b/src/GitLurker.UI/ViewModels/ShellViewModel.cs @@ -38,6 +38,7 @@ public class ShellViewModel : Screen, IHandle, IHandle private string _version; private double _dpiX = 1; private double _dpiY = 1; + private bool _hasSurfaceDial; #endregion @@ -102,6 +103,16 @@ public string SearchTerm } } + public bool HasSurfaceDial + { + get => _hasSurfaceDial; + set + { + _hasSurfaceDial = value; + NotifyOfPropertyChange(); + } + } + public string SearchWatermark { get => _searchWatermark; @@ -243,6 +254,8 @@ protected override async void OnViewLoaded(object view) _surfaceDialService.RotatedRight += SurfaceDialService_RotatedRight; _surfaceDialService.RotatedLeft += SurfaceDialService_RotatedLeft; _surfaceDialService.ButtonHolding += SurfaceDialService_ButtonHolding; + _surfaceDialService.ControlAcquired += SurfaceDialService_ControlAcquired; + _surfaceDialService.ControlLost += SurfaceDialService_ControlLost; var source = PresentationSource.FromVisual(this.View); if (source != null) @@ -259,6 +272,10 @@ protected override async void OnViewLoaded(object view) HideFromAltTab(View); } + private void SurfaceDialService_ControlLost(object sender, EventArgs e) => HasSurfaceDial = false; + + private void SurfaceDialService_ControlAcquired(object sender, EventArgs e) => HasSurfaceDial = true; + private void SurfaceDialService_ButtonHolding(object sender, EventArgs e) => WorkspaceViewModel.OpenPullRequest(); private void SurfaceDialService_RotatedLeft(object sender, EventArgs e) => WorkspaceViewModel.MoveUp(); diff --git a/src/GitLurker.UI/Views/ShellView.xaml b/src/GitLurker.UI/Views/ShellView.xaml index d337840..5ea9aac 100644 --- a/src/GitLurker.UI/Views/ShellView.xaml +++ b/src/GitLurker.UI/Views/ShellView.xaml @@ -57,7 +57,8 @@ - + + + + + Connected + +