From b0cb150b35b3994a290b129cd60371298f2b255a Mon Sep 17 00:00:00 2001 From: Kalakoi Date: Thu, 22 May 2025 14:23:04 -0400 Subject: [PATCH] Added ability for competition overlay to stay on top of other windows and be clicked through. --- osrs-toolbox/Models/HomePageModel.cs | 6 ++++++ osrs-toolbox/ViewModels/CompetitionOverlayViewModel.cs | 10 +++++++--- osrs-toolbox/ViewModels/HomePageViewModel.cs | 7 +++++++ osrs-toolbox/Views/CompetitionOverlayView.xaml | 6 +++--- osrs-toolbox/Views/CompetitionOverlayView.xaml.cs | 7 +++++++ osrs-toolbox/Views/HomePageView.xaml | 2 ++ 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/osrs-toolbox/Models/HomePageModel.cs b/osrs-toolbox/Models/HomePageModel.cs index 639dd20..9cc7e9b 100644 --- a/osrs-toolbox/Models/HomePageModel.cs +++ b/osrs-toolbox/Models/HomePageModel.cs @@ -18,6 +18,7 @@ namespace osrs_toolbox private bool _hideZeroKC = false; private ICommand _toggleCompetitionOverlay; + private ICommand _toggleCompetitionOverlayClickThrough; public int CompetitionID { @@ -50,5 +51,10 @@ namespace osrs_toolbox get { return _toggleCompetitionOverlay; } set { SetProperty(ref _toggleCompetitionOverlay, value, nameof(ToggleCompetitionOverlay)); } } + public ICommand ToggleCompetitionOverlayClickThrough + { + get { return _toggleCompetitionOverlayClickThrough; } + set { SetProperty(ref _toggleCompetitionOverlayClickThrough, value, nameof(ToggleCompetitionOverlayClickThrough)); } + } } } diff --git a/osrs-toolbox/ViewModels/CompetitionOverlayViewModel.cs b/osrs-toolbox/ViewModels/CompetitionOverlayViewModel.cs index 976b19e..98f1985 100644 --- a/osrs-toolbox/ViewModels/CompetitionOverlayViewModel.cs +++ b/osrs-toolbox/ViewModels/CompetitionOverlayViewModel.cs @@ -67,6 +67,7 @@ namespace osrs_toolbox private void DoUpdate(object obj) { GridOutput = new StackPanel(); + GridOutput.IsHitTestVisible = false; Competition c = new Competition(); try { @@ -85,7 +86,8 @@ namespace osrs_toolbox VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, FontWeight = FontWeights.ExtraBold, - TextWrapping = TextWrapping.Wrap + TextWrapping = TextWrapping.Wrap, + IsHitTestVisible = false }); OnPropertyChanged(nameof(GridOutput)); return; @@ -106,13 +108,15 @@ namespace osrs_toolbox VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, FontWeight = FontWeights.ExtraBold, - TextWrapping = TextWrapping.Wrap + TextWrapping = TextWrapping.Wrap, + IsHitTestVisible = false }); foreach (CompetitionParticipation cp in c.participations) { StackPanel SubStack = new StackPanel() { - Orientation = Orientation.Horizontal + Orientation = Orientation.Horizontal, + IsHitTestVisible = false }; Image typeImage = new Image(); diff --git a/osrs-toolbox/ViewModels/HomePageViewModel.cs b/osrs-toolbox/ViewModels/HomePageViewModel.cs index 04a4f3c..ce79973 100644 --- a/osrs-toolbox/ViewModels/HomePageViewModel.cs +++ b/osrs-toolbox/ViewModels/HomePageViewModel.cs @@ -27,6 +27,7 @@ namespace osrs_toolbox private void InitializeCommands() { ToggleCompetitionOverlay = new RelayCommand(DoToggleCompetitionOverlay); + ToggleCompetitionOverlayClickThrough = new RelayCommand(DoToggleCompetitionOverlayClickThrough); } private void DoToggleCompetitionOverlay(object obj) @@ -53,5 +54,11 @@ namespace osrs_toolbox Properties.Settings.Default.Save(); } } + + private void DoToggleCompetitionOverlayClickThrough(object obj) + { + if (CompetitionOverlayView.Current == null) { return; } + (CompetitionOverlayView.Current as CompetitionOverlayView).MakeClickThrough(); + } } } diff --git a/osrs-toolbox/Views/CompetitionOverlayView.xaml b/osrs-toolbox/Views/CompetitionOverlayView.xaml index 45bb0d2..8ea8bca 100644 --- a/osrs-toolbox/Views/CompetitionOverlayView.xaml +++ b/osrs-toolbox/Views/CompetitionOverlayView.xaml @@ -5,7 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:osrs_toolbox" mc:Ignorable="d" - Title="Competition Info" Height="800" Width="500" AllowsTransparency="True" Background="Transparent" WindowStyle="None" ResizeMode="NoResize" SizeToContent="WidthAndHeight" MouseDown="Window_MouseDown"> + Title="Competition Info" Height="800" Width="500" AllowsTransparency="True" Background="Transparent" WindowStyle="None" ResizeMode="NoResize" SizeToContent="WidthAndHeight" MouseDown="Window_MouseDown" Topmost="True"> @@ -32,8 +32,8 @@ - - + + diff --git a/osrs-toolbox/Views/CompetitionOverlayView.xaml.cs b/osrs-toolbox/Views/CompetitionOverlayView.xaml.cs index a55e534..d9e002e 100644 --- a/osrs-toolbox/Views/CompetitionOverlayView.xaml.cs +++ b/osrs-toolbox/Views/CompetitionOverlayView.xaml.cs @@ -8,6 +8,7 @@ using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; +using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; @@ -32,5 +33,11 @@ namespace osrs_toolbox if (e.LeftButton == MouseButtonState.Pressed) DragMove(); } + + public void MakeClickThrough() + { + var hwnd = new WindowInteropHelper(this).Handle; + WindowsServices.SetWindowExTransparent(hwnd); + } } } diff --git a/osrs-toolbox/Views/HomePageView.xaml b/osrs-toolbox/Views/HomePageView.xaml index 1057787..3191050 100644 --- a/osrs-toolbox/Views/HomePageView.xaml +++ b/osrs-toolbox/Views/HomePageView.xaml @@ -18,6 +18,7 @@ + @@ -35,5 +36,6 @@