public NotifyIconWindow(INotificationDispatcher notificationDispatcher, IHistoryMenuViewModel historyMenuViewModel) { _notificationDispatcher = notificationDispatcher; _historyMenuViewModel = historyMenuViewModel; InitializeComponent(); HistoryMenu.DataContext = _historyMenuViewModel; _notificationDispatcher.Subscribe(notification => { ShowNotification(notification.Notification); }); }
private void ConfigureEventTriggers() { _clipboard.Subscribe(notification => { Console.WriteLine("ClipboardUpdated"); _copypastaStateMachine.Fire(CopypastaTrigger.ClipboardUpdated); }); _notificationDispatcher.Subscribe(notification => { if (notification.Notification != null) { return; } Console.WriteLine("NotificationTimeout"); _copypastaStateMachine.Fire(CopypastaTrigger.Timeout); }); _ctrlVHotkey.HotkeyPressed += (sender, args) => { Console.WriteLine($"CtrlVPressed: Handled={_ctrlVHandled}"); args.Handled = _ctrlVHandled; _copypastaStateMachine.Fire(CopypastaTrigger.CtrlVPressed); }; _ctrlCHotkey.HotkeyPressed += (sender, args) => { Console.WriteLine($"CtrlCPressed: Handled={_ctrlCHandled}"); args.Handled = _ctrlCHandled; _copypastaStateMachine.Fire(CopypastaTrigger.CtrlCPressed); }; _keyTracker.KeyPressed += (sender, args) => { if (_keyTracker.Modifiers != ModifierKeys.None) { return; } if (_escHotkey.IsPressed) { return; } Console.WriteLine($"KeyPressed: Key={args.Key}, Handled={_keyPressHandled}"); args.Handled = _keyPressHandled; _copypastaStateMachine.Fire(_keyPressedTrigger, args.Key); }; _keyTracker.KeyPressed += (sender, args) => { if (_keyTracker.Modifiers == ModifierKeys.None) { return; } if (_ctrlCHotkey.IsPressed || _ctrlVHotkey.IsPressed) { return; } Console.WriteLine($"ModifierPressed: Key={args.Key}, Handled={_modifierPressHandled}"); args.Handled = _modifierPressHandled; _copypastaStateMachine.Fire(CopypastaTrigger.ModifierPressed); }; _escHotkey.HotkeyPressed += (sender, args) => { Console.WriteLine($"EscPressed: Handled={_escPressHandled}"); args.Handled = _escPressHandled; _copypastaStateMachine.Fire(CopypastaTrigger.EscPressed); }; _clipboardBindingManager.Subscribe(clipboardItem => { Console.WriteLine("BindingAdded"); _copypastaStateMachine.Fire(CopypastaTrigger.ClipboardBound); }); }