Esempio n. 1
0
        //////////////////////////////////////////////////////////////////////////////

        #region Scene key handling

        private bool SceneKeyDownHandler(KeyCode key, CModifiers modifiers)
        {
            CBinding  binding;
            CShortCut shortCut = new CShortCut(key, modifiers);

            if (CBindings.FindBinding(shortCut, out binding))
            {
                return(ExecCommand(binding.cmdKeyDown));
            }

            return(false);
        }
Esempio n. 2
0
        public static bool TryParse(string token, out CShortCut shortCut)
        {
            string[] tokens = token.Split('+');

            CModifiers modifiers = 0;

            if (tokens.Length > 1)
            {
                for (int i = 0; i < tokens.Length - 1; ++i)
                {
                    string name = tokens[i].ToLower();
                    if (name == "ctrl")
                    {
                        modifiers |= CModifiers.Control;
                    }
                    else if (name == "shift")
                    {
                        modifiers |= CModifiers.Shift;
                    }
                    else if (name == "alt")
                    {
                        modifiers |= CModifiers.Alt;
                    }
                    else if (name == "cmd" || name == "command")
                    {
                        modifiers |= CModifiers.Command;
                    }
                    else
                    {
                        shortCut = default(CShortCut);
                        return(false);
                    }
                }
            }

            string  keyName = tokens[tokens.Length - 1].ToLower();
            KeyCode key;

            if (!CBindings.TryParse(keyName, out key))
            {
                shortCut = default(CShortCut);
                return(false);
            }

            shortCut = new CShortCut(key, modifiers);
            return(true);
        }
Esempio n. 3
0
        private static CModifiers GetModifiers(CEvent evt)
        {
            CModifiers modifiers = 0;

            if (evt.alt)
            {
                modifiers |= CModifiers.Alt;
            }
            if (evt.shift)
            {
                modifiers |= CModifiers.Shift;
            }
            if (evt.control)
            {
                modifiers |= CModifiers.Control;
            }
            if (evt.command)
            {
                modifiers |= CModifiers.Command;
            }

            return(modifiers);
        }
Esempio n. 4
0
        public static bool TryParse(string token, out CShortCut shortCut)
        {
            string[] tokens = token.Split('+');

            CModifiers modifiers = 0;
            if (tokens.Length > 1)
            {
                for (int i = 0; i < tokens.Length - 1; ++i)
                {
                    string name = tokens[i].ToLower();
                    if (name == "ctrl")
                        modifiers |= CModifiers.Control;
                    else if (name == "shift")
                        modifiers |= CModifiers.Shift;
                    else if (name == "alt")
                        modifiers |= CModifiers.Alt;
                    else if (name == "cmd" || name == "command")
                        modifiers |= CModifiers.Command;
                    else
                    {
                        shortCut = default(CShortCut);
                        return false;
                    }
                }
            }

            string keyName = tokens[tokens.Length - 1].ToLower();
            KeyCode key;
            if (!CBindings.TryParse(keyName, out key))
            {
                shortCut = default(CShortCut);
                return false;
            }

            shortCut = new CShortCut(key, modifiers);
            return true;
        }
Esempio n. 5
0
 public CShortCut(KeyCode key, CModifiers modifiers)
 {
     this.key       = key;
     this.modifiers = modifiers;
 }
Esempio n. 6
0
 public bool HasModifier(CModifiers modifier)
 {
     return((modifiers & modifier) != 0);
 }
Esempio n. 7
0
 public bool HasModifier(CModifiers modifier)
 {
     return (modifiers & modifier) != 0;
 }
Esempio n. 8
0
 public CShortCut(KeyCode key, CModifiers modifiers)
 {
     this.key = key;
     this.modifiers = modifiers;
 }
Esempio n. 9
0
        private bool SceneUpDownHandler(KeyCode key, CModifiers modifiers)
        {
            CBinding binding;
            CShortCut shortCut = new CShortCut(key, modifiers);
            if (CBindings.FindBinding(shortCut, out binding) && binding.cmdKeyUp != null)
            {
                return ExecCommand(binding.cmdKeyUp);
            }

            return false;
        }