private void Initialize()
 {
     ItsPlaybackHotKeyBindings = new PlaybackHotKeyBindings();
     _keyHandler = new SpotifyKeyHandler {ItsPlaybackHotKeyBindings = ItsPlaybackHotKeyBindings};
     _keyCapture = new KeyCapture(_keyHandler);
     _keyCapture.HookKeys();
 }
 /// <summary>
 /// Lets you register a custom key handler. You are responsible for ensuring that each key is only handled by one handler.  This method will throw if
 /// you try to add a duplicate key handler.
 /// </summary>
 /// <param name="handler">The handler to register</param>
 public void RegisterHandler(IKeyHandler handler)
 {
     foreach (var key in handler.KeysHandled)
     {
         KeyHandlers.Add(key, handler);
     }
 }
Exemple #3
0
        /// <summary>
        /// Can we set such a DefaultKeyHandler?
        /// Prevents endless recursive loops.
        /// </summary>
        /// <param name="nextHandler">Canditate to test</param>
        /// <returns>true, if setting DefaultKeyHandler to nextHandler causes no recursion.</returns>
        public bool NextHandlerValid(IKeyHandler nextHandler)
        {
            // setting to null is perfectly fine
            // (turning off the redirection)
            if (nextHandler == null)
            {
                return(true);
            }

            // setting to itself would cause
            // an infinite recursion
            if (nextHandler == this)
            {
                return(false);
            }

            IKeyHandler current = nextHandler;

            while (current != null)
            {
                current = current.DefaultKeyHandler;
                if (current == this)
                {
                    return(false);
                }
            }
            return(true);
        }
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (tcTabControl.SelectedTab != null)
            {
                IKeyHandler keyHandler = tcTabControl.SelectedTab as IKeyHandler;

                if (keyHandler != null)
                {
                    if (keyHandler.ProcessKey(keyData))
                    {
                        return(true);
                    }
                }
            }

            switch (keyData)
            {
            case Keys.F5: btnOpenPatientRecord.PerformClick(); return(true);

            case Keys.F6: btnViewTasks.PerformClick(); return(true);

            case Keys.F7: btnViewApiLog.PerformClick(); return(true);

            default: return(base.ProcessCmdKey(ref msg, keyData));
            }
        }
Exemple #5
0
        public SlammerUIHandler(ILog log,
                                WindowTools windowTools,
                                ProcessMem processMem,
                                IComponentContext container,
                                IKeyHandler keyHandler)
        {
            _log         = log;
            _windowTools = windowTools;
            _processMem  = processMem;
            _container   = container;
            _keyHandler  = keyHandler;

            try
            {
                _game = _container.Resolve <IGame>();
                _log.Info("Found plugin for " + _game.name);
            }
            catch
            {
                _log.Fatal("Error - no plugins for any games found");
                return;
            }
            _log.Warn("Initializing plugin, please load " + _game.name);
            try
            {
                _process     = _windowTools.GetProcess(_game.exe, new TimeSpan(0, 1, 0))[0];
                _ui.gameName = _game.name;
            }
            catch
            {
                _log.Fatal("Error - unable to load game");
                return;
            }
        }
Exemple #6
0
        /// <summary>
        /// Registers a keypress with the editor.
        /// </summary>
        /// <param name="key">The key press info</param>
        /// <param name="prototype">if specified, the foreground and background color will be taken from this prototype, otherwise the system defaults will be used</param>
        public void RegisterKeyPress(ConsoleKeyInfo key, ConsoleCharacter?prototype = null)
        {
            Context.Reset();
            Context.KeyPressed       = key;
            Context.CharacterToWrite = new ConsoleCharacter(Context.KeyPressed.KeyChar,
                                                            prototype.HasValue ? prototype.Value.ForegroundColor : ConsoleString.DefaultForegroundColor,
                                                            prototype.HasValue ? prototype.Value.BackgroundColor : ConsoleString.DefaultBackgroundColor);

            IKeyHandler handler = null;

            if (KeyHandlers.TryGetValue(Context.KeyPressed.Key, out handler) == false && RichTextCommandLineReader.IsWriteable(Context.KeyPressed))
            {
                WriteCharacterForPressedKey(Context);
                DoSyntaxHighlighting(Context);
            }
            else if (handler != null)
            {
                handler.Handle(Context);

                if (Context.Intercept == false && RichTextCommandLineReader.IsWriteable(Context.KeyPressed))
                {
                    WriteCharacterForPressedKey(Context);
                }

                DoSyntaxHighlighting(Context);
            }
            FireValueChanged();
        }
 /// <summary>
 /// Registers a KeyHandler that is capable for handling Keystrokes on the main-window
 /// </summary>
 /// <param name="handler">the handler that will process keystrokes</param>
 public void RegisterKeyHandler(IKeyHandler handler)
 {
     lock (handlers)
     {
         handlers.Add(handler);
     }
 }
