Skip to content

Commit

Permalink
SteamScreenshots: Add support to close the fullscreen screenshot view…
Browse files Browse the repository at this point in the history
… by double clicking
  • Loading branch information
darklinkpower committed Dec 9, 2024
1 parent ac7e79c commit 83e20f3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Grid>

<Image x:Name="ImageA"
MouseLeftButtonDown="Image_MouseLeftButtonDown"
Source="{Binding BitmapImageA, IsAsync=False}"
RenderOptions.BitmapScalingMode="Fant"
Stretch="Uniform"
Expand All @@ -20,6 +21,7 @@
VerticalAlignment="Center"/>

<Image x:Name="ImageB"
MouseLeftButtonDown="Image_MouseLeftButtonDown"
Source="{Binding BitmapImageB, IsAsync=False}"
RenderOptions.BitmapScalingMode="Fant"
Stretch="Uniform"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ namespace SteamScreenshots.Screenshots
/// </summary>
public partial class ScreenshotsView : UserControl
{
private DateTime _lastClickTime = DateTime.MinValue;
private const int DoubleClickTimeLimit = 500;

public ScreenshotsView()
{
SetControlTextBlockStyle();
Expand Down Expand Up @@ -53,5 +56,21 @@ private void SetControlTextBlockStyle()
Resources.Add(typeof(TextBlock), implicitStyle);
}
}

private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
var currentTime = DateTime.Now;
var elapsedMilliseconds = (currentTime - _lastClickTime).TotalMilliseconds;

if (elapsedMilliseconds < DoubleClickTimeLimit)
{
if (DataContext is ScreenshotsViewModel viewModel && viewModel.CloseWindowCommand.CanExecute(null))
{
viewModel.CloseWindowCommand.Execute(null);
}
}

_lastClickTime = currentTime;
}
}
}

0 comments on commit 83e20f3

Please sign in to comment.