Beispiel #1
0
        public static bool TryParse(string binding, out KeyBinding keyBinding)
        {
            keyBinding = default(KeyBinding);
            var scopeEnd = binding.IndexOf(':');
            if (scopeEnd < 0)
            {
                return false;
            }

            // Num key binding not supported at this time
            if (binding.IndexOf("Num") >= 0)
            {
                return false;
            }

            var scope = binding.Substring(0, scopeEnd);
            var rest = binding.Substring(scopeEnd + 2);
            var entries = rest
                .Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries)
                .Select(x => ParseOne(x));
            if (entries.Any(x => x == null))
            {
                return false;
            }

            keyBinding = new KeyBinding(scope, entries);
            return true;
        }
Beispiel #2
0
 public KeyBinding(KeyBinding otherBinding, params Key[] keys) :
     this(otherBinding.DisplayIndex, keys) {
     UID = otherBinding.UID;
     ExecuteOnKeyDown = otherBinding.ExecuteOnKeyDown;
     ExecuteOnKeyUp = otherBinding.ExecuteOnKeyUp;
     RepeatOnKeyDown = otherBinding.RepeatOnKeyDown;
 }
        public void EqualsTest()
        {
            var x = new KeyBinding(Command.Action0, Keys.A, true, false, true);
            var y = new KeyBinding(Command.Action0, Keys.A, true, false, true);
            var z = new KeyBinding(Command.Action0, Keys.A, true, false, true);

            // 反射律
            Assert.True(x.Equals(x));

            // 対象律
            Assert.True(x.Equals(y));
            Assert.True(y.Equals(x));

            // 推移律
            Assert.True(y.Equals(z));
            Assert.True(z.Equals(x));

            Assert.False(x.Equals(null));
            Assert.False(x.Equals(new object()));

            Assert.AreEqual(x.GetHashCode(), y.GetHashCode());
            Assert.AreEqual(y.GetHashCode(), z.GetHashCode());
            Assert.AreEqual(z.GetHashCode(), x.GetHashCode());

            // 等しくないデータ同士を比較
            var zz = new KeyBinding(Command.Action0, Keys.B, true, false, true);
            Assert.False(zz.Equals(x));
            Assert.AreNotEqual(zz.GetHashCode(), x.GetHashCode());
        }
    void aquireBinding()
    {
        KeyBindings allBindings = player.GetComponent <KeyBindings> ();

        BindingAction action = player.GetComponent <KeyBindings> ().getBindingAction (bindingActionName);

        //Debug.Log ("Binding action:" + action.ToString());

        KeyBinding keyBinding = new KeyBinding (bindingId, action);
        keyBinding.setIsContinuous (isContinuous);

        foreach (KeyCode keyCode in requiredDownKeys)
        {
            keyBinding.addKeyDown (keyCode);
        }

        keyBinding.m_funnyText = bindgingDescription;

        //discardKeyBinding
        allBindings.aquireKeyBinding (keyBinding);

        // Redraw keybindings.
        inventory.clearAllKeyBindings ();
        inventory.drawAllKeybindings ();

        gameObject.SetActive (false);
    }
 public void ConstructionTest()
 {
     var binding = new KeyBinding(Command.Action1, Keys.Return, false, true, false);
     Assert.AreEqual(Command.Action1, binding.Command);
     Assert.AreEqual(Keys.Return, binding.KeyCode);
     Assert.False(binding.Alt);
     Assert.True(binding.Control);
     Assert.False(binding.Shift);
     Assert.AreEqual(Keys.Return | Keys.Control, binding.KeyData);
 }
        public static void Setup()
        {
            TRANSLATE_UP    = new KeyBinding (GameSettings.TRANSLATE_UP.primary);
            TRANSLATE_DOWN  = new KeyBinding (GameSettings.TRANSLATE_DOWN.primary);
            TRANSLATE_BACK  = new KeyBinding (GameSettings.TRANSLATE_BACK.primary);
            TRANSLATE_FWD   = new KeyBinding (GameSettings.TRANSLATE_FWD.primary);
            TRANSLATE_RIGHT = new KeyBinding (GameSettings.TRANSLATE_RIGHT.primary);
            TRANSLATE_LEFT  = new KeyBinding (GameSettings.TRANSLATE_LEFT.primary);

            PLUGIN_TOGGLE = new KeyBinding (Parse (Settings.GetValue ("shortcut_key", KeyCode.Alpha5.ToString ())));
        }
        public GameSettingsManipulator()
        {
            _pitchUp                    = GameSettings.PITCH_UP;
            _pitchDown                  = GameSettings.PITCH_DOWN;
            _pitchAxisPrimaryInverted   = GameSettings.AXIS_PITCH.primary.inverted;
            _pitchAxisSecondaryInverted = GameSettings.AXIS_PITCH.secondary.inverted;

            _rollLeft    = GameSettings.ROLL_LEFT;
            _rollRight   = GameSettings.ROLL_RIGHT;
            _rollAxis    = GameSettings.AXIS_ROLL;

            _yawLeft     = GameSettings.YAW_LEFT;
            _yawRight    = GameSettings.YAW_RIGHT;
            _yawAxis     = GameSettings.AXIS_YAW;
        }
    // Use this for initialization
    void Start()
    {
        player = GameObject.Find ("Player");
        cameraObj = GameObject.Find ("Main Camera");

        player.GetComponent <KeyBindings> ().registerBindingAction ("openDoor", this);

        // Setup default keybinding.
        KeyBinding binding = new KeyBinding ("open", this);
        binding.m_funnyText = "Actuate door-handle of the ordinary variety.";
        binding.addKeyDown (KeyCode.LeftControl);
        binding.addKeyDown (KeyCode.LeftBracket);

        player.GetComponent <KeyBindings> ().aquireKeyBinding (binding);
    }
 public ScreenManager()
 {
     Window = new RenderWindow(new VideoMode(800, 600, 32), "",Styles.Resize);
     keybinds = new KeyBinding();
     Window.KeyPressed += new EventHandler<KeyEventArgs>(InputSystem_KeyDown);
     Window.KeyReleased += new EventHandler<KeyEventArgs>(InputSystem_KeyUp);
     Window.TextEntered += new EventHandler<TextEventArgs>(InputSystem_CharEntered);
     Window.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(InputSystem_MouseDown);
     Window.MouseButtonReleased += new EventHandler<MouseButtonEventArgs>(InputSystem_MouseUp);
     Window.MouseMoved += new EventHandler<MouseMoveEventArgs>(InputSystem_MouseMove);
     Window.MouseWheelMoved += new EventHandler<MouseWheelEventArgs>(InputSystem_MouseWheel);
     AddScreen(new UserInterface.Screens.MainMenuScreen());
     Window.SetFramerateLimit(60);
     while (Window.IsOpen())
     {
         GameLoop();
     }
 }
        public KeyBindingViewModel(KeyBinding binding, Action<KeyBinding, KeyBinding> bindingChangedCallback, Action<KeyBindingViewModel> deleteBindingCallback)
        {
            _currentBinding = binding;
            _bindingChangedCallback = bindingChangedCallback;
            KeyPressHandler = new KeyPressHandler(
                KeyPressed,
                keyDownCanExecute: x => IsEditingBinding.Value,
                keyUpCanExecute: x => IsEditingBinding.Value
            );
            Keys = new NotifyingProperty<HashSet<Key>>(_currentBinding.Keys);
            PathOrLiteral = new NotifyingProperty<string>(x => CommitChanges(), (binding as LuaKeyBinding)?.PathOrLiteral);
            ExecuteOnKeyUp = new NotifyingProperty<bool>(
                x => {
                    if(IsEditingBinding.Value) EndEditBinding();
                    else CommitChanges();
                },
                _currentBinding.ExecuteOnKeyUp
            );
            ExecuteOnKeyDown = new NotifyingProperty<bool>(
                x => {
                    if(!x) RepeatOnKeyDown.Value = x;
                    else if(IsEditingBinding.Value) EndEditBinding();
                    else CommitChanges();
                },
                _currentBinding.ExecuteOnKeyDown
            );
            RepeatOnKeyDown = new NotifyingProperty<bool>(
                x => {
                    if (x) ExecuteOnKeyDown.Value = x;
                    else if(IsEditingBinding.Value) EndEditBinding();
                    else CommitChanges();
                },
                _currentBinding.RepeatOnKeyDown
            );
            IsEditingBinding = new NotifyingProperty<bool>();
            StartEditingCommand = new RelayCommand(x => StartEditBinding());
            EndEditingCommand = new RelayCommand(x => EndEditBinding());
            if (deleteBindingCallback != null) DeleteBindingCommand = new RelayCommand(x => deleteBindingCallback(this));

            PathOrLiteralGotFocusCommand = new RelayCommand(x => PathOrLiteralIsFocused.Value = true);
            PathOrLiteralLostFocusCommand = new RelayCommand(x => PathOrLiteralIsFocused.Value = false);
            DragDrop = new DragAndDropHandler(AllowDrop, Drop);
            LostKeyboardFocusCommand = new RelayCommand(x => KeyPressHandler.ClearPressedKeys());
        }
    // Use this for initialization
    public void rebindLeft()
    {
        foreach (KeyBinding binding in GetComponent <KeyBindings> ().m_keyBindings)
        {
            if(binding.m_bindingName == "left")
            {
                GetComponent <KeyBindings> ().discardKeyBinding (binding);
            }
        }

        if (Event.current.type == EventType.KeyDown)
        {
            KeyCode newBinding = Event.current.keyCode;
            KeyBinding binding = new KeyBinding ("left", GetComponent <Movement> ());
            binding.setIsContinuous (true);
            binding.addKeyDown (newBinding);
            GetComponent <KeyBindings> ().aquireKeyBinding (binding);
        }
    }
    // Use this for initialization
    void Start()
    {
        player = GameObject.Find ("Player");

        distToGround = GetComponent <Collider> ().bounds.extents.y;

        player.GetComponent <KeyBindings> ().registerBindingAction ("jump", this);

        // Setup default keybindings
        KeyBinding binding = new KeyBinding ("low_jump", this);
        binding.m_funnyText = "Perform a feeble excuse for 'jump'.";
        binding.addKeyDown (KeyCode.Space);
        GetComponent <KeyBindings> ().aquireKeyBinding (binding);

        binding = new KeyBinding ("high_jump", this);
        binding.m_funnyText = "Perferm a right proper jump.";
        binding.addKeyDown (KeyCode.Space);
        binding.addKeyDown (KeyCode.LeftControl);
        GetComponent <KeyBindings> ().aquireKeyBinding (binding);
    }