Exemple #8
0
        public StartupHandler(IScreens screensInfo, IVirtualDesktopCollection virtualDesktops, IContainerNodeCreater containerNodeCreator, IVirtualDesktopCreater virtualDesktopCreator, IScreenNodeCreater screenNodeCreator, ISignalHandler signal, IKeyHandler keyHandler, ICommandHelper commandHelper, IWindowTracker windowTracker, IPInvokeHandler pinvokeHandler)
        {
            this.screensInfo          = screensInfo;
            this.desktops             = virtualDesktops;
            this.containerNodeCreator = containerNodeCreator;
            this.signal          = signal;
            this.keyHandler      = keyHandler;
            this.commandHelper   = commandHelper;
            this.windowTracker   = windowTracker;
            this.pinvokeHandler  = pinvokeHandler;
            this.HandlesToIgnore = new List <IntPtr>();

            var result = screensInfo.AllScreens.GetOrderRect();

            _screens = result.rect.ToArray();

            for (var i = 0; i < desktops.Count; i++)
            {
                var screensToAdd = _screens.Select((rect, i) => screenNodeCreator.Create("Screen" + i, rect, dir: result.direction)).ToArray();
                desktops[i] = virtualDesktopCreator.Create(i, rect: _screens.TotalRect(), dir: result.direction, childs: screensToAdd);
                desktops[i].Hide();
            }

            desktops.Index = 0;
            desktops.ActiveDesktop.Show();
        }
        public void RegisterKeyPress(ConsoleKeyInfo key)
        {
            Context.Reset();
            Context.KeyPressed       = key;
            Context.CharacterToWrite = new ConsoleCharacter(Context.KeyPressed.KeyChar);

            IKeyHandler handler = null;

            if (KeyHandlers.TryGetValue(Context.KeyPressed.Key, out handler) == false && RichTextCommandLineReader.IsWriteable(Context.KeyPressed))
            {
                WriteCharacterForPressedKey(Context.KeyPressed);
                DoSyntaxHighlighting(Context);
            }
            else if (handler != null)
            {
                handler.Handle(Context);

                if (Context.Intercept == false && RichTextCommandLineReader.IsWriteable(Context.KeyPressed))
                {
                    WriteCharacterForPressedKey(Context.KeyPressed);
                }

                DoSyntaxHighlighting(Context);
            }
            FireValueChanged();
        }
 /// <summary>
 /// Unregisters the given key handler from the reader.  You should only do this if you're planning on overriding the default handlers, and you should do so
 /// with caution.
 /// </summary>
 /// <param name="handler">The handler to unregister</param>
 public void UnregisterHandler(IKeyHandler handler)
 {
     foreach (var key in handler.KeysHandled)
     {
         KeyHandlers.Remove(key);
     }
 }
Exemple #11
0
        /// <summary>
        /// Can we set such a DefaultKeyHandler?
        /// Prevents endless recursive loops.
        /// </summary>
        /// <param name="nextHandler">Canditate to test</param>
        /// <returns>true, if setting DefaultKeyHandler to nextHandler causes no recursion.</returns>
        public bool NextHandlerValid(IKeyHandler nextHandler)
        {
            // setting to null is perfectly fine
            // (turning off the redirection)
            if (nextHandler == null)
            {
                return true;
            }

            // setting to itself would cause
            // an infinite recursion
            if (nextHandler == this)
            {
                return false;
            }

            IKeyHandler current = nextHandler;
            while (current != null)
            {
                current = current.DefaultKeyHandler;
                if (current == this)
                {
                    return false;
                }
            }
            return true;
        }
Exemple #12
0
        public void EnableTacticalCameraTriggers()
        {
            if (AreTacticalCameraTriggersEnabled)
            {
                throw new InvalidOperationException("Tactical camera is already running.");
            }

            AreTacticalCameraTriggersEnabled = true;
            if (_tacticalCameraSettings.UnlimitedZoomEnabled)
            {
                _gameValueService.EnableUnlimitedZoom();
            }
            _gameValueService.DisableFreeCamera();
            _gameValueService.EnableZoom();
            _gameValueService.EnableCollisionZoomAdjustment();
            _gameValueService.EnableAutoCameraAngleAdjustment();
            _gameValueService.EnableCenteringCameraBehindCharacter();
            _gameValueService.SetCameraZoomDistance(0);

            _keyHandler = _tacticalCameraKeyHandlerFactory.CreateTacticalCameraKeyHandler(_gameValueService, _tacticalCameraSettings, _gameProcess);

            _userInputHandler = _userInputHandlerFactory.CreateUserInputHandler
                                (
                _keyHandler,
                _gameValueService
                                );

            _userInputHandler.StartProcessingInputEvents();
        }
