Skip to content

Commit

Permalink
Allow pressing the enter key to search for vods/clips/channels (#767)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrubN authored Jul 31, 2023
1 parent 02c40cc commit 57bb9d7
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 5 deletions.
2 changes: 1 addition & 1 deletion TwitchDownloaderWPF/PageChatDownload.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<!-- MIDDLE -->
<WrapPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="4" Margin="0,0,0,10" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Margin="3,8,3,3" Text="{lex:Loc VodClipLink}" Foreground="{DynamicResource AppText}" />
<TextBox x:Name="textUrl" Margin="3" MinWidth="200" MaxWidth="400" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<TextBox x:Name="textUrl" Margin="3" MinWidth="200" MaxWidth="400" KeyDown="TextUrl_OnKeyDown" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<Button x:Name="btnGetInfo" Margin="3" MinWidth="50" Content="{lex:Loc GetInfo}" RenderTransformOrigin="0.503,0.508" Click="btnGetInfo_Click" Background="{DynamicResource ActionButtonBackground}" Foreground="{DynamicResource ActionButtonText}" BorderBrush="{DynamicResource ActionButtonBorder}" />
</WrapPanel>
<StackPanel Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Margin="0,20,0,0" Orientation="Horizontal" HorizontalAlignment="Center">
Expand Down
14 changes: 14 additions & 0 deletions TwitchDownloaderWPF/PageChatDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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();
}
}
}
}
2 changes: 1 addition & 1 deletion TwitchDownloaderWPF/PageClipDownload.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<!-- MIDDLE -->
<WrapPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="4" Margin="0,0,0,10" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Margin="3,8,3,3" Text="{lex:Loc ClipLinkId}" Foreground="{DynamicResource AppText}" />
<TextBox x:Name="textUrl" Margin="3" MinWidth="200" MaxWidth="400" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<TextBox x:Name="textUrl" Margin="3" MinWidth="200" MaxWidth="400" KeyDown="TextUrl_OnKeyDown" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<Button x:Name="btnGetInfo" Margin="3" MinWidth="50" Content="{lex:Loc GetInfo}" Click="btnGetInfo_Click" Background="{DynamicResource ActionButtonBackground}" Foreground="{DynamicResource ActionButtonText}" BorderBrush="{DynamicResource ActionButtonBorder}"/>
</WrapPanel>
<StackPanel Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Margin="0,20,0,0" Orientation="Horizontal" HorizontalAlignment="Center">
Expand Down
14 changes: 14 additions & 0 deletions TwitchDownloaderWPF/PageClipDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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))
Expand Down Expand Up @@ -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();
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion TwitchDownloaderWPF/PageVodDownload.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<!-- MIDDLE -->
<WrapPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="4" Margin="0,0,0,10" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Margin="3,8,3,3" Text="{lex:Loc VodLinkId}" Foreground="{DynamicResource AppText}" />
<TextBox x:Name="textUrl" Margin="3" MinWidth="200" MaxWidth="400" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<TextBox x:Name="textUrl" Margin="3" MinWidth="200" MaxWidth="400" KeyDown="TextUrl_OnKeyDown" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<Button x:Name="btnGetInfo" Margin="3" MinWidth="50" Content="{lex:Loc GetInfo}" Click="btnGetInfo_Click" Background="{DynamicResource ActionButtonBackground}" Foreground="{DynamicResource ActionButtonText}" BorderBrush="{DynamicResource ActionButtonBorder}"/>
</WrapPanel>
<StackPanel Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Margin="0,20,0,0" Orientation="Horizontal" HorizontalAlignment="Center">
Expand Down
16 changes: 15 additions & 1 deletion TwitchDownloaderWPF/PageVodDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
}
}
}
2 changes: 1 addition & 1 deletion TwitchDownloaderWPF/WindowMassDownload.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</ComboBox>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBox x:Name="textChannel" HorizontalAlignment="Center" Height="23" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="194" Margin="0,6,0,0" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<TextBox x:Name="textChannel" HorizontalAlignment="Center" Height="23" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="194" Margin="0,6,0,0" KeyDown="TextChannel_OnKeyDown" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<Button x:Name="btnChannel" Content="{lex:Loc SetChannel}" HorizontalAlignment="Left" Margin="3,6,0,0" VerticalAlignment="Top" MinWidth="84" Height="30" Click="btnChannel_Click" Background="{DynamicResource ActionButtonBackground}" Foreground="{DynamicResource ActionButtonText}" BorderBrush="{DynamicResource ActionButtonBorder}"/>
</StackPanel>
<WrapPanel HorizontalAlignment="Left" Height="329" Margin="10,54,0,0" VerticalAlignment="Top" Width="772"/>
Expand Down
13 changes: 13 additions & 0 deletions TwitchDownloaderWPF/WindowMassDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
}
}
}

0 comments on commit 57bb9d7

Please sign in to comment.