Beispiel #13
0
 private Config(
     KeyBinding toggleControlMode,
     KeyBinding holdControlMode,
     bool pitchInvert,
     bool enableAppLauncherButton,
     ControlMode defaultControlMode,
     ControlMode defaultVabControlMode,
     ControlMode defaultSphControlMode,
     LogLevel logLevel
     )
 {
     ToggleControlMode = toggleControlMode;
     HoldControlMode = holdControlMode;
     PitchInvert = pitchInvert;
     EnableAppLauncherButton = enableAppLauncherButton;
     DefaultControlMode = defaultControlMode;
     DefaultVabControlMode = defaultVabControlMode;
     DefaultSphControlMode = defaultSphControlMode;
     LogLevel = logLevel;
 }
 public void aquireKeyBinding(KeyBinding binding)
 {
     // Only add this binding if it has not already been added.
     //		foreach (KeyBinding bind in m_keyBindings)
     //		{
     //			if (bind.m_bindingName == binding.m_bindingName)
     //			{
     //				Debug.Log ("discarding binding: " + binding.m_bindingName);
     //
     //				return;
     ////				if (bind != binding)
     ////				{
     ////					discardKeyBinding (bind);
     ////				}
     ////				//m_keyBindings.Remove (bind);
     ////				break;
     //			}
     //		}
     Debug.Log ("aquiring binding: " + binding.m_bindingName + "With num bindings: " + binding.requiredKeysDown.Count);
     m_keyBindings.Add (binding);
 }
Beispiel #15
0
        /// <summary>
        /// Called when the program switches to the screen. This is
        /// where screen assets are loaded and resources are created.
        /// </summary>
        public override void LoadContent()
        {
            InputDevice input = Platform.Instance.InputDevice;
            input.MouseState.Visible = true;

            Font font = BaseGameProgram.Instance.ContentDatabase.Load<Font>("Segoe_UI_10_Regular");
            FontManager.DefaultFont = Engine.Instance.Renderer.CreateFont(font);
            Viewport viewport = Platform.Instance.GraphicsDevice.Viewport;

            basicUI = new BasicUI(viewport.Width, viewport.Height);
            debug = new DebugViewModel(basicUI);
            basicUI.DataContext = new BasicUIViewModel();

            FontManager.Instance.LoadFonts(BaseGameProgram.Instance.ContentDatabase);
            ImageManager.Instance.LoadImages(BaseGameProgram.Instance.ContentDatabase);
            SoundManager.Instance.LoadSounds(BaseGameProgram.Instance.ContentDatabase);

            RelayCommand command = new RelayCommand(new Action<object>(ExitEvent));

            KeyBinding keyBinding = new KeyBinding(command, KeyCode.Escape, ModifierKeys.None);
            basicUI.InputBindings.Add(keyBinding);
        }
Beispiel #16
0
        private void Lock()
        {
            if (isLocked) return;

            isLocked = true;
            ShowCursor = true;
            BringToFront();

            cameraManager = CameraManager.Instance;
            cameraManager.enabled = false;

            // Exclude the TARGETING ControlType so that we can set the target vessel with the terminal open.
            InputLockManager.SetControlLock(ControlTypes.All & ~ControlTypes.TARGETING, CONTROL_LOCKOUT);

            // Prevent editor keys from being pressed while typing
            EditorLogic editor = EditorLogic.fetch;
                //TODO: POST 0.90 REVIEW
            if (editor != null && InputLockManager.IsUnlocked(ControlTypes.All)) editor.Lock(true, true, true, CONTROL_LOCKOUT);

            // This seems to be the only way to force KSP to let me lock out the "X" throttle
            // key.  It seems to entirely bypass the logic of every other keypress in the game,
            // so the only way to fix it is to use the keybindings system from the Setup screen.
            // When the terminal is focused, the THROTTLE_CUTOFF action gets unbound, and then
            // when its unfocused later, its put back the way it was:
            rememberThrottleCutoffKey = GameSettings.THROTTLE_CUTOFF;
            GameSettings.THROTTLE_CUTOFF = new KeyBinding(KeyCode.None);
            rememberThrottleFullKey = GameSettings.THROTTLE_FULL;
            GameSettings.THROTTLE_FULL = new KeyBinding(KeyCode.None);
        }
Beispiel #17
0
 public void BadParse2()
 {
     Assert.Throws <ArgumentException>(() => KeyBinding.Parse("::ctrl+notavalidkey"));
 }
Beispiel #18
0
 private void BindHotkey()
 {
     foreach (var child in Toolbar.Children)
     {
         if (child.GetType() == typeof(RibbonButton))
         {
             RibbonButton tlb         = (RibbonButton)child;
             KeyBinding   key         = new KeyBinding();
             string       strTinhNang = tlb.Name.Substring(3, tlb.Name.Length - 3);
             if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.THEM)))
             {
                 KeyGesture keyg = new KeyGesture(Key.N, ModifierKeys.Control);
                 key         = new KeyBinding(AddCommand, keyg);
                 key.Gesture = keyg;
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.SUA)))
             {
                 KeyGesture keyg = new KeyGesture(Key.M, ModifierKeys.Control);
                 key         = new KeyBinding(ModifyCommand, keyg);
                 key.Gesture = keyg;
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.XOA)))
             {
                 KeyGesture keyg = new KeyGesture(Key.Delete, ModifierKeys.Shift);
                 key         = new KeyBinding(DeleteCommand, keyg);
                 key.Gesture = keyg;
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.DUYET)))
             {
                 KeyGesture keyg = new KeyGesture(Key.A, ModifierKeys.Control | ModifierKeys.Shift);
                 key         = new KeyBinding(ApproveCommand, keyg);
                 key.Gesture = keyg;
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TU_CHOI_DUYET)))
             {
                 KeyGesture keyg = new KeyGesture(Key.R, ModifierKeys.Control | ModifierKeys.Shift);
                 key         = new KeyBinding(RefuseCommand, keyg);
                 key.Gesture = keyg;
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.THOAI_DUYET)))
             {
                 KeyGesture keyg = new KeyGesture(Key.C, ModifierKeys.Control | ModifierKeys.Shift);
                 key         = new KeyBinding(CancelCommand, keyg);
                 key.Gesture = keyg;
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.XEM)))
             {
                 KeyGesture keyg = new KeyGesture(Key.W, ModifierKeys.Control);
                 key         = new KeyBinding(ViewCommand, keyg);
                 key.Gesture = keyg;
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TIM_KIEM)))
             {
                 KeyGesture keyg = new KeyGesture(Key.F, ModifierKeys.Control);
                 key         = new KeyBinding(SearchCommand, keyg);
                 key.Gesture = keyg;
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.LAY_LAI)))
             {
                 KeyGesture keyg = new KeyGesture(Key.F5, ModifierKeys.None);
                 key         = new KeyBinding(ReloadCommand, keyg);
                 key.Gesture = keyg;
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.XUAT_DU_LIEU)))
             {
                 KeyGesture keyg = new KeyGesture(Key.E, ModifierKeys.Control | ModifierKeys.Shift);
                 key         = new KeyBinding(ExportCommand, keyg);
                 key.Gesture = keyg;
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TRO_GIUP)))
             {
                 KeyGesture keyg = new KeyGesture(Key.F1, ModifierKeys.None);
                 key         = new KeyBinding(HelpCommand, keyg);
                 key.Gesture = keyg;
             }
             if (key != null)
             {
                 InputBindings.Add(key);
             }
         }
     }
 }
 public Key GetDefault( KeyBinding key )
 {
     return defaultKeys[(int)key];
 }
Beispiel #20
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="summonTractor">The keys which summon the tractor.</param>
 /// <param name="dismissTractor">The keys which return the tractor to its home.</param>
 /// <param name="holdToActivate">The keys which activate the tractor when held, or none to activate automatically.</param>
 public ModConfigKeys(KeyBinding summonTractor, KeyBinding dismissTractor, KeyBinding holdToActivate)
 {
     this.SummonTractor  = summonTractor;
     this.DismissTractor = dismissTractor;
     this.HoldToActivate = holdToActivate;
 }
        /// <summary>
        /// Dang ky hot key, shortcut key
        /// </summary>
        #region Dang ky hot key, shortcut key
        /// <summary>
        /// Binding HotKey
        /// </summary>
        private void BindHotkey()
        {
            foreach (var child in Toolbar.Children)
            {
                if (child.GetType() == typeof(RibbonButton))
                {
                    RibbonButton tlb         = (RibbonButton)child;
                    KeyBinding   key         = new KeyBinding();
                    string       strTinhNang = tlb.Name.Substring(3, tlb.Name.Length - 3);
                    if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.NHAP_DU_LIEU)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.I, ModifierKeys.Control);
                        key         = new KeyBinding(ImportCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.SUA)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.M, ModifierKeys.Control);
                        key         = new KeyBinding(ModifyCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.XOA)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.Delete, ModifierKeys.Shift);
                        key         = new KeyBinding(DeleteCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.NHAN_BAN)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.V, ModifierKeys.Control | ModifierKeys.Shift);
                        key         = new KeyBinding(CloneCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.LUU_TAM)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.H, ModifierKeys.Control);
                        key         = new KeyBinding(HoldCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.LUU)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.S, ModifierKeys.Control);
                        key         = new KeyBinding(SubmitCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.BANG_KE)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Shift);
                        key         = new KeyBinding(CashStmtCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.DUYET)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.A, ModifierKeys.Control | ModifierKeys.Shift);
                        key         = new KeyBinding(ApproveCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TU_CHOI_DUYET)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.R, ModifierKeys.Control | ModifierKeys.Shift);
                        key         = new KeyBinding(RefuseCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.THOAI_DUYET)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.C, ModifierKeys.Control | ModifierKeys.Shift);
                        key         = new KeyBinding(CancelCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.XEM_TRUOC)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.W, ModifierKeys.Control | ModifierKeys.Shift);
                        key         = new KeyBinding(PreviewCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.XEM)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.W, ModifierKeys.Control);
                        key         = new KeyBinding(ViewCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.XUAT_DU_LIEU)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.E, ModifierKeys.Shift);
                        key         = new KeyBinding(ExportCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TIM_KIEM)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.F, ModifierKeys.Control | ModifierKeys.Shift);
                        key         = new KeyBinding(SearchCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TRO_GIUP)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.F1, ModifierKeys.None);
                        key         = new KeyBinding(HelpCommand, keyg);
                        key.Gesture = keyg;
                    }
                    else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.DONG)))
                    {
                        KeyGesture keyg = new KeyGesture(Key.Escape, ModifierKeys.None);
                        key         = new KeyBinding(CloseCommand, keyg);
                        key.Gesture = keyg;
                    }

                    InputBindings.Add(key);
                }
            }
        }