Exemple #13
0
 public static object GetKey(IKeyHandler data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     return(data.GetKey());
 }
Exemple #14
0
        public Form1()
        {
            InitializeComponent();

            // resources allocation part
            captainHook = new CGlobalKeyboardHook();
            keyHandler  = new CheonJiInKeyHandler(Hancheck, FormShow, FormHide);
        }
Exemple #15
0
        /// <summary>
        /// Removes a certain key listener
        /// </summary>
        /// <param name="Key">Key to remove from</param>
        /// <param name="Handler">The <see cref="IKeyHandler"/> to remove</param>
        public static void RemoveKeyListener(Keys Key, IKeyHandler Handler)
        {
            HashSet <IKeyHandler> Handlers;

            if (_KeyHandlers.TryGetValue(Key, out Handlers))
            {
                Handlers.Remove(Handler);
            }
        }
        public KeyBoardKey(CustomizedKey key, IKeyHandler keyHandler)
            : this()
        {
            this.Key = key;

            this.KeyHandler = keyHandler;

            this.KeyButton.Text = key.KeyChar;
        }
 /// <summary>
 /// Removes a registered handler
 /// </summary>
 /// <param name="handler">the handler that does not process keystrokes anymore</param>
 public void UnRegisterKeyHandler(IKeyHandler handler)
 {
     lock (handlers)
     {
         if (handlers.Contains(handler))
         {
             handlers.Remove(handler);
         }
     }
 }
Exemple #18
0
 public static IKeyHandler GetKey(IKeyHandler handler, Point p)
 {
     instance.Position = p;
     instance.ShowDialog();
     if (instance.Cancelled)
     {
         return(handler);
     }
     return(new DefKeyHandler(instance.KeyCode));
 }
Exemple #19
0
 public KpsButton(int position)
 {
     color    = new KpsButtonColor();
     Visible  = true;
     AutoSize = false;
     Size     = new Size(36, 36);
     Location = new Point(40 * position, 0);
     createLabel();
     keyhandler = NoKeyHandler.Get();
     UpdateColor();
 }
 public UserInputHandler
 (
     IHotkeyConditionService hotkeyConditionService,
     IKeyMapper keyMapper,
     IKeyHandler keyHandler
 )
 {
     _hotkeyConditionService = hotkeyConditionService;
     _keyMapper  = keyMapper;
     _keyHandler = keyHandler;
 }
 public ConsoleInputHandler(IConsole console,
                            IConsoleWriter consoleWriter,
                            IKeyHandler keyHandler,
                            IHistoryNavigator historyNavigator,
                            IPromptProvider promptProvider)
 {
     _console          = console;
     _consoleWriter    = consoleWriter;
     _keyHandler       = keyHandler;
     _historyNavigator = historyNavigator;
     _promptProvider   = promptProvider;
 }
Exemple #22
0
    public CanvasControl()
    {
        DoubleBuffered = true;
        SetStyle(ControlStyles.ResizeRedraw, true);
        mouseWheelIndent = 0;
        ZoomScale        = 1;

        _keyHandler = new CanvasKeyHandler(this);

        // An event is published when the selected shape is changed. The canvas is subscribed to this event so that it can react accordingly.
        Drawables.SelectedShapeChanged += OnSelectedShapeChanged;
    }
Exemple #23
0
 public KpsButton(int position, frmMain form)
 {
     this.frm = form;
     color    = new KpsButtonColor();
     Visible  = true;
     AutoSize = false;
     Size     = new Size(40, 36);
     Location = new Point(40 * position, 0);
     createPanel();
     createLabel();
     Handler = NoKeyHandler.Get();
     UpdateColor();
 }
Exemple #24
0
        private void DisposeHandlers()
        {
            if (_keyHandler != null)
            {
                _keyHandler.Dispose();
                _keyHandler = null;
            }

            if (_userInputHandler != null)
            {
                _userInputHandler.Dispose();
                _userInputHandler = null;
            }
        }
 public KeyActivator(
     IWebProcessor webProcessor,
     ICookieManager cookieManager,
     ISteamAuthenticator steamAuthenticator,
     IKeyHandler keyHandler,
     BotSettings botSettings,
     ILogger logger)
 {
     this.webProcessor       = webProcessor;
     this.cookieManager      = cookieManager;
     this.steamAuthenticator = steamAuthenticator;
     this.keyHandler         = keyHandler;
     this.botSettings        = botSettings;
     this.logger             = logger;
 }
