Added ability for competition overlay to stay on top of other windows and be clicked through.

This commit is contained in:
2025-05-22 14:23:04 -04:00
parent 555488b8bb
commit b0cb150b35
6 changed files with 32 additions and 6 deletions

View File

@@ -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)); }
}
}
}

View File

@@ -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();

View File

@@ -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();
}
}
}

View File

@@ -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">
<Window.DataContext>
<local:CompetitionOverlayViewModel/>
</Window.DataContext>
@@ -32,8 +32,8 @@
</Grid.ColumnDefinitions>
<local:OutlinedTextBlock Grid.Column="0" Text="Competition Tracker" Margin="3" FontWeight="ExtraBold" FontSize="16" Stroke="Black" Fill="White" StrokeThickness="1" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</Grid>
<Border Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="Black" BorderThickness="0" Margin="3" Padding="3" CornerRadius="4">
<ContentControl Content="{Binding GridOutput, UpdateSourceTrigger=PropertyChanged}"/>
<Border Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="Black" BorderThickness="0" Margin="3" Padding="3" CornerRadius="4" IsHitTestVisible="False">
<ContentControl Content="{Binding GridOutput, UpdateSourceTrigger=PropertyChanged}" IsHitTestVisible="False"/>
</Border>
</Grid>
</Window>

View File

@@ -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);
}
}
}

View File

@@ -18,6 +18,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
@@ -35,5 +36,6 @@
<CheckBox IsChecked="{Binding HideOtherPlayers, UpdateSourceTrigger=PropertyChanged}" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
<CheckBox IsChecked="{Binding HideZeroGained, UpdateSourceTrigger=PropertyChanged}" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
<Button Command="{Binding ToggleCompetitionOverlay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="3" Padding="3" Content="Toggle Competition Overlay"/>
<Button Command="{Binding ToggleCompetitionOverlayClickThrough, UpdateSourceTrigger=PropertyChanged}" Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="3" Padding="3" Content="Make Overlay Click-Through"/>
</Grid>
</Window>