Beispiel #22
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Load and assign saved hotkeys
            var    keyBind = new KeyBinding();
            string setting;
            bool   gotHotkeyException = false;

            // Very crappy check for every hotkey
            // TODO: refactor and add friendly exception handling
            try
            {
                setting = Settings.Default.Hotkey_CaptureArea;
                if (setting != null && setting != string.Empty)
                {
                    keyBind.FromString(setting);
                    HotkeyManager.Current.AddOrReplace("CaptureArea", keyBind.Key, keyBind.ModifierKeys, PublishDesktopHotkey);
                }
            }
            catch (NHotkey.HotkeyAlreadyRegisteredException exception)
            {
                HotkeyManager.Current.Remove(exception.Name);
                gotHotkeyException = true;
            }

            try
            {
                setting = Settings.Default.Hotkey_PublishClip;
                if (setting != null && setting != string.Empty)
                {
                    keyBind.FromString(setting);
                    HotkeyManager.Current.AddOrReplace("PublishClip", keyBind.Key, keyBind.ModifierKeys, PublishClipHotkey);
                }
            }
            catch (NHotkey.HotkeyAlreadyRegisteredException exception)
            {
                HotkeyManager.Current.Remove(exception.Name);
                gotHotkeyException = true;
            }

            try
            {
                setting = Settings.Default.Hotkey_PublishFile;
                if (setting != null && setting != string.Empty)
                {
                    keyBind.FromString(setting);
                    HotkeyManager.Current.AddOrReplace("PublishFile", keyBind.Key, keyBind.ModifierKeys, PublishClipHotkey);
                }
            }
            catch (NHotkey.HotkeyAlreadyRegisteredException exception)
            {
                HotkeyManager.Current.Remove(exception.Name);
                gotHotkeyException = true;
            }

            // Prompt message box to alert about hotkeys
            if (gotHotkeyException)
            {
                if (MessageBox.Show("Some of the hotkeys are disabled because they are already registered somewhere else. Do you want to change them now? ('Yes' opens Settings window)",
                                    "Hotkey already registered.",
                                    MessageBoxButton.YesNo,
                                    MessageBoxImage.Error,
                                    MessageBoxResult.Yes) == MessageBoxResult.Yes)
                {
                    new SettingsWindow();
                }
            }

            // Suggest user to log in
            if (Settings.Default.Username == string.Empty)
            {
                if (MessageBox.Show("To upload something you'll need to log in from installed app (Tray Icon -> Settings). Would you like to do it now?",
                                    "Don't forget to log in!",
                                    MessageBoxButton.YesNo,
                                    MessageBoxImage.Information,
                                    MessageBoxResult.Yes) == MessageBoxResult.Yes)
                {
                    new SettingsWindow();
                }
            }
        }
Beispiel #23
0
        //</SnippetCommandingOverviewCommandDefinition>


        public Window1()
        {
            InitializeComponent();

            //<SnippetCommandingOverviewKeyBinding>
            KeyGesture OpenKeyGesture = new KeyGesture(
                Key.B,
                ModifierKeys.Control);

            KeyBinding OpenCmdKeybinding = new KeyBinding(
                ApplicationCommands.Open,
                OpenKeyGesture);

            this.InputBindings.Add(OpenCmdKeybinding);
            //</SnippetCommandingOverviewKeyBinding>

            //<SnippetCommandingOverviewKeyGestureOnCmd>
            KeyGesture OpenCmdKeyGesture = new KeyGesture(
                Key.B,
                ModifierKeys.Control);

            ApplicationCommands.Open.InputGestures.Add(OpenCmdKeyGesture);
            //</SnippetCommandingOverviewKeyGestureOnCmd>

            //<SnippetCommandingOverviewCommandTargetCodeBehind>
            // Creating the UI objects
            StackPanel mainStackPanel = new StackPanel();
            TextBox    pasteTextBox   = new TextBox();
            Menu       stackPanelMenu = new Menu();
            MenuItem   pasteMenuItem  = new MenuItem();

            // Adding objects to the panel and the menu
            stackPanelMenu.Items.Add(pasteMenuItem);
            mainStackPanel.Children.Add(stackPanelMenu);
            mainStackPanel.Children.Add(pasteTextBox);

            // Setting the command to the Paste command
            pasteMenuItem.Command = ApplicationCommands.Paste;

            // Setting the command target to the TextBox
            pasteMenuItem.CommandTarget = pasteTextBox;
            //</SnippetCommandingOverviewCommandTargetCodeBehind>

            //<SnippetCommandingOverviewCustomCommandSourceCodeBehind>
            // create the ui
            StackPanel CustomCommandStackPanel = new StackPanel();
            Button     CustomCommandButton     = new Button();

            CustomCommandStackPanel.Children.Add(CustomCommandButton);

            CustomCommandButton.Command = CustomRoutedCommand;
            //</SnippetCommandingOverviewCustomCommandSourceCodeBehind>

            //<SnippetCommandingOverviewCustomCommandBindingCodeBehind>
            CommandBinding customCommandBinding = new CommandBinding(
                CustomRoutedCommand, ExecutedCustomCommand, CanExecuteCustomCommand);

            // attach CommandBinding to root window
            this.CommandBindings.Add(customCommandBinding);
            //</SnippetCommandingOverviewCustomCommandBindingCodeBehind>

            sp.Children.Add(mainStackPanel);
            pasteTextBox.Background = Brushes.Bisque;

            sp.Children.Add(CustomCommandStackPanel);

            //<SnippetCommandingOverviewCmdSource>
            StackPanel  cmdSourcePanel       = new StackPanel();
            ContextMenu cmdSourceContextMenu = new ContextMenu();
            MenuItem    cmdSourceMenuItem    = new MenuItem();

            // Add ContextMenu to the StackPanel.
            cmdSourcePanel.ContextMenu = cmdSourceContextMenu;
            cmdSourcePanel.ContextMenu.Items.Add(cmdSourceMenuItem);

            // Associate Command with MenuItem.
            cmdSourceMenuItem.Command = ApplicationCommands.Properties;
            //</SnippetCommandingOverviewCmdSource>

            cmdSourcePanel.Background = Brushes.Black;
            cmdSourcePanel.Height     = 100;
            cmdSourcePanel.Width      = 100;
            mainStackPanel.Children.Add(cmdSourcePanel);
        }
Beispiel #24
0
        public void VsNum1()
        {
            var b = KeyBinding.Parse("::Num +");

            Assert.Equal(VimKey.KeypadPlus, b.FirstKeyStroke.Key);
        }
Beispiel #25
0
        public void VsNum2()
        {
            var b = KeyBinding.Parse("::Num *");

            Assert.Equal(VimKey.KeypadMultiply, b.FirstKeyStroke.Key);
        }
Beispiel #26
0
        public void VsKeyPageUp()
        {
            var b = KeyBinding.Parse("::PgUp");

            Assert.Equal(VimKey.PageUp, b.FirstKeyStroke.Key);
        }
Beispiel #27
0
        public void VsKeyPageDown()
        {
            var b = KeyBinding.Parse("::PgDn");

            Assert.Equal(VimKey.PageDown, b.FirstKeyStroke.Key);
        }
Beispiel #28
0
        public void VsKeyDownArrow2()
        {
            var b = KeyBinding.Parse("::Shift+Down Arrow");

            Assert.Equal(VimKey.Down, b.FirstKeyStroke.Key);
        }
Beispiel #29
0
        public void VsKeyUpArrow()
        {
            var b = KeyBinding.Parse("::Up Arrow");

            Assert.Equal(VimKey.Up, b.FirstKeyStroke.Key);
        }
