1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2024-10-17 09:42:45 +02:00
TweetDuck/Browser/Handling/KeyboardHandlerNotification.cs
2021-12-17 20:27:48 +01:00

38 lines
996 B
C#

using System.Windows.Forms;
using CefSharp;
using TweetDuck.Browser.Notification;
using TweetDuck.Controls;
namespace TweetDuck.Browser.Handling {
sealed class KeyboardHandlerNotification : KeyboardHandlerBase {
private readonly FormNotificationBase notification;
public KeyboardHandlerNotification(FormNotificationBase notification) {
this.notification = notification;
}
protected override bool HandleRawKey(IWebBrowser browserControl, Keys key, CefEventFlags modifiers) {
if (base.HandleRawKey(browserControl, key, modifiers)) {
return true;
}
switch (key) {
case Keys.Enter:
notification.InvokeAsyncSafe(notification.FinishCurrentNotification);
return true;
case Keys.Escape:
notification.InvokeAsyncSafe(notification.HideNotification);
return true;
case Keys.Space:
notification.InvokeAsyncSafe(() => notification.FreezeTimer = !notification.FreezeTimer);
return true;
default:
return false;
}
}
}
}