Exemple #26
0
        public static void HandlePreviewKeyDown(this IKeyHandler keyHandler, object sender, System.Windows.Input.KeyEventArgs e)
        {
            //bool fFocusedControlIsTextBox = FocusManager.GetFocusedElement(this).GetType().Equals(typeof(TextBox));
            var fFocusedControlIsTextBox = Keyboard.FocusedElement != null && Keyboard.FocusedElement.GetType() == typeof(TextBox);

            if (fFocusedControlIsTextBox)
            {
                e.Handled = false;
            }
            else if (keyHandler != null)
            {
                var handled = keyHandler.HandleKeyDown(e.Key);
                e.Handled = handled;
            }
        }
Exemple #27
0
        /// <summary>
        /// Add a listener for key changes
        /// </summary>
        /// <param name="Key">The key to listen for</param>
        /// <param name="Handler"><see cref="IKeyHandler"/> used to receive key changes</param>
        public static void ListenForKey(Keys Key, IKeyHandler Handler)
        {
            HashSet <IKeyHandler> Handlers;

            if (!_KeyHandlers.TryGetValue(Key, out Handlers))
            {
                Handlers = new HashSet <IKeyHandler>();
                if (!_KeyHandlers.TryAdd(Key, Handlers))
                {
                    ListenForKey(Key, Handler);
                    return;
                }
            }
            Handlers.Add(Handler);
        }
        /// <summary>
        /// Reads a line of text from the console.  Any interactions you've configured before calling this method will be in effect.
        /// </summary>
        /// <param name="initialBuffer">Optionally seed the prompt with an initial value that the end user can modify</param>
        /// <returns>a line of text from the console</returns>
        public ConsoleString ReadLine(ConsoleString initialBuffer = null)
        {
            RichCommandLineContext context = new RichCommandLineContext(this.HistoryManager);

            context.Console          = this.Console;
            context.ConsoleStartTop  = this.Console.CursorTop;
            context.ConsoleStartLeft = this.Console.CursorLeft;

            if (initialBuffer != null)
            {
                context.ReplaceConsole(initialBuffer);
            }

            while (true)
            {
                context.Reset();
                context.KeyPressed       = this.Console.ReadKey(true);
                context.CharacterToWrite = new ConsoleCharacter(context.KeyPressed.KeyChar);
                context.BufferPosition   = this.Console.CursorLeft - context.ConsoleStartLeft + (this.Console.CursorTop - context.ConsoleStartTop) * this.Console.BufferWidth;

                IKeyHandler handler = null;

                if (KeyHandlers.TryGetValue(context.KeyPressed.Key, out handler) == false && context.CharacterToWrite.Value != '\u0000')
                {
                    context.WriteCharacterForPressedKey();
                    DoSyntaxHighlighting(context);
                }
                else if (handler != null)
                {
                    handler.Handle(context);

                    if (context.Intercept == false && context.CharacterToWrite.Value != '\u0000')
                    {
                        this.Console.Write(context.CharacterToWrite);
                    }

                    DoSyntaxHighlighting(context);

                    if (context.IsFinished)
                    {
                        this.Console.WriteLine();
                        break;
                    }
                }
            }

            return(new ConsoleString(context.Buffer));
        }
Exemple #29
0
 public void UpdateSettings(TacticalCameraSettings tacticalCameraSettings)
 {
     DisableTacticalCamera();
     DisposeHandlers();
     _tacticalCameraSettings = tacticalCameraSettings;
     _keyHandler             = _tacticalCameraKeyHandlerFactory.CreateTacticalCameraKeyHandler(_gameValueService, _tacticalCameraSettings, _gameProcess);
     EnableTacticalCameraTriggers();
     if (tacticalCameraSettings.UnlimitedZoomEnabled)
     {
         _gameValueService.EnableUnlimitedZoom();
     }
     else
     {
         _gameValueService.DisableUnlimitedZoom();
     }
 }
Exemple #30
0
        private void KpsButton_Click(object sender, EventArgs e)
        {
            DialogPositioner.From(FindForm(), PointToScreen(new Point(Width / 2, Height / 2)));
            IKeyHandler newHandler = frmGetKey.ShowDialogAndGetKeyHandler(color, key, label.Text);

            if (newHandler == null)
            {
                return;
            }
            keyhandler = newHandler;
            key        = frmGetKey.yourkey();      //get my key id
            frmGetKey.UpdateLabel(label);
            if (settingChangedEvent != null)
            {
                settingChangedEvent(null, null);
            }
        }