Beispiel #30
0
        // </SnippetKeyGestureGetProperties>

        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            // <SnippetKeyBindingKeyGestureSetProperties>
            // Defining the KeyGesture.
            KeyGesture FindCmdKeyGesture = new KeyGesture(Key.F,
                                                          (ModifierKeys.Shift | ModifierKeys.Alt));

            // Defining the KeyBinding.
            KeyBinding FindKeyBinding = new KeyBinding(
                ApplicationCommands.Find, FindCmdKeyGesture);

            // Binding the KeyBinding to the Root Window.
            this.InputBindings.Add(FindKeyBinding);
            // </SnippetKeyBindingKeyGestureSetProperties>

            // <SnippetKeyBindingWithNoModifier>
            KeyGesture OpenCmdKeyGesture = new KeyGesture(Key.F12);
            KeyBinding OpenKeyBinding    = new KeyBinding(
                ApplicationCommands.Open,
                OpenCmdKeyGesture);

            this.InputBindings.Add(OpenKeyBinding);
            // </SnippetKeyBindingWithNoModifier>

            // <SnippetKeyBindingWithKeyAndModifiers>
            KeyGesture CloseCmdKeyGesture = new KeyGesture(
                Key.L, ModifierKeys.Alt);

            KeyBinding CloseKeyBinding = new KeyBinding(
                ApplicationCommands.Close, CloseCmdKeyGesture);

            this.InputBindings.Add(CloseKeyBinding);
            // </SnippetKeyBindingWithKeyAndModifiers>

            // <SnippetKeyBindingMultipleModifiers>
            KeyBinding CopyKeyBinding = new KeyBinding(
                ApplicationCommands.Copy, Key.D,
                (ModifierKeys.Control | ModifierKeys.Shift));

            this.InputBindings.Add(CopyKeyBinding);
            // </SnippetKeyBindingMultipleModifiers>

            // <SnippetKeyBindingDefatulCtor>
            KeyBinding RedoKeyBinding = new KeyBinding();

            RedoKeyBinding.Modifiers = ModifierKeys.Alt;
            RedoKeyBinding.Key       = Key.F;
            RedoKeyBinding.Command   = ApplicationCommands.Redo;

            this.InputBindings.Add(RedoKeyBinding);
            // </SnippetKeyBindingDefatulCtor>

            // <SnippetMouseBindingAddedToInputBinding>
            MouseGesture OpenCmdMouseGesture = new MouseGesture();

            OpenCmdMouseGesture.MouseAction = MouseAction.WheelClick;
            OpenCmdMouseGesture.Modifiers   = ModifierKeys.Control;

            MouseBinding OpenCmdMouseBinding = new MouseBinding();

            OpenCmdMouseBinding.Gesture = OpenCmdMouseGesture;
            OpenCmdMouseBinding.Command = ApplicationCommands.Open;

            this.InputBindings.Add(OpenCmdMouseBinding);
            // </SnippetMouseBindingAddedToInputBinding>

            // <SnippetMouseBindingAddedCommand>
            MouseGesture PasteCmdMouseGesture = new MouseGesture(
                MouseAction.MiddleClick, ModifierKeys.Alt);

            ApplicationCommands.Paste.InputGestures.Add(PasteCmdMouseGesture);
            // </SnippetMouseBindingAddedCommand>

            KeyGesture pasteBind = new KeyGesture(Key.V, ModifierKeys.Alt);

            ApplicationCommands.Paste.InputGestures.Add(pasteBind);

            // <SnippetInputBindingAddingCommand>
            KeyGesture HelpCmdKeyGesture = new KeyGesture(Key.H,
                                                          ModifierKeys.Alt);

            InputBinding inputBinding;

            inputBinding = new InputBinding(ApplicationCommands.Help,
                                            HelpCmdKeyGesture);

            this.InputBindings.Add(inputBinding);
            // </SnippetInputBindingAddingCommand>

            // <SnippetMouseBindingMouseAction>
            MouseGesture CutCmdMouseGesture = new MouseGesture(
                MouseAction.MiddleClick);

            MouseBinding CutMouseBinding = new MouseBinding(
                ApplicationCommands.Cut,
                CutCmdMouseGesture);

            // RootWindow is an instance of Window.
            RootWindow.InputBindings.Add(CutMouseBinding);
            // </SnippetMouseBindingMouseAction>

            // <SnippetMouseBindingGesture>
            MouseGesture NewCmdMouseGesture = new MouseGesture();

            NewCmdMouseGesture.Modifiers   = ModifierKeys.Alt;
            NewCmdMouseGesture.MouseAction = MouseAction.MiddleClick;

            MouseBinding NewMouseBinding = new MouseBinding();

            NewMouseBinding.Command = ApplicationCommands.New;
            NewMouseBinding.Gesture = NewCmdMouseGesture;

            // RootWindow is an instance of Window.
            RootWindow.InputBindings.Add(NewMouseBinding);
            // </SnippetMouseBindingGesture>
        }
Beispiel #31
0
        public void ParseMultiple1()
        {
            var b = KeyBinding.Parse("::e, f");

            Assert.Equal(2, b.KeyStrokes.Count());
        }
Beispiel #32
0
 private void BindShortkey()
 {
     foreach (var child in Toolbar.Children)
     {
         if (child.GetType() == typeof(StackPanel))
         {
             foreach (var subchild in ((StackPanel)child).Children)
             {
                 if (subchild.GetType() == typeof(RibbonButton))
                 {
                     RibbonButton btl = (RibbonButton)subchild;
                     KeyBinding   key = new KeyBinding();
                     if (btl.Name.Equals("tlbAdd"))
                     {
                         KeyGesture keyg = new KeyGesture(Key.N, ModifierKeys.Control);
                         key         = new KeyBinding(ucPhanBoTheoLichCT.AddCommand, keyg);
                         key.Gesture = keyg;
                     }
                     else if (btl.Name.Equals("tlbModify"))
                     {
                         KeyGesture keyg = new KeyGesture(Key.M, ModifierKeys.Control);
                         key = new KeyBinding(ucPhanBoTheoLichCT.ModifyCommand, keyg);
                     }
                     else if (btl.Name.Equals("tlbDelete"))
                     {
                         KeyGesture keyg = new KeyGesture(Key.Delete, ModifierKeys.None);
                         key = new KeyBinding(ucPhanBoTheoLichCT.DeleteCommand, keyg);
                     }
                     else if (btl.Name.Equals("tlbApprove"))
                     {
                         KeyGesture keyg = new KeyGesture(Key.D, ModifierKeys.Control);
                         key = new KeyBinding(ucPhanBoTheoLichCT.ApproveCommand, keyg);
                     }
                     else if (btl.Name.Equals("tlbRefuse"))
                     {
                         KeyGesture keyg = new KeyGesture(Key.R, ModifierKeys.Control);
                         key = new KeyBinding(ucPhanBoTheoLichCT.RefuseCommand, keyg);
                     }
                     else if (btl.Name.Equals("tlbCancel"))
                     {
                         KeyGesture keyg = new KeyGesture(Key.I, ModifierKeys.Control);
                         key = new KeyBinding(ucPhanBoTheoLichCT.CancelCommand, keyg);
                     }
                     else if (btl.Name.Equals("tlbSearch"))
                     {
                         KeyGesture keyg = new KeyGesture(Key.F, ModifierKeys.Control);
                         key = new KeyBinding(ucPhanBoTheoLichCT.SearchCommand, keyg);
                     }
                     else if (btl.Name.Equals("tlbExport"))
                     {
                         KeyGesture keyg = new KeyGesture(Key.E, ModifierKeys.Control);
                         key = new KeyBinding(ucPhanBoTheoLichCT.ExportCommand, keyg);
                     }
                     else if (btl.Name.Equals("tlbClose"))
                     {
                         KeyGesture keyg = new KeyGesture(Key.Escape, ModifierKeys.None);
                         key = new KeyBinding(ucPhanBoTheoLichCT.CloseCommand, keyg);
                     }
                     InputBindings.Add(key);
                 }
             }
         }
         if (child.GetType() == typeof(RibbonButton))
         {
             RibbonButton btl = (RibbonButton)child;
             KeyBinding   key = new KeyBinding();
             if (btl.Name.Equals("tlbAdd"))
             {
                 KeyGesture keyg = new KeyGesture(Key.N, ModifierKeys.Control);
                 key         = new KeyBinding(ucPhanBoTheoLichCT.AddCommand, keyg);
                 key.Gesture = keyg;
             }
             else if (btl.Name.Equals("tlbModify"))
             {
                 KeyGesture keyg = new KeyGesture(Key.M, ModifierKeys.Control);
                 key = new KeyBinding(ucPhanBoTheoLichCT.ModifyCommand, keyg);
             }
             else if (btl.Name.Equals("tlbRemove"))
             {
                 KeyGesture keyg = new KeyGesture(Key.Delete, ModifierKeys.None);
                 key = new KeyBinding(ucPhanBoTheoLichCT.DeleteCommand, keyg);
             }
             else if (btl.Name.Equals("tlbApprove"))
             {
                 KeyGesture keyg = new KeyGesture(Key.D, ModifierKeys.Control);
                 key = new KeyBinding(ucPhanBoTheoLichCT.ApproveCommand, keyg);
             }
             else if (btl.Name.Equals("tlbRefuse"))
             {
                 KeyGesture keyg = new KeyGesture(Key.R, ModifierKeys.Control);
                 key = new KeyBinding(ucPhanBoTheoLichCT.RefuseCommand, keyg);
             }
             else if (btl.Name.Equals("tlbCancel"))
             {
                 KeyGesture keyg = new KeyGesture(Key.I, ModifierKeys.Control);
                 key = new KeyBinding(ucPhanBoTheoLichCT.CancelCommand, keyg);
             }
             else if (btl.Name.Equals("tlbSearch"))
             {
                 KeyGesture keyg = new KeyGesture(Key.F, ModifierKeys.Control);
                 key = new KeyBinding(ucPhanBoTheoLichCT.SearchCommand, keyg);
             }
             else if (btl.Name.Equals("tlbExport"))
             {
                 KeyGesture keyg = new KeyGesture(Key.E, ModifierKeys.Control);
                 key = new KeyBinding(ucPhanBoTheoLichCT.ExportCommand, keyg);
             }
             else if (btl.Name.Equals("tlbClose"))
             {
                 KeyGesture keyg = new KeyGesture(Key.Escape, ModifierKeys.None);
                 key = new KeyBinding(ucPhanBoTheoLichCT.CloseCommand, keyg);
             }
             InputBindings.Add(key);
         }
     }
 }
Beispiel #33
0
        public void VsKeyLeftArrow()
        {
            var b = KeyBinding.Parse("::Left Arrow");

            Assert.Equal(VimKey.Left, b.FirstKeyStroke.Key);
        }
