From 83e20f348aa734ae714d1fb74bb877cb4717a5c6 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 9 Dec 2024 01:48:32 -0600 Subject: [PATCH] SteamScreenshots: Add support to close the fullscreen screenshot view by double clicking --- .../ScreenshotsView/ScreenshotsView.xaml | 2 ++ .../ScreenshotsView/ScreenshotsView.xaml.cs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/source/Generic/SteamScreenshots/ScreenshotsView/ScreenshotsView.xaml b/source/Generic/SteamScreenshots/ScreenshotsView/ScreenshotsView.xaml index 4fb34c05b..61acd3dae 100644 --- a/source/Generic/SteamScreenshots/ScreenshotsView/ScreenshotsView.xaml +++ b/source/Generic/SteamScreenshots/ScreenshotsView/ScreenshotsView.xaml @@ -12,6 +12,7 @@ public partial class ScreenshotsView : UserControl { + private DateTime _lastClickTime = DateTime.MinValue; + private const int DoubleClickTimeLimit = 500; + public ScreenshotsView() { SetControlTextBlockStyle(); @@ -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; + } } } \ No newline at end of file