rework throttle

reuse throttle mechanism for catching global keys
This commit is contained in:
Oleksandr Bezdieniezhnykh
2024-08-14 02:02:26 +03:00
parent 468d28d9d8
commit 78776d37bd
6 changed files with 38 additions and 28 deletions
+1 -5
View File
@@ -1,7 +1,6 @@
using System.IO;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
using Azaion.Annotator.DTO;
using LibVLCSharp.Shared;
using MediatR;
@@ -24,8 +23,6 @@ public class PlayerControlHandler(LibVLC libVLC,
private const int LARGE_STEP = 5000;
private const int RESULT_WIDTH = 1280;
private static readonly string[] CatchSenders = ["ForegroundWindow", "ScrollViewer", "VideoView", "GridSplitter"];
private readonly Dictionary<Key, PlaybackControlEnum> _keysControlEnumDict = new()
{
{ Key.Space, PlaybackControlEnum.Pause },
@@ -55,8 +52,7 @@ public class PlayerControlHandler(LibVLC libVLC,
public async Task Handle(KeyEvent notification, CancellationToken cancellationToken)
{
if (!CatchSenders.Contains(notification.Sender.GetType().Name))
return;
logger.LogInformation($"Catch {notification.Args.Key} by {notification.Sender.GetType().Name}");
var key = notification.Args.Key;
var keyNumber = (int?)null;