Beispiel #34
0
 public static void RegisterKeyBinding(KeyBinding keyBinding)
 {
     m_keyboardEvents.Add(keyBinding.KeyCode, keyBinding.Event);
 }
        /// <summary>
        /// Creates a keyboard shortcut from a
        /// </summary>
        /// <param name="ksc"></param>
        /// <param name="command"></param>
        /// <returns>KeyBinding - Window.InputBindings.Add(keyBinding)</returns>
        public static KeyBinding xCreateKeyboardShortcutBinding(string ksc, ICommand command, object commandParameter = null)
        {
            if (string.IsNullOrEmpty(ksc))
            {
                return(null);
            }

            try
            {
                KeyBinding kb = new KeyBinding();
                ksc = ksc.ToLower();

                if (ksc.Contains("alt"))
                {
                    kb.Modifiers = ModifierKeys.Alt;
                }
                if (ksc.Contains("shift"))
                {
                    kb.Modifiers |= ModifierKeys.Shift;
                }
                if (ksc.Contains("ctrl") || ksc.Contains("ctl"))
                {
                    kb.Modifiers |= ModifierKeys.Control;
                }
                if (ksc.Contains("win"))
                {
                    kb.Modifiers |= ModifierKeys.Windows;
                }

                string key =
                    ksc.Replace("+", "")
                    .Replace("-", "")
                    .Replace("_", "")
                    .Replace(" ", "")
                    .Replace("alt", "")
                    .Replace("shift", "")
                    .Replace("ctrl", "")
                    .Replace("ctl", "");

                key = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(key);
                if (!string.IsNullOrEmpty(key))
                {
                    KeyConverter k = new KeyConverter();
                    kb.Key = (Key)k.ConvertFromString(key);
                }

                // Whatever command you need to bind to
                kb.Command = command;
                if (commandParameter != null)
                {
                    kb.CommandParameter = commandParameter;
                }

                return(kb);
            }
            // deal with invalid bindings - ignore them
            catch (Exception ex)
            {
                mmApp.Log("Unable to assign key binding: " + ksc, ex);
                return(null);
            }
        }
Beispiel #36
0
        private void AddCtrlSpacebar()
        {
            var handleCtrlSpacebar = new KeyBinding(new ControlSpacebarCommand(textEditor), Key.Space, ModifierKeys.Control);

            AddKeyBinding(handleCtrlSpacebar);
        }
Beispiel #37
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="toggleLayer">The keys which toggle the data layer overlay.</param>
 /// <param name="prevLayer">The keys which cycle backwards through data layers.</param>
 /// <param name="nextLayer">The keys which cycle forward through data layers.</param>
 public ModConfigKeys(KeyBinding toggleLayer, KeyBinding prevLayer, KeyBinding nextLayer)
 {
     this.ToggleLayer = toggleLayer;
     this.PrevLayer   = prevLayer;
     this.NextLayer   = nextLayer;
 }
Beispiel #38
0
        private void AddF5()
        {
            KeyBinding handleF5 = new KeyBinding(new F5Command(textEditor), new KeyGesture(Key.F5));

            AddKeyBinding(handleF5);
        }
Beispiel #39
0
        public void VsKeyBackSpace()
        {
            var b = KeyBinding.Parse("::Bkspce");

            Assert.Equal(VimKey.Back, b.FirstKeyStroke.KeyInput.Key);
        }
