diff --git a/Dashboard/Controls/PlanViewerControl.xaml b/Dashboard/Controls/PlanViewerControl.xaml index a3610c9e..f8bdfd8c 100644 --- a/Dashboard/Controls/PlanViewerControl.xaml +++ b/Dashboard/Controls/PlanViewerControl.xaml @@ -1,7 +1,10 @@ + Background="{DynamicResource BackgroundBrush}" + Focusable="True" + PreviewMouseDown="PlanViewerControl_PreviewMouseDown" + PreviewKeyDown="PlanViewerControl_PreviewKeyDown"> diff --git a/Dashboard/Controls/PlanViewerControl.xaml.cs b/Dashboard/Controls/PlanViewerControl.xaml.cs index fc26e470..452eba6f 100644 --- a/Dashboard/Controls/PlanViewerControl.xaml.cs +++ b/Dashboard/Controls/PlanViewerControl.xaml.cs @@ -1436,6 +1436,38 @@ private void PlanScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventAr } } + private void PlanViewerControl_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + Focus(); + } + + private void PlanViewerControl_PreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.V && Keyboard.Modifiers == ModifierKeys.Control + && e.OriginalSource is not TextBox) + { + var text = Clipboard.GetText(); + if (!string.IsNullOrWhiteSpace(text)) + { + e.Handled = true; + try + { + System.Xml.Linq.XDocument.Parse(text); + } + catch (System.Xml.XmlException ex) + { + MessageBox.Show( + $"The plan XML is not valid:\n\n{ex.Message}", + "Invalid Plan XML", + MessageBoxButton.OK, + MessageBoxImage.Warning); + return; + } + LoadPlan(text, "Pasted Plan"); + } + } + } + #endregion #region Save & Statement Selection diff --git a/Dashboard/Controls/QueryPerformanceContent.xaml b/Dashboard/Controls/QueryPerformanceContent.xaml index b7c71c9d..c2b50c41 100644 --- a/Dashboard/Controls/QueryPerformanceContent.xaml +++ b/Dashboard/Controls/QueryPerformanceContent.xaml @@ -32,8 +32,12 @@ - - + + + + + +