Exemple #31
0
        public CameraBasedPanTiltRunner(
            IPanTiltMechanism panTiltMech
            , ICaptureGrab captureGrabber
            , IController <CameraPanTiltProcessOutput> controller
            , IScreen screen)
            : base(panTiltMech)
        {
            _controller = controller;

            Screen = screen;

            FpsTracker = new FpsTracker();
            FpsTracker.ReportEveryNthFrame = 2;
            FpsTracker.ReportFrames        = s => Screen.WriteLine(s);

            UpdateCaptureGrabber(captureGrabber);

            _keyHandler = controller as IKeyHandler;
        }
        public CameraBasedPanTiltRunner(
            IPanTiltMechanism panTiltMech
            , ICaptureGrab captureGrabber
            , IController<CameraPanTiltProcessOutput> controller
            , IScreen screen)
            : base(panTiltMech)
        {
            _controller = controller;

            Screen = screen;

            FpsTracker = new FpsTracker();
            FpsTracker.ReportEveryNthFrame = 2;
            FpsTracker.ReportFrames = s => Screen.WriteLine(s);

            UpdateCaptureGrabber(captureGrabber);

            _keyHandler = controller as IKeyHandler;
        }
Exemple #33
0
        internal QueryEditSession(IPreviousNextStack <string> alreadyEditedQueries)
        {
            Debug.Assert(alreadyEditedQueries != null);

            Console.CancelKeyPress += this.On_Ctrl_C_Pressed;

            m_AlreadyEditedQueries = alreadyEditedQueries;

            m_ConsoleWriter = new ConsoleWriter();

            m_UndoRedoStates = new PreviousNextStack <State>(
                new State[] {},
                State.DefaultState,
                (s1, s2) => !s1.IsDifferentThan(s2));

            m_KeyHandlers = new IKeyHandler[] {
                // Order of keyHandlers declaration matters!
                new KeyHandlerCtrl(m_UndoRedoStates),
                new KeyHandlerCursor(ConsoleWriter.AvailableWidth),
                new KeyHandlerChar(ConsoleWriter.AvailableWidth)
            };
        }
Exemple #34
0
 private void KpsButton_Click(object sender, EventArgs e)
 {
     if (!isAddbutton)
     {
         Point       pt         = PointToScreen(new Point(Width / 2, Height / 2 - 150));
         IKeyHandler newHandler = frmGetKey.ShowDialogAndGetKeyHandler(color, key, label.Text, pt);
         if (newHandler == null)
         {
             return;
         }
         Handler = newHandler;
         key     = frmGetKey.yourkey(); //get my key id
         frmGetKey.UpdateLabel(label);
         if (settingChangedEvent != null)
         {
             settingChangedEvent(null, null);
         }
     }
     else
     {
         frm.addButton(label);
     }
 }
 public KeyCapture(IKeyHandler keyHandler)
 {
     _keyHandler = keyHandler;
     _proc = HookCallback;
     HookKeys();
 }
 /// <summary>
 /// Unregisters the given key handler from the reader.  You should only do this if you're planning on overriding the default handlers, and you should do so
 /// with caution.
 /// </summary>
 /// <param name="handler">The handler to unregister</param>
 public void UnregisterHandler(IKeyHandler handler)
 {
     foreach(var key in handler.KeysHandled)
     {
         KeyHandlers.Remove(key);
     }
 }
 /// <summary>
 /// Lets you register a custom key handler. You are responsible for ensuring that each key is only handled by one handler.  This method will throw if
 /// you try to add a duplicate key handler.
 /// </summary>
 /// <param name="handler">The handler to register</param>
 public void RegisterHandler(IKeyHandler handler)
 {
     foreach(var key in handler.KeysHandled)
     {
         KeyHandlers.Add(key, handler);
     }
 }
Exemple #38
0
 /// <summary>
 /// Create a new State to event transformer (possibly only for mainwindow)
 /// </summary>
 /// <param name="parent"></param>
 public StateToEvent(IKeyHandler parent)
 {
     _parent = parent;
     _pressed = Keyboard.GetState().GetPressedKeys();
     _leftButton = (Mouse.GetState().LeftButton == ButtonState.Pressed);
     _middleButton = (Mouse.GetState().MiddleButton == ButtonState.Pressed);
     _rightButton = (Mouse.GetState().RightButton == ButtonState.Pressed);
     _working = false;
 }