Example #1
0
        private void MouseAndKeyboardHookService_MouseAction(object sender, MouseHookEventArgs e)
        {
            var mustClose    = false;
            var activeScreen = Screen.FromPoint(new System.Drawing.Point(Cursor.Position.X, Cursor.Position.Y));
            var screen       = SystemInfoHelper.GetAllScreenInfos().Single(s => s.DeviceName == activeScreen.DeviceName);

            switch (Settings.Default.PasteBarPosition)
            {
            case PasteBarPosition.Top:
                if (e.Coords.Y - screen.Bounds.Top >= screen.Bounds.Bottom / 2)
                {
                    if (_canCloseIfMouseMovesAway)
                    {
                        mustClose = true;
                    }
                }
                else
                {
                    _canCloseIfMouseMovesAway = true;
                }
                break;

            case PasteBarPosition.Bottom:
                if (e.Coords.Y - screen.Bounds.Top <= screen.Bounds.Bottom / 2)
                {
                    if (_canCloseIfMouseMovesAway)
                    {
                        mustClose = true;
                    }
                }
                else
                {
                    _canCloseIfMouseMovesAway = true;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (mustClose)
            {
                if (_mouseAndKeyboardHookService != null)
                {
                    _mouseAndKeyboardHookService.MouseAction -= MouseAndKeyboardHookService_MouseAction;
                }
                Logger.Instance.Information($"Mouse moves away from the paste bar.");

                var delayer = new Delayer <object>(TimeSpan.FromMilliseconds(10));
                delayer.Action += (o, args) => HideBarButtonCommand?.Execute(null);
                delayer.ResetAndTick();
            }
        }
Example #2
0
        private void ExecutePasteCommand(DataEntry dataEntry)
        {
            var delayer = new Delayer <DataEntry>(TimeSpan.FromMilliseconds(200));

            delayer.Action += (sender, args) =>
            {
                Logger.Instance.Information("Paste command activated.");
                Requires.NotNull(args.Data, nameof(args.Data));
                HideBarButtonCommand.Execute(null);
                MessengerInstance.Send(new ComponentModel.Messages.Message(args.Data), MessageIdentifiers.PasteData);
            };
            delayer.ResetAndTick(dataEntry);
        }
Example #3
0
        private void MouseAndKeyboardHookService_HotKeyDetected(object sender, HotKeyEventArgs e)
        {
            if (_mouseAndKeyboardHookService != null)
            {
                _mouseAndKeyboardHookService.HotKeyDetected -= MouseAndKeyboardHookService_HotKeyDetected;
            }
            Logger.Instance.Information($"The keyboard shortcut has hit.");
            e.Handled = true;

            var delayer = new Delayer <object>(TimeSpan.FromMilliseconds(10));

            delayer.Action += (o, args) => HideBarButtonCommand?.Execute(null);
            delayer.ResetAndTick();
        }
Example #4
0
 private void ExecuteClickHyperlinkCommand(string uri)
 {
     Logger.Instance.Information("Hyperlink activated.");
     Process.Start(uri);
     HideBarButtonCommand.Execute(null);
 }
Example #5
0
 private void ExecuteDeactivatedCommand()
 {
     Logger.Instance.Information("Paste bar deactived.");
     HideBarButtonCommand.Execute(null);
 }