handle key events (#8279)

This commit is contained in:
Seraphima Zykova 2020-11-30 22:07:03 +03:00 committed by GitHub
parent f86182d062
commit c6078e3136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View File

@ -91,6 +91,22 @@ namespace FancyZonesEditor
Overlay.Show();
}
public void App_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == System.Windows.Input.Key.LeftShift || e.Key == System.Windows.Input.Key.RightShift)
{
MainWindowSettings.IsShiftKeyPressed = false;
}
}
public void App_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == System.Windows.Input.Key.LeftShift || e.Key == System.Windows.Input.Key.RightShift)
{
MainWindowSettings.IsShiftKeyPressed = true;
}
}
public static void ShowExceptionMessageBox(string message, Exception exception = null)
{
string fullMessage = FancyZonesEditor.Properties.Resources.Error_Report + PowerToysIssuesURL + " \n" + message;

View File

@ -19,6 +19,7 @@ namespace FancyZonesEditor
InitializeComponent();
KeyUp += GridEditorWindow_KeyUp;
KeyDown += ((App)Application.Current).App_KeyDown;
_stashedModel = (GridLayoutModel)(App.Overlay.CurrentDataContext as GridLayoutModel).Clone();
}
@ -36,6 +37,8 @@ namespace FancyZonesEditor
{
OnCancel(sender, null);
}
((App)Application.Current).App_KeyUp(sender, e);
}
private GridLayoutModel _stashedModel;

View File

@ -5,6 +5,7 @@
using System;
using System.Reflection;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using FancyZonesEditor.Utils;
@ -32,6 +33,9 @@ namespace FancyZonesEditor.Models
Window.Background = (Brush)properties[milliseconds % properties.Length].GetValue(null, null);
}
Window.KeyUp += ((App)Application.Current).App_KeyUp;
Window.KeyDown += ((App)Application.Current).App_KeyDown;
Window.Left = workArea.X;
Window.Top = workArea.Y;
Window.Width = workArea.Width;