Beispiel #40
0
 void Unregister()
 {
     if (_root != null && _binding != null)
         _root.KeyBindings.Remove(_binding);
     _binding = null;
 }
 public void SetBinding(KeyBinding keyBinding)
 {
     keyField.text    = keyBinding.Key.ToString();
     actionField.text = keyBinding.Action.ToString();
 }
		public void Load(XmlDocument configDocument)
		{
			
			XmlNode langNode = configDocument.DocumentElement.SelectSingleNode("./Language[@Name='" + _language + "']");
			if (langNode == null)
				return;

			XmlElement callTipNode = langNode.SelectSingleNode("CallTip") as XmlElement;
			if (callTipNode != null)
			{
				_callTip_BackColor = getColor(callTipNode.GetAttribute("BackColor"));
				_callTip_ForeColor = getColor(callTipNode.GetAttribute("ForeColor"));
				_callTip_HighlightTextColor = getColor(callTipNode.GetAttribute("HighlightTextColor"));
			}
			callTipNode = null;

			XmlElement caretNode = langNode.SelectSingleNode("Caret") as XmlElement;
			if (caretNode != null)
			{
				//	This guy is a bit of an oddball becuase null means "I don't Care"
				//	and we need some way of using the OS value.
				string blinkRate = caretNode.GetAttribute("BlinkRate");
				if (blinkRate.ToLower() == "system")
					_caret_BlinkRate = SystemInformation.CaretBlinkTime;
				else
					_caret_BlinkRate = getInt(blinkRate);

				_caret_Color = getColor(caretNode.GetAttribute("Color"));
				_caret_CurrentLineBackgroundAlpha = getInt(caretNode.GetAttribute("CurrentLineBackgroundAlpha"));
				_caret_CurrentLineBackgroundColor = getColor(caretNode.GetAttribute("CurrentLineBackgroundColor"));
				_caret_HighlightCurrentLine = getBool(caretNode.GetAttribute("HighlightCurrentLine"));
				_caret_IsSticky = getBool(caretNode.GetAttribute("IsSticky"));
				try
				{
					_caret_Style = (CaretStyle)Enum.Parse(typeof(CaretStyle), caretNode.GetAttribute("Style"), true);
				}
				catch (ArgumentException) { }
				_caret_Width = getInt(caretNode.GetAttribute("Width"));
			}
			caretNode = null;

			XmlElement clipboardNode = langNode.SelectSingleNode("Clipboard") as XmlElement;
			if (clipboardNode != null)
			{
				_clipboard_ConvertEndOfLineOnPaste = getBool(clipboardNode.GetAttribute("ConvertEndOfLineOnPaste"));
			}
			clipboardNode = null;

			_commands_KeyBindingList = new CommandBindingConfigList();
			XmlElement commandsNode = langNode.SelectSingleNode("Commands") as XmlElement;
			if (commandsNode != null)
			{
				_commands_KeyBindingList.Inherit = getBool(commandsNode.GetAttribute("Inherit"));
				_commands_KeyBindingList.AllowDuplicateBindings = getBool(commandsNode.GetAttribute("AllowDuplicateBindings"));
				foreach (XmlElement el in commandsNode.SelectNodes("./Binding"))
				{
					KeyBinding kb = new KeyBinding();
					kb.KeyCode = Utilities.GetKeys(el.GetAttribute("Key"));

					string modifiers = el.GetAttribute("Modifier");
					if (modifiers != string.Empty)
					{
						foreach (string modifier in modifiers.Split(' '))
							kb.Modifiers |= (Keys)Enum.Parse(typeof(Keys), modifier.Trim(), true);
					}

					BindableCommand cmd = (BindableCommand)Enum.Parse(typeof(BindableCommand), el.GetAttribute("Command"), true);
					CommandBindingConfig cfg = new CommandBindingConfig(kb, getBool(el.GetAttribute("ReplaceCurrent")), cmd);
					_commands_KeyBindingList.Add(cfg);
				}
			}
			commandsNode = null;

			XmlElement endOfLineNode = langNode.SelectSingleNode("EndOfLine") as XmlElement;
			if (endOfLineNode != null)
			{
				_endOfLine_ConvertOnPaste = getBool(endOfLineNode.GetAttribute("ConvertOnPaste"));
				_endOfLine_IsVisisble = getBool(endOfLineNode.GetAttribute("IsVisible"));

				try
				{
					_endOfLine_Mode = (EndOfLineMode)Enum.Parse(typeof(EndOfLineMode), endOfLineNode.GetAttribute("Mode"), true);
				}
				catch (ArgumentException) { }
			}
			endOfLineNode = null;

			XmlElement hotSpotNode = langNode.SelectSingleNode("HotSpot") as XmlElement;
			if (hotSpotNode != null)
			{
				_hotspot_ActiveBackColor = getColor(hotSpotNode.GetAttribute("ActiveBackColor"));
				_hotspot_ActiveForeColor = getColor(hotSpotNode.GetAttribute("ActiveForeColor"));
				_hotspot_ActiveUnderline = getBool(hotSpotNode.GetAttribute("ActiveUnderline"));
				_hotspot_SingleLine = getBool(hotSpotNode.GetAttribute("SingleLine"));
				_hotspot_UseActiveBackColor = getBool(hotSpotNode.GetAttribute("UseActiveBackColor"));
				_hotspot_UseActiveForeColor = getBool(hotSpotNode.GetAttribute("UseActiveForeColor"));
			}
			hotSpotNode = null;

			XmlElement indentationNode = langNode.SelectSingleNode("Indentation") as XmlElement;
			if (indentationNode != null)
			{
				_indentation_BackspaceUnindents = getBool(indentationNode.GetAttribute("BackspaceUnindents"));
				_indentation_IndentWidth = getInt(indentationNode.GetAttribute("IndentWidth"));
				_indentation_ShowGuides = getBool(indentationNode.GetAttribute("ShowGuides"));
				_indentation_TabIndents = getBool(indentationNode.GetAttribute("TabIndents"));
				_indentation_TabWidth = getInt(indentationNode.GetAttribute("TabWidth"));
				_indentation_UseTabs = getBool(indentationNode.GetAttribute("UseTabs"));

				try
				{
					_indentation_SmartIndentType = (SmartIndent)Enum.Parse(typeof(SmartIndent), indentationNode.GetAttribute("SmartIndentType"), true);
				}
				catch (ArgumentException) { }

			}
			indentationNode = null;

			XmlElement indicatorNode = langNode.SelectSingleNode("Indicators") as XmlElement;
			if (indicatorNode != null)
			{
				_indicator_List.Inherit = getBool(indicatorNode.GetAttribute("Inherit"));
				foreach (XmlElement el in indicatorNode.SelectNodes("Indicator"))
				{
					IndicatorConfig ic = new IndicatorConfig();
					ic.Number = int.Parse(el.GetAttribute("Number"));
					ic.Color = getColor(el.GetAttribute("Color"));
					ic.Inherit = getBool(el.GetAttribute("Inherit"));
					ic.IsDrawnUnder = getBool(el.GetAttribute("IsDrawnUnder"));
					try
					{
						ic.Style = (IndicatorStyle)Enum.Parse(typeof(IndicatorStyle), el.GetAttribute("Style"), true);
					}
					catch (ArgumentException) { }

					_indicator_List.Add(ic);
				}
			}

			_lexing_Properties = new LexerPropertiesConfig();
			_lexing_Keywords = new KeyWordConfigList();
			XmlElement lexerNode = langNode.SelectSingleNode("Lexer") as XmlElement;
			if (lexerNode != null)
			{
				_lexing_WhiteSpaceChars = getString(lexerNode.GetAttributeNode("WhiteSpaceChars"));
				_lexing_WordChars = getString(lexerNode.GetAttributeNode("WordChars"));
				_lexing_Language = getString(lexerNode.GetAttributeNode("LexerName"));
				_lexing_LineCommentPrefix = getString(lexerNode.GetAttributeNode("LineCommentPrefix"));
				_lexing_StreamCommentPrefix = getString(lexerNode.GetAttributeNode("StreamCommentPrefix"));
				_lexing_StreamCommentSuffix = getString(lexerNode.GetAttributeNode("StreamCommentSuffix"));

				XmlElement propNode = lexerNode.SelectSingleNode("Properties") as XmlElement;
				if (propNode != null)
				{
					_lexing_Properties.Inherit = getBool(propNode.GetAttribute("Inherit"));

					foreach (XmlElement el in propNode.SelectNodes("Property"))
						_lexing_Properties.Add(el.GetAttribute("Name"), el.GetAttribute("Value"));
				}

				foreach (XmlElement el in lexerNode.SelectNodes("Keywords"))
					_lexing_Keywords.Add(new KeyWordConfig(getInt(el.GetAttribute("List")).Value, el.InnerText.Trim(), getBool(el.GetAttribute("Inherit"))));

			}
			lexerNode = null;

			XmlElement lineWrapNode = langNode.SelectSingleNode("LineWrap") as XmlElement;
			if (lineWrapNode != null)
			{
				try
				{
					_lineWrap_LayoutCache = (LineCache)Enum.Parse(typeof(LineCache), lineWrapNode.GetAttribute("LayoutCache"), true);
				}
				catch (ArgumentException) { }

				try
				{
					_lineWrap_Mode = (WrapMode)Enum.Parse(typeof(WrapMode), lineWrapNode.GetAttribute("Mode"), true);
				}
				catch (ArgumentException) { }

				_lineWrap_PositionCacheSize = getInt(lineWrapNode.GetAttribute("PositionCacheSize"));
				_lineWrap_StartIndent = getInt(lineWrapNode.GetAttribute("StartIndent"));

				string flags = lineWrapNode.GetAttribute("VisualFlags").Trim();
				if (flags != string.Empty)
				{
					WrapVisualFlag? wvf = null;
					foreach (string flag in flags.Split(' '))
						wvf |= (WrapVisualFlag)Enum.Parse(typeof(WrapVisualFlag), flag.Trim(), true);

					if (wvf.HasValue)
						_lineWrap_VisualFlags = wvf;
				}

				try
				{
					_lineWrap_VisualFlagsLocation = (WrapVisualLocation)Enum.Parse(typeof(WrapVisualLocation), lineWrapNode.GetAttribute("VisualFlagsLocation"), true);
				}
				catch (ArgumentException) { }
			}
			lineWrapNode = null;

			XmlElement longLinesNode = langNode.SelectSingleNode("LongLines") as XmlElement;
			if (longLinesNode != null)
			{
				_longLines_EdgeColor = getColor(longLinesNode.GetAttribute("EdgeColor"));
				_longLines_EdgeColumn = getInt(longLinesNode.GetAttribute("EdgeColumn"));
				try
				{
					_longLines_EdgeMode = (EdgeMode)Enum.Parse(typeof(EdgeMode), longLinesNode.GetAttribute("EdgeMode"), true);
				}
				catch (ArgumentException) { }
			}
			longLinesNode = null;

			_margin_List = new MarginConfigList();
			XmlElement marginNode = langNode.SelectSingleNode("Margins") as XmlElement;
			if (marginNode != null)
			{
				_margin_List.FoldMarginColor = getColor(marginNode.GetAttribute("FoldMarginColor"));
				_margin_List.FoldMarginHighlightColor = getColor(marginNode.GetAttribute("FoldMarginHighlightColor"));
				_margin_List.Left = getInt(marginNode.GetAttribute("Left"));
				_margin_List.Right = getInt(marginNode.GetAttribute("Right"));
				_margin_List.Inherit = getBool(marginNode.GetAttribute("Inherit"));

				foreach (XmlElement el in marginNode.SelectNodes("./Margin"))
				{
					MarginConfig mc = new MarginConfig();
					mc.Number = int.Parse(el.GetAttribute("Number"));
					mc.Inherit = getBool(el.GetAttribute("Inherit"));
					mc.AutoToggleMarkerNumber = getInt(el.GetAttribute("AutoToggleMarkerNumber"));
					mc.IsClickable = getBool(el.GetAttribute("IsClickable"));
					mc.IsFoldMargin = getBool(el.GetAttribute("IsFoldMargin"));
					mc.IsMarkerMargin = getBool(el.GetAttribute("IsMarkerMargin"));
					try
					{
						mc.Type = (MarginType)Enum.Parse(typeof(MarginType), el.GetAttribute("Type"), true);
					}
					catch (ArgumentException) { }

					mc.Width = getInt(el.GetAttribute("Width"));

					_margin_List.Add(mc);
				}
			}
			marginNode = null;

			XmlElement markersNode = langNode.SelectSingleNode("Markers") as XmlElement;
			_markers_List = new MarkersConfigList();
			if (markersNode != null)
			{
				_markers_List.Inherit = getBool(markersNode.GetAttribute("Inherit"));

				foreach (XmlElement el in markersNode.SelectNodes("Marker"))
				{
					MarkersConfig mc = new MarkersConfig();
					mc.Alpha = getInt(el.GetAttribute("Alpha"));
					mc.BackColor = getColor(el.GetAttribute("BackColor"));
					mc.ForeColor = getColor(el.GetAttribute("ForeColor"));
					mc.Name = getString(el.GetAttributeNode("Name"));
					mc.Number = getInt(el.GetAttribute("Number"));
					mc.Inherit = getBool(el.GetAttribute("Inherit"));
					try
					{
						mc.Symbol = (MarkerSymbol)Enum.Parse(typeof(MarkerSymbol), el.GetAttribute("Symbol"), true);
					}
					catch (ArgumentException) { }
					_markers_List.Add(mc);
				}
			}

			XmlElement scrollingNode = langNode.SelectSingleNode("Scrolling") as XmlElement;
			if (scrollingNode != null)
			{
				_scrolling_EndAtLastLine = getBool(scrollingNode.GetAttribute("EndAtLastLine"));
				_scrolling_HorizontalWidth = getInt(scrollingNode.GetAttribute("HorizontalWidth"));

				string flags = scrollingNode.GetAttribute("ScrollBars").Trim();
				if (flags != string.Empty)
				{
					ScrollBars? sb = null;
					foreach (string flag in flags.Split(' '))
						sb |= (ScrollBars)Enum.Parse(typeof(ScrollBars), flag.Trim(), true);

					if (sb.HasValue)
						_scrolling_ScrollBars = sb;
				}

				_scrolling_XOffset = getInt(scrollingNode.GetAttribute("XOffset"));
			}
			scrollingNode = null;


			XmlElement selectionNode = langNode.SelectSingleNode("Selection") as XmlElement;
			if (selectionNode != null)
			{
				_selection_BackColor = getColor(selectionNode.GetAttribute("BackColor"));
				_selection_BackColorUnfocused = getColor(selectionNode.GetAttribute("BackColorUnfocused"));
				_selection_ForeColor = getColor(selectionNode.GetAttribute("ForeColor"));
				_selection_ForeColorUnfocused = getColor(selectionNode.GetAttribute("ForeColorUnfocused"));
				_selection_Hidden = getBool(selectionNode.GetAttribute("Hidden"));
				_selection_HideSelection = getBool(selectionNode.GetAttribute("HideSelection"));
				try
				{
					_selection_Mode = (SelectionMode)Enum.Parse(typeof(SelectionMode), selectionNode.GetAttribute("Mode"), true);
				}
				catch (ArgumentException) { }
			}
			selectionNode = null;

			_styles = new StyleConfigList();
			XmlElement stylesNode = langNode.SelectSingleNode("Styles") as XmlElement;
			if (stylesNode != null)
			{
				_styles.Bits = getInt(stylesNode.GetAttribute("Bits"));
				foreach (XmlElement el in stylesNode.SelectNodes("Style"))
				{
					StyleConfig sc = new StyleConfig();
					sc.Name = el.GetAttribute("Name");
					sc.Number = getInt(el.GetAttribute("Number"));
					sc.BackColor = getColor(el.GetAttribute("BackColor"));
					sc.Bold = getBool(el.GetAttribute("Bold"));
					try
					{
						sc.Case = (StyleCase)Enum.Parse(typeof(StyleCase), el.GetAttribute("Case"), true);
					}
					catch (ArgumentException) { }

					try
					{
						sc.CharacterSet = (CharacterSet)Enum.Parse(typeof(CharacterSet), el.GetAttribute("CharacterSet"), true);
					}
					catch (ArgumentException) { }

					sc.FontName = getString(el.GetAttributeNode("FontName"));
					sc.ForeColor = getColor(el.GetAttribute("ForeColor"));
					sc.IsChangeable = getBool(el.GetAttribute("IsChangeable"));
					sc.IsHotspot = getBool(el.GetAttribute("IsHotspot"));
					sc.IsSelectionEolFilled = getBool(el.GetAttribute("IsSelectionEolFilled"));
					sc.IsVisible = getBool(el.GetAttribute("IsVisible"));
					sc.Italic = getBool(el.GetAttribute("Italic"));
					sc.Size = getInt(el.GetAttribute("Size"));
					sc.Underline = getBool(el.GetAttribute("Underline"));
					sc.Inherit = getBool(el.GetAttribute("Inherit"));
					
					_styles.Add(sc);
				}

				//	This is a nifty added on hack made specifically for HTML.
				//	Normally the style config elements are quite managable as there
				//	are typically less than 10 when you don't count common styles.
				//	
				//	However HTML uses 9 different Sub languages that combined make 
				//	use of all 128 styles (well there are some small gaps). In order
				//	to make this more managable I did added a SubLanguage element that
				//	basically just prepends the Language's name and "." to the Style 
				//	Name definition.
				//
				//	So for example if you had the following
				//	<Styles>
				//		<SubLanguage Name="ASP JavaScript">
				//			<Style Name="Keyword" Bold="True" />
				//		</SubLanguage>
				//	</Styles>
				//	That style's name will get interpreted as "ASP JavaScript.Keyword".
				//	which if you look at the html.txt in LexerStyleNames you'll see it
				//	maps to Style # 62

				//	Yeah I copied and pasted from above. I know. Feel free to refactor
				//	this and check it in since you're so high and mighty.
				foreach (XmlElement subLanguage in stylesNode.SelectNodes("SubLanguage"))
				{
					string subLanguageName = subLanguage.GetAttribute("Name");
					foreach (XmlElement el in subLanguage.SelectNodes("Style"))
					{
						StyleConfig sc = new StyleConfig();
						sc.Name = subLanguageName + "." + el.GetAttribute("Name");
						sc.Number = getInt(el.GetAttribute("Number"));
						sc.BackColor = getColor(el.GetAttribute("BackColor"));
						sc.Bold = getBool(el.GetAttribute("Bold"));
						try
						{
							sc.Case = (StyleCase)Enum.Parse(typeof(StyleCase), el.GetAttribute("Case"), true);
						}
						catch (ArgumentException) { }

						try
						{
							sc.CharacterSet = (CharacterSet)Enum.Parse(typeof(CharacterSet), el.GetAttribute("CharacterSet"), true);
						}
						catch (ArgumentException) { }

						sc.FontName = getString(el.GetAttributeNode("FontName"));
						sc.ForeColor = getColor(el.GetAttribute("ForeColor"));
						sc.IsChangeable = getBool(el.GetAttribute("IsChangeable"));
						sc.IsHotspot = getBool(el.GetAttribute("IsHotspot"));
						sc.IsSelectionEolFilled = getBool(el.GetAttribute("IsSelectionEolFilled"));
						sc.IsVisible = getBool(el.GetAttribute("IsVisible"));
						sc.Italic = getBool(el.GetAttribute("Italic"));
						sc.Size = getInt(el.GetAttribute("Size"));
						sc.Underline = getBool(el.GetAttribute("Underline"));
						sc.Inherit = getBool(el.GetAttribute("Inherit"));

						_styles.Add(sc);
					}
				}
			}
			stylesNode = null;

			XmlElement undoRedoNode = langNode.SelectSingleNode("UndoRedo") as XmlElement;
			if (undoRedoNode != null)
			{
				_undoRedoIsUndoEnabled = getBool(undoRedoNode.GetAttribute("IsUndoEnabled"));
			}
			undoRedoNode = null;


			XmlElement whiteSpaceNode = langNode.SelectSingleNode("WhiteSpace") as XmlElement;
			if (whiteSpaceNode != null)
			{
				_whiteSpace_BackColor = getColor(whiteSpaceNode.GetAttribute("BackColor"));
				_whiteSpace_ForeColor = getColor(whiteSpaceNode.GetAttribute("ForeColor"));
				_whiteSpace_Mode = (WhiteSpaceMode)Enum.Parse(typeof(WhiteSpaceMode), whiteSpaceNode.GetAttribute("Mode"), true);
				_whiteSpace_UseWhiteSpaceBackColor = getBool(whiteSpaceNode.GetAttribute("UseWhiteSpaceBackColor"));
				_whiteSpace_UseWhiteSpaceForeColor = getBool(whiteSpaceNode.GetAttribute("UseWhiteSpaceForeColor"));
			}
			whiteSpaceNode = null;

			configDocument = null;
		}
 public void ToStringTest()
 {
     {
         var keyBinding = new KeyBinding(Fish.eigotest.Command.Action0, Keys.A, true, true, true);
         Assert.AreEqual("Shift+Ctrl+Alt+A", keyBinding.GetText());
     }
     {
         var keyBinding = new KeyBinding(Fish.eigotest.Command.Action0, Keys.A, false, true, true);
         Assert.AreEqual("Shift+Ctrl+A", keyBinding.GetText());
     }
     {
         var keyBinding = new KeyBinding(Fish.eigotest.Command.Action0, Keys.A, false, false, true);
         Assert.AreEqual("Shift+A", keyBinding.GetText());
     }
     {
         var keyBinding = new KeyBinding(Fish.eigotest.Command.Action0, Keys.A, false, false, false);
         Assert.AreEqual("A", keyBinding.GetText());
     }
 }
