From 57bb9d7a447a29486d0de24bac17d492c9e81a5e Mon Sep 17 00:00:00 2001
From: Scrub <72096833+ScrubN@users.noreply.github.com>
Date: Mon, 31 Jul 2023 00:36:03 -0400
Subject: [PATCH] Allow pressing the enter key to search for
vods/clips/channels (#767)
---
TwitchDownloaderWPF/PageChatDownload.xaml | 2 +-
TwitchDownloaderWPF/PageChatDownload.xaml.cs | 14 ++++++++++++++
TwitchDownloaderWPF/PageClipDownload.xaml | 2 +-
TwitchDownloaderWPF/PageClipDownload.xaml.cs | 14 ++++++++++++++
TwitchDownloaderWPF/PageVodDownload.xaml | 2 +-
TwitchDownloaderWPF/PageVodDownload.xaml.cs | 16 +++++++++++++++-
TwitchDownloaderWPF/WindowMassDownload.xaml | 2 +-
TwitchDownloaderWPF/WindowMassDownload.xaml.cs | 13 +++++++++++++
8 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/TwitchDownloaderWPF/PageChatDownload.xaml b/TwitchDownloaderWPF/PageChatDownload.xaml
index 74e1a7a6..f23bdf5a 100644
--- a/TwitchDownloaderWPF/PageChatDownload.xaml
+++ b/TwitchDownloaderWPF/PageChatDownload.xaml
@@ -61,7 +61,7 @@
-
+
diff --git a/TwitchDownloaderWPF/PageChatDownload.xaml.cs b/TwitchDownloaderWPF/PageChatDownload.xaml.cs
index ebfa2175..73efa0ee 100644
--- a/TwitchDownloaderWPF/PageChatDownload.xaml.cs
+++ b/TwitchDownloaderWPF/PageChatDownload.xaml.cs
@@ -8,6 +8,7 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Input;
using System.Windows.Media.Imaging;
using TwitchDownloaderCore;
using TwitchDownloaderCore.Chat;
@@ -92,6 +93,11 @@ private void SetEnabledCropEnd(bool isEnabled)
}
private async void btnGetInfo_Click(object sender, RoutedEventArgs e)
+ {
+ await GetVideoInfo();
+ }
+
+ private async Task GetVideoInfo()
{
string id = ValidateUrl(textUrl.Text.Trim());
if (string.IsNullOrWhiteSpace(id))
@@ -576,5 +582,13 @@ private void MenuItemEnqueue_Click(object sender, RoutedEventArgs e)
WindowQueueOptions queueOptions = new WindowQueueOptions(this);
queueOptions.ShowDialog();
}
+
+ private async void TextUrl_OnKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Enter)
+ {
+ await GetVideoInfo();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/TwitchDownloaderWPF/PageClipDownload.xaml b/TwitchDownloaderWPF/PageClipDownload.xaml
index 27493508..6ac2fffb 100644
--- a/TwitchDownloaderWPF/PageClipDownload.xaml
+++ b/TwitchDownloaderWPF/PageClipDownload.xaml
@@ -60,7 +60,7 @@
-
+
diff --git a/TwitchDownloaderWPF/PageClipDownload.xaml.cs b/TwitchDownloaderWPF/PageClipDownload.xaml.cs
index 0b557d7d..8740483a 100644
--- a/TwitchDownloaderWPF/PageClipDownload.xaml.cs
+++ b/TwitchDownloaderWPF/PageClipDownload.xaml.cs
@@ -8,6 +8,7 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Input;
using System.Windows.Media.Imaging;
using TwitchDownloaderCore;
using TwitchDownloaderCore.Options;
@@ -34,6 +35,11 @@ public PageClipDownload()
}
private async void btnGetInfo_Click(object sender, RoutedEventArgs e)
+ {
+ await GetClipInfo();
+ }
+
+ private async Task GetClipInfo()
{
clipId = ValidateUrl(textUrl.Text.Trim());
if (string.IsNullOrWhiteSpace(clipId))
@@ -246,6 +252,14 @@ private void MenuItemEnqueue_Click(object sender, RoutedEventArgs e)
WindowQueueOptions queueOptions = new WindowQueueOptions(this);
queueOptions.ShowDialog();
}
+
+ private async void TextUrl_OnKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Enter)
+ {
+ await GetClipInfo();
+ }
+ }
}
}
diff --git a/TwitchDownloaderWPF/PageVodDownload.xaml b/TwitchDownloaderWPF/PageVodDownload.xaml
index 0232db18..f554e9eb 100644
--- a/TwitchDownloaderWPF/PageVodDownload.xaml
+++ b/TwitchDownloaderWPF/PageVodDownload.xaml
@@ -62,7 +62,7 @@
-
+
diff --git a/TwitchDownloaderWPF/PageVodDownload.xaml.cs b/TwitchDownloaderWPF/PageVodDownload.xaml.cs
index a4d098a0..ccd05774 100644
--- a/TwitchDownloaderWPF/PageVodDownload.xaml.cs
+++ b/TwitchDownloaderWPF/PageVodDownload.xaml.cs
@@ -11,6 +11,7 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Input;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using TwitchDownloaderCore;
@@ -70,8 +71,13 @@ private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e
e.Handled = true;
}
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0018:Inline variable declaration")]
private async void btnGetInfo_Click(object sender, RoutedEventArgs e)
+ {
+ await GetVideoInfo();
+ }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0018:Inline variable declaration")]
+ private async Task GetVideoInfo()
{
int videoId = ValidateUrl(textUrl.Text.Trim());
if (videoId <= 0)
@@ -530,5 +536,13 @@ private void numStartSecond_ValueChanged(object sender, HandyControl.Data.Functi
{
UpdateVideoSizeEstimates();
}
+
+ private async void TextUrl_OnKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Enter)
+ {
+ await GetVideoInfo();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/TwitchDownloaderWPF/WindowMassDownload.xaml b/TwitchDownloaderWPF/WindowMassDownload.xaml
index 02e71216..1beebb7c 100644
--- a/TwitchDownloaderWPF/WindowMassDownload.xaml
+++ b/TwitchDownloaderWPF/WindowMassDownload.xaml
@@ -30,7 +30,7 @@
-
+
diff --git a/TwitchDownloaderWPF/WindowMassDownload.xaml.cs b/TwitchDownloaderWPF/WindowMassDownload.xaml.cs
index aa1a06dc..be91cfa9 100644
--- a/TwitchDownloaderWPF/WindowMassDownload.xaml.cs
+++ b/TwitchDownloaderWPF/WindowMassDownload.xaml.cs
@@ -44,6 +44,11 @@ public WindowMassDownload(DownloadType Type)
}
private async void btnChannel_Click(object sender, RoutedEventArgs e)
+ {
+ await ChangeCurrentChannel();
+ }
+
+ private async Task ChangeCurrentChannel()
{
currentChannel = textChannel.Text;
videoList.Clear();
@@ -243,5 +248,13 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
: Translations.Strings.TitleClipMassDownloader;
AppSingleton.RequestTitleBarChange();
}
+
+ private async void TextChannel_OnKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Enter)
+ {
+ await ChangeCurrentChannel();
+ }
+ }
}
}