From: sr55 Date: Sat, 9 Mar 2019 20:50:06 +0000 (+0000) Subject: WinGui: Bind "Ctrl-C" on the Error window. This *may* be usable in some instances... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c332cf6f061948c2f03c908faca59fa05d1aead4;p=handbrake WinGui: Bind "Ctrl-C" on the Error window. This *may* be usable in some instances where the screen doesn't render correctly to allow us to see the error. #1950 --- diff --git a/win/CS/HandBrakeWPF/Views/ErrorView.xaml b/win/CS/HandBrakeWPF/Views/ErrorView.xaml index f8ab63c6f..fb6f1ac7a 100644 --- a/win/CS/HandBrakeWPF/Views/ErrorView.xaml +++ b/win/CS/HandBrakeWPF/Views/ErrorView.xaml @@ -56,6 +56,7 @@ VerticalAlignment="Stretch" IsReadOnly="True" Text="{Binding Details}" + x:Name="errorText" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" /> diff --git a/win/CS/HandBrakeWPF/Views/ErrorView.xaml.cs b/win/CS/HandBrakeWPF/Views/ErrorView.xaml.cs index b21194e35..0effdbfdd 100644 --- a/win/CS/HandBrakeWPF/Views/ErrorView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/ErrorView.xaml.cs @@ -9,19 +9,45 @@ namespace HandBrakeWPF.Views { + using System; using System.Windows; + using System.Windows.Controls; + using System.Windows.Input; + + using HandBrakeWPF.Commands; + using HandBrakeWPF.ViewModels.Interfaces; - /// - /// Interaction logic for ErrorView.xaml - /// public partial class ErrorView : Window { - /// - /// Initializes a new instance of the class. - /// public ErrorView() + { + this.InitializeComponent(); + this.InputBindings.Add(new InputBinding(new CopyError(this.errorText), new KeyGesture(Key.C, ModifierKeys.Control))); // Copy Error + } + } + + public class CopyError : ICommand + { + private readonly TextBox textBlock; + + public CopyError(TextBox textBlock) { - InitializeComponent(); + this.textBlock = textBlock; } + + public bool CanExecute(object parameter) + { + return true; + } + + public void Execute(object parameter) + { + if (this.textBlock != null) + { + Clipboard.SetText(this.textBlock.Text); + } + } + + public event EventHandler CanExecuteChanged; } }