Beispiel #44
0
 public Key this[KeyBinding key]
 {
     get { return Keys[(int)key]; }
     set { Keys[(int)key] = value; SaveKeyBindings(); }
 }
Beispiel #45
0
 private void AddKeyBinding(KeyBinding targetBinding)
 {
     textEditor.TextArea.DefaultInputHandler.Editing.InputBindings.Add(targetBinding);
 }
Beispiel #46
0
        public void VsKeyRightArrow()
        {
            var b = KeyBinding.Parse("::Right Arrow");

            Assert.Equal(VimKey.Right, b.FirstKeyStroke.KeyInput.Key);
        }
Beispiel #47
0
 void Register()
 {
     if (_root != null && _hotkey != null)
     {
         _binding = new KeyBinding() {Gesture = _hotkey, Command = _wrapper};
         _root.KeyBindings.Add(_binding);
     }
 }
 /// <summary> Returns whether the key associated with the given key binding is currently held down. </summary>
 public bool IsKeyDown( KeyBinding binding )
 {
     Key key = Keys[binding];
     return game.Keyboard[key];
 }
		private void readCommands(XmlReader reader)
		{
			if (reader.HasAttributes)
			{
				while (reader.MoveToNextAttribute())
				{
					string attrName = reader.Name.ToLower();
					switch (attrName)
					{
						case "Inherit":
							_commands_KeyBindingList.Inherit = getBool(reader.Value);
							break;
						case "AllowDuplicateBindings":
							_commands_KeyBindingList.AllowDuplicateBindings = getBool(reader.Value);
							break;
					}
				}

				reader.MoveToElement();
			}

			if (!reader.IsEmptyElement)
			{
				while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name.Equals("commands", StringComparison.OrdinalIgnoreCase)))
				{
					reader.Read();
					if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("binding", StringComparison.OrdinalIgnoreCase))
					{
						if (reader.HasAttributes)
						{
							KeyBinding kb = new KeyBinding();
							BindableCommand cmd = new BindableCommand();
							bool? replaceCurrent = null;

							while (reader.MoveToNextAttribute())
							{
								string attrName = reader.Name.ToLower();
								switch (attrName)
								{
									case "key":
										kb.KeyCode = Utilities.GetKeys(reader.Value);
										break;
									case "modifier":
										if (reader.Value != string.Empty)
										{
											foreach (string modifier in reader.Value.Split(' '))
												kb.Modifiers |= (Keys)Enum.Parse(typeof(Keys), modifier.Trim(), true);
										}
										break;
									case "command":
										cmd = (BindableCommand)Enum.Parse(typeof(BindableCommand), reader.Value, true);
										break;
									case "replacecurrent":
										replaceCurrent = getBool(reader.Value);
										break;
								}
							}

							_commands_KeyBindingList.Add(new CommandBindingConfig(kb, replaceCurrent, cmd));
						}

						reader.MoveToElement();
					}
				}
			}
			reader.Read();
		}
Beispiel #50
0
 public KeybindConfig (KeyBinding keybind)
 {
     gui_id = next_gui_id;
     next_gui_id++;
     key = keybind;
 }
Beispiel #51
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            this.IsMouseVisible = true;

            SpriteFont font = Content.Load<SpriteFont>("Segoe_UI_10_Regular");
            FontManager.DefaultFont = Engine.Instance.Renderer.CreateFont(font);
            Viewport viewport = GraphicsDevice.Viewport;
            basicUI = new BasicUI(viewport.Width, viewport.Height);
            viewModel = new BasicUIViewModel();
            viewModel.Tetris = new TetrisController(basicUI.TetrisContainer, basicUI.TetrisNextContainer);
            basicUI.DataContext = viewModel;
            debug = new DebugViewModel(basicUI);

            FontManager.Instance.LoadFonts(Content);
            ImageManager.Instance.LoadImages(Content);
            SoundManager.Instance.LoadSounds(Content);

            RelayCommand command = new RelayCommand(new Action<object>(ExitEvent));

            KeyBinding keyBinding = new KeyBinding(command, KeyCode.Escape, ModifierKeys.None);
            basicUI.InputBindings.Add(keyBinding);

            RelayCommand tetrisLeft = new RelayCommand(new Action<object>(OnLeft));
            KeyBinding left = new KeyBinding(tetrisLeft, KeyCode.A, ModifierKeys.None);
            basicUI.InputBindings.Add(left);

            RelayCommand tetrisRight = new RelayCommand(new Action<object>(OnRight));
            KeyBinding right = new KeyBinding(tetrisRight, KeyCode.D, ModifierKeys.None);
            basicUI.InputBindings.Add(right);

            RelayCommand tetrisDown = new RelayCommand(new Action<object>(OnDown));
            KeyBinding down = new KeyBinding(tetrisDown, KeyCode.S, ModifierKeys.None);
            basicUI.InputBindings.Add(down);

            RelayCommand tetrisRotate = new RelayCommand(new Action<object>(OnRotate));
            KeyBinding rotate = new KeyBinding(tetrisRotate, KeyCode.W, ModifierKeys.None);
            basicUI.InputBindings.Add(rotate);
        }
