Esempio n. 1
0
        /// <summary>
        /// Creates a binding for the supplied Mouse Button.  The callback will call beginHandler on MouseDown and endHandler on MouseUp
        /// </summary>
        /// <param name="name">The name of the binding</param>
        /// <param name="buttons">The Mouse Button to attach the binding to</param>
        /// <param name="beginHandler">The handler to execute when the binding's mouse button is pressed down</param>
        /// <param name="endHandler">The handler to execute when the binding's mouse button is pressed release</param>
        /// <returns>The InputBinding object.</returns>
        public InputBinding AddBinding(string name, MouseButton buttons, EventHandler beginHandler, EventHandler endHandler)
        {
            InputBinding binding = new InputBinding(name, false, false, false);

            binding.BeginExecution = beginHandler;
            binding.EndExecution = endHandler;

            _mouseBindings.Add(buttons, binding);

            return binding;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates and adds a binding to the InputState for the supplied Keyboard Key and Modifier Keys.
        /// </summary>
        /// <param name="name">The name of the binding</param>
        /// <param name="shift">Binding requires shift button in order to execute</param>
        /// <param name="control">Binding requires control button in order to execute</param>
        /// <param name="alt">Binding requires alt button in order to execute</param>
        /// <param name="key">The Key to bind to.</param>
        /// <param name="beginHandler">The handler to execute when the binding's key combination is pressed down</param>
        /// <param name="endHandler">The handler to execute when the binding's key combination button is pressed release</param>
        /// <returns>The InputBinding object.</returns>
        public InputBinding AddBinding(string name, bool shift, bool control, bool alt, WinKeys key, EventHandler beginHandler, EventHandler endHandler)
        {
            InputBinding binding = new InputBinding(name, shift, control, alt);

            binding.BeginExecution = beginHandler;
            binding.EndExecution = endHandler;

            key |= shift ? WinKeys.Shift : WinKeys.None;
            key |= control ? WinKeys.Control : WinKeys.None;
            key |= alt ? WinKeys.Alt : WinKeys.None;

            _keyBindings.Add(key, binding);

            return binding;
        }