Beispiel #52
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Virtex.Lib.Vrtc.GUI.Controls.vxKeyBindingSettingsGUIItem"/> class.
        /// </summary>
        /// <param name="Engine">Engine.</param>
        /// <param name="GUIManager">GUI Manager.</param>
        /// <param name="Title">Title.</param>
        /// <param name="KeyBinding">Key binding.</param>
        /// <param name="position">Position.</param>
        public vxKeyBindingSettingsGUIItem(vxEngine Engine, vxGuiManager GUIManager, string Title, KeyBinding KeyBinding, object id, Vector2 position)
            : base(position)
        {
            GUIManager.Add(this);

            this.KeyBinding = KeyBinding;

            BindingID = id;

            Label = new vxLabel(Engine, Title, position + new Vector2(10, 5));
            GUIManager.Add(Label);

            Button          = new vxButton(Engine, KeyBinding.Key.ToString(), position + new Vector2(200, 10));
            Button.Clicked += delegate {
                TakingInput            = true;
                Button.Text            = "Press Any Key...";
                Button.Colour          = Color.CornflowerBlue;
                Button.Color_Normal    = Color.CornflowerBlue;
                Button.Color_Highlight = Color.CornflowerBlue;
            };
            GUIManager.Add(Button);

            Height = 40;
        }
Beispiel #53
0
 public CommandKeyBinding(string name, KeyBinding binding)
 {
     Name = name;
     KeyBinding = binding;
 }
 public int GetIndexOfRowByBinding(KeyBinding binding)
 {
     return(Model.KeyBindings.IndexOf(binding));
 }
Beispiel #55
0
		public KeyBindingChangedEventArgs (Command command, KeyBinding oldKeyBinding)
		{
			OldKeyBinding = oldKeyBinding;
			Command = command;
		}
        // Perform our own initilization when the window initilizes.
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            F7Binding = new KeyBinding(Key.F7, ToggleHotkeys);

            var controlUpBinding    = new KeyBinding(Key.Up, Modifier.Control, () => App.MoveForwardBackward(500));
            var controlDownBinding  = new KeyBinding(Key.Down, Modifier.Control, () => App.MoveForwardBackward(-500));
            var controlLeftBinding  = new KeyBinding(Key.Left, Modifier.Control, () => App.MoveLeftRight(-500));
            var controlRightBinding = new KeyBinding(Key.Right, Modifier.Control, () => App.MoveLeftRight(500));

            var controlEndBinding = new KeyBinding(Key.End, Modifier.Control, () => BLIO.RunCommand("disconnect"));

            SymbolBindings = new KeyBinding[]
            {
                new KeyBinding(Key.Equals, App.ToggleThirdPerson),
                new KeyBinding(Key.LeftBracket, App.HalveSpeed),
                new KeyBinding(Key.RightBracket, App.DoubleSpeed),
                new KeyBinding(Key.Backslash, App.ResetSpeed),
                new KeyBinding(Key.Comma, App.RestorePosition),
                new KeyBinding(Key.Period, App.SavePosition),
                new KeyBinding(Key.Semicolon, () => BLIO.RunCommand("togglehud")),
                new KeyBinding(Key.Quote, App.ToggleDamageNumbers),
                new KeyBinding(Key.Slash, App.TogglePlayersOnly),
                controlUpBinding,
                controlDownBinding,
                controlLeftBinding,
                controlRightBinding,
                controlEndBinding,
            };

            NumpadBindings = new KeyBinding[]
            {
                new KeyBinding(Key.NumOne, App.HalveSpeed),
                new KeyBinding(Key.NumTwo, App.DoubleSpeed),
                new KeyBinding(Key.NumThree, App.ResetSpeed),
                new KeyBinding(Key.NumFour, App.RestorePosition),
                new KeyBinding(Key.NumFive, App.SavePosition),
                new KeyBinding(Key.NumSix, App.TogglePlayersOnly),
                new KeyBinding(Key.NumSeven, () => BLIO.RunCommand("togglehud")),
                new KeyBinding(Key.NumEight, App.ToggleDamageNumbers),
                new KeyBinding(Key.NumNine, App.ToggleThirdPerson),
                controlUpBinding,
                controlDownBinding,
                controlLeftBinding,
                controlRightBinding,
                controlEndBinding,
            };

            if (Properties.Settings.Default.NumpadBindings)
            {
                NumpadBindingsMenuItem.Checked = true;
                // Set up the dictionary entires for our keybindings and their callbacks.
                KeyBindings = NumpadBindings;
            }
            else
            {
                SymbolBindingsMenuItem.Checked = true;
                // Set up the dictionary entires for our keybindings and their callbacks.
                KeyBindings = SymbolBindings;
            }

            // Set up the handle variables for binding hotkeys, and set up our
            // callback method as the hook for receiving hotkey events.
            Handle = new WindowInteropHelper(this).Handle;
            source = HwndSource.FromHwnd(Handle);
            source.AddHook(OnHotkeyPressed);

            // Create the delegate to handle notifications of foreground window
            // changes, and register it with the system.
            ForegroundWindowDelegate = (_0, _1, windowHandle, _3, _4, _5, _6) => HandleForegroundWindow(windowHandle);
            SetWinEventHook(0x0003, 0x0003, IntPtr.Zero, ForegroundWindowDelegate, 0, 0, 0);

            // Set up bindings if the foreground window is already Borderlands.
            HandleForegroundWindow(GetForegroundWindow());
        }
Beispiel #57
0
        private void Lock()
        {
            if (isLocked) return;

            isLocked = true;

            InputLockManager.SetControlLock(CONTROL_LOCKOUT);

            // Prevent editor keys from being pressed while typing
            EditorLogic editor = EditorLogic.fetch;
            //TODO: POST 0.90 REVIEW
            if (editor != null && InputLockManager.IsUnlocked(ControlTypes.All)) editor.Lock(true, true, true, CONTROL_LOCKOUT);

            // This seems to be the only way to force KSP to let me lock out the "X" throttle
            // key.  It seems to entirely bypass the logic of every other keypress in the game,
            // so the only way to fix it is to use the keybindings system from the Setup screen.
            // When the terminal is focused, the THROTTLE_CUTOFF action gets unbound, and then
            // when its unfocused later, its put back the way it was:
            rememberCameraResetKey = GameSettings.CAMERA_RESET;
            GameSettings.CAMERA_RESET = new KeyBinding(KeyCode.None);
            rememberCameraModeKey = GameSettings.CAMERA_MODE;
            GameSettings.CAMERA_MODE = new KeyBinding(KeyCode.None);
            rememberCameraViewKey = GameSettings.CAMERA_NEXT;
            GameSettings.CAMERA_NEXT = new KeyBinding(KeyCode.None);
            rememberThrottleCutoffKey = GameSettings.THROTTLE_CUTOFF;
            GameSettings.THROTTLE_CUTOFF = new KeyBinding(KeyCode.None);
            rememberThrottleFullKey = GameSettings.THROTTLE_FULL;
            GameSettings.THROTTLE_FULL = new KeyBinding(KeyCode.None);
        }
Beispiel #58
0
 public Key this[KeyBinding key] {
     get { return(Keys[(int)key]); }
     set { Keys[(int)key] = value; SaveKeyBindings(); }
 }
Beispiel #59
0
		bool CanUseBinding (KeyboardShortcut[] chords, KeyboardShortcut[] accels, out KeyBinding binding, out bool isChord)
		{
			if (chords != null) {
				foreach (var chord in chords) {
					foreach (var accel in accels) {
						binding = new KeyBinding (chord, accel);
						if (bindings.BindingExists (binding)) {
							isChord = false;
							return true;
						}
					}
				}
			} else {
				foreach (var accel in accels) {
					if (bindings.ChordExists (accel)) {
						// Chords take precedence over bindings with the same shortcut.
						binding = null;
						isChord = true;
						return false;
					}
					
					binding = new KeyBinding (accel);
					if (bindings.BindingExists (binding)) {
						isChord = false;
						return true;
					}
				}
			}
			
			isChord = false;
			binding = null;
			
			return false;
		}
 private void BindShortkey()
 {
     foreach (var child in Toolbar.Children)
     {
         if (child.GetType() == typeof(RibbonButton))
         {
             RibbonButton tlb         = (RibbonButton)child;
             KeyBinding   key         = new KeyBinding();
             string       strTinhNang = tlb.Name.Substring(3, tlb.Name.Length - 3);
             if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.LUU_TAM)))
             {
                 KeyGesture keyg = new KeyGesture(Key.H, ModifierKeys.Control);
                 key         = new KeyBinding(HoldCommand, keyg);
                 key.Gesture = keyg;
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TRINH_DUYET)))
             {
                 KeyGesture keyg = new KeyGesture(Key.S, ModifierKeys.Control);
                 key = new KeyBinding(SaveCommand, keyg);
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.SUA)))
             {
                 KeyGesture keyg = new KeyGesture(Key.M, ModifierKeys.Control);
                 key = new KeyBinding(ModifyCommand, keyg);
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.XOA)))
             {
                 KeyGesture keyg = new KeyGesture(Key.Delete, ModifierKeys.Shift);
                 key = new KeyBinding(DeleteCommand, keyg);
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.DUYET)))
             {
                 KeyGesture keyg = new KeyGesture(Key.A, ModifierKeys.Control | ModifierKeys.Shift);
                 key = new KeyBinding(ApproveCommand, keyg);
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TU_CHOI_DUYET)))
             {
                 KeyGesture keyg = new KeyGesture(Key.R, ModifierKeys.Control | ModifierKeys.Shift);
                 key = new KeyBinding(RefuseCommand, keyg);
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.THOAI_DUYET)))
             {
                 KeyGesture keyg = new KeyGesture(Key.C, ModifierKeys.Control | ModifierKeys.Shift);
                 key = new KeyBinding(CancelCommand, keyg);
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TINH_TOAN)))
             {
                 KeyGesture keyg = new KeyGesture(Key.T, ModifierKeys.Control | ModifierKeys.Shift);
                 key = new KeyBinding(CancelCommand, keyg);
             }
             else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TRO_GIUP)))
             {
                 KeyGesture keyg = new KeyGesture(Key.F1, ModifierKeys.None);
                 key = new KeyBinding(HelpCommand, keyg);
             }
             if (key != null)
             {
                 InputBindings.Add(key);
             }
         }
     }
 }