Exemplo n.º 1
0
        public IEnumerable <object> GetElementsMatchingShortcut(ModifierKeys modifierKeys, Key key)
        {
            var keyShortcut = new KeyShortcut(modifierKeys, key);

            return(CommandManager.GlobalCommands.Where(o => o.Metadata.OfType <KeyShortcutBase>().Any() && ShortcutComparer.Equals(o.Metadata.OfType <KeyShortcutBase>().Single(), keyShortcut)).Cast <object>().Concat
                       (PanelManager.StaticPanelDefinitions.Where(def => def.OfType <KeyShortcutBase>().Any() && ShortcutComparer.Equals(def.OfType <KeyShortcutBase>().Single(), keyShortcut)).Cast <object>()));
        }
        CommandInfo GetCommand(KeyEventArgs e, object target, out bool waitForSecondKey)
        {
            var keyInput = new KeyInput(e);
            ProviderAndCommand result;

            if (prevKey != null)
            {
                waitForSecondKey = false;
                var keyShortcut = new KeyShortcut(prevKey.Value, keyInput);
                result  = keyShortcutCollection.GetTwoKeyShortcuts(keyShortcut).FirstOrDefault();
                prevKey = null;
            }
            else
            {
                if (keyShortcutCollection.IsTwoKeyCombo(keyInput))
                {
                    waitForSecondKey = true;
                    prevKey          = keyInput;
                    result           = default(ProviderAndCommand);
                }
                else
                {
                    waitForSecondKey = false;
                    result           = keyShortcutCollection.GetOneKeyShortcuts(keyInput).FirstOrDefault();
                }
            }
            if (result.IsDefault)
            {
                return(StandardIds.Unknown.ToCommandInfo());
            }
            return(result.Command);
        }
Exemplo n.º 3
0
        public Message(IEnumerable <KeyPress> keys, KeyShortcut shortcut, Boolean isShortcut = false)
            : this()
        {
            var allKeys             = keys.ToArray();
            var distinctProcessName = allKeys.Select(k => k.Process.ProcessName)
                                      .Distinct()
                                      .ToArray();

            if (distinctProcessName.Count() != 1)
            {
                throw new InvalidOperationException("Keys are from different processes");
            }

            processName     = distinctProcessName.Single();
            processIcon     = allKeys.First().Process.ProcessIcon;
            shortcutName    = shortcut.Name;
            this.isShortcut = isShortcut;
            canBeMerged     = false;

            this.keys = new ReadOnlyCollection <KeyPress>(allKeys);

            var textSeq = CreateTextSequence(allKeys).ToList();

            if (!string.IsNullOrEmpty(shortcutName))
            {
                textSeq.Add(string.Format(" [{0}]", shortcutName));
            }
            textCollection = new ReadOnlyCollection <string>(textSeq);
        }
Exemplo n.º 4
0
		public IEnumerable<ProviderAndCommand> GetTwoKeyShortcuts(KeyShortcut keyShortcut) {
			Debug.Assert(keyShortcut.HasTwoKeyInputs);
			List<ProviderAndCommand> list;
			if (dict.TryGetValue(keyShortcut, out list))
				return list;
			return Array.Empty<ProviderAndCommand>();
		}
Exemplo n.º 5
0
 public RepositoryItemFADatePicker()
 {
     TextEditStyle        = TextEditStyles.Standard;
     CloseUpKey           = new KeyShortcut(Keys.F4);
     PopupSizeable        = false;
     ShowPopupCloseButton = false;
 }
Exemplo n.º 6
0
        public void SerializeAndGet()
        {
            var shortcut = new KeyShortcut
            {
                AddSpace       = true,
                AlignFromCaret = true,
                Alignment      = " = ",
                Language       = "CSharp",
                UseRegex       = true,
                Value          = Key.EqualsPlus
            };

            var xml        = KeyShortcut.Serialize(new[] { shortcut });
            var cloneArray = KeyShortcut.Get(xml);

            Assert.Single(cloneArray);

            var clone = cloneArray[0];

            Assert.Equal(shortcut.AddSpace, clone.AddSpace);
            Assert.Equal(shortcut.AlignFromCaret, clone.AlignFromCaret);
            Assert.Equal(shortcut.Alignment, clone.Alignment);
            Assert.Equal(shortcut.Language, clone.Language);
            Assert.Equal(shortcut.UseRegex, clone.UseRegex);
            Assert.Equal(shortcut.Value, clone.Value);
        }
Exemplo n.º 7
0
		public IEnumerable<ProviderAndCommand> GetOneKeyShortcuts(KeyInput keyInput) {
			var keyShortcut = new KeyShortcut(keyInput, KeyInput.Default);
			List<ProviderAndCommand> list;
			if (dict.TryGetValue(keyShortcut, out list))
				return list;
			return Array.Empty<ProviderAndCommand>();
		}
 public RepositoryItemFADatePicker()
 {
     TextEditStyle = TextEditStyles.Standard;
     CloseUpKey = new KeyShortcut(Keys.F4);
     PopupSizeable = false;
     ShowPopupCloseButton = false;
 }
Exemplo n.º 9
0
 public IEnumerable <ProviderAndCommand> GetTwoKeyShortcuts(KeyShortcut keyShortcut)
 {
     Debug.Assert(keyShortcut.HasTwoKeyInputs);
     if (dict.TryGetValue(keyShortcut, out var list))
     {
         return(list);
     }
     return(Array.Empty <ProviderAndCommand>());
 }
 public DeveloverRepositoryItemCalcEdit() : base()
 {
     AutoHeight = false;
     Mask.UseMaskAsDisplayFormat = true;
     ShowCloseButton             = true;
     NullText        = "0";
     CloseUpKey      = new KeyShortcut(Keys.Space);
     ShowPopupShadow = true;
 }
Exemplo n.º 11
0
        public void Unregister(KeyShortcut shortcut)
        {
            var s = records.FirstOrDefault(record => record.shortcut == shortcut);

            if (s != null)
            {
                records.Remove(s);
            }
        }
Exemplo n.º 12
0
        public IEnumerable <ProviderAndCommand> GetOneKeyShortcuts(KeyInput keyInput)
        {
            var keyShortcut = new KeyShortcut(keyInput, KeyInput.Default);

            if (dict.TryGetValue(keyShortcut, out var list))
            {
                return(list);
            }
            return(Array.Empty <ProviderAndCommand>());
        }
Exemplo n.º 13
0
        /// <summary>
        /// Quando o usuário tentar salvar.
        /// </summary>
        protected override void OnSaving()
        {
            if (CsPadrao == CsPadraoSistema.Sim)
            {
                SituacaoPlanejamentoBO.DesabilitarSituacaoPlanejamentoPadraoAnterior(this.Session, this.Oid);
            }

            TxKeys = new KeyShortcut(KeyPress).ToString();

            base.OnSaving();
        }
Exemplo n.º 14
0
        int GetMinIndex(bool forceFromCaret, KeyShortcut shortcut)
        {
            if (m_lastAlignment != -1)
            {
                return(m_lastAlignment + 1);
            }

            if (forceFromCaret || shortcut.AlignFromCaret)
            {
                return(m_functions.Document.CaretColumn);
            }

            return(0);
        }
Exemplo n.º 15
0
        public void Change(KeyEventArgs e)
        {
            if (KeyShortcut.IsModifier(e.Key))
            {
                e.Handled = false;
                return;
            }
//            Console.WriteLine(">>: " + e.Key);
            var shortcut = new KeyShortcut()
            {
                Key       = e.Key,
                Modifiers = Keyboard.Modifiers
            };

            onKeysAction.Invoke(shortcut);
            TryClose();
        }
Exemplo n.º 16
0
        KeyValuePair <ActionBase, string> ReplaceUnsupportedShortcuts(ActionBase actionBase)
        {
            var shortcutToKeys = ShortcutToKeys(actionBase.Shortcut);

            if (((shortcutToKeys & Keys.Control) == Keys.Control))
            {
                var modelWebShortcut = ((IModelOptionsWebShortcut)Application.Model.Options).WebShortcut;
                if (((shortcutToKeys & Keys.N) == Keys.N))
                {
                    shortcutToKeys = ShortcutToKeys(modelWebShortcut.CtrlNReplacement);
                }
                else if (((shortcutToKeys & Keys.T) == Keys.T))
                {
                    shortcutToKeys = ShortcutToKeys(modelWebShortcut.CtrlTReplacement);
                }
            }
            return(new KeyValuePair <ActionBase, string>(actionBase, KeyShortcut.GetKeyDisplayText(shortcutToKeys).Replace(KeyShortcut.ControlKeyName, "ctrl")));
        }
Exemplo n.º 17
0
        public Message(IEnumerable <KeyPress> keys, KeyShortcut shortcut)
            : this()
        {
            var distinctProcessName = keys.Select(k => k.Process.ProcessName).Distinct();

            if (distinctProcessName.Count() != 1)
            {
                throw new InvalidOperationException("Keys are from different processes");
            }

            ProcessName = distinctProcessName.Single();
            foreach (var keyPress in keys)
            {
                AddKey(keyPress);
            }
            ShortcutName = shortcut.Name;
            IsShortcut   = true;
            CanBeMerged  = false;
        }
Exemplo n.º 18
0
        public Message(IEnumerable<KeyPress> keys, KeyShortcut shortcut)
            : this()
        {
            var allKeys = keys.ToArray();
            var distinctProcessName = allKeys.Select(k => k.Process.ProcessName)
                .Distinct()
                .ToArray();
            if (distinctProcessName.Count() != 1)
                throw new InvalidOperationException("Keys are from different processes");

            processName = distinctProcessName.Single();
            processIcon = allKeys.First().Process.ProcessIcon;
            shortcutName = shortcut.Name;
            isShortcut = true;
            canBeMerged = false;

            this.keys = new ReadOnlyCollection<KeyPress>(allKeys);

            var textSeq = CreateTextSequence(allKeys).ToList();
            if (!string.IsNullOrEmpty(shortcutName))
                textSeq.Add(string.Format(" [{0}]", shortcutName));
            textCollection = new ReadOnlyCollection<string>(textSeq);
        }
Exemplo n.º 19
0
 public Record(KeyShortcut shortcut, Action action)
 {
     this.shortcut = shortcut;
     this.action   = action;
 }
Exemplo n.º 20
0
		public CommandShortcut(KeyShortcut shortcut, CommandInfo cmd) {
			KeyShortcut = shortcut;
			CommandInfo = cmd;
		}
 public DeveloverRepositoryItemDateEdit() : base()
 {
     CloseUpKey = new KeyShortcut(Keys.Space);
 }
 public DeveloverRepositoryItemComboBox() : base()
 {
     AutoHeight      = false;
     CloseUpKey      = new KeyShortcut(Keys.Space);
     ShowPopupShadow = true;
 }
Exemplo n.º 23
0
        private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode < 0)
            {
                return(CallNextHookEx(hookId, nCode, wParam, lParam));
            }

            if (wParam == (IntPtr)WM_KEYDOWN)
            {
                var vkCode = Marshal.ReadInt32(lParam);
                var k      = KeyShortcut.FromVirtualKey(vkCode);
                var m      = Keyboard.Modifiers;
//                if (!KeyShortcut.IsModifier(k.Key))
//                {
//
//                }
                KeyDown?.Invoke(new KeyShortcut {
                    Key = k, Modifiers = m
                });
//                if (oneTimeKeys != null)
//                {
//                    if (!KeyShortcut.IsModifier(k))
//                    {
//                        oneTimeKeys.Invoke(new KeyShortcut() {Key = k, Modifiers = m});
//                        oneTimeKeys = null;
//                        Close();
//                    }
//                    return CallNextHookEx(hookId, nCode, wParam, lParam);
//                }

                foreach (var rec in records)
                {
                    if (rec.shortcut.Key == k && rec.shortcut.Modifiers == m)
                    {
                        rec.action.Invoke();
                    }
                }
                Console.WriteLine($"{vkCode}[{m}]: {k}|{Thread.CurrentThread.ManagedThreadId}");
            }

//            if ((MainWindow.StartStopKey == (Keys) vkCode) && (MainWindow.Paused == false) &&
//                (wParam == (IntPtr) WM_KEYDOWN))
//            {
//                MainWindow.Paused = true;
//                Debug.WriteLine("Paused");
//                return CallNextHookEx(hookId, nCode, wParam, lParam);
//            }
//            if (MainWindow.StartStopKey == (Keys) vkCode && MainWindow.Paused && (wParam == (IntPtr) WM_KEYDOWN))
//            {
//                MainWindow.Paused = false;
//
//                return CallNextHookEx(hookId, nCode, wParam, lParam);
//            }


//            if (wParam == (IntPtr) WM_KEYDOWN && MainWindow.Paused == false)
//            {
//                string s = ((Keys) vkCode) + ",  ";
//                //konsola(s);
//
//                KeyDown(this, kea);
//
//            }
//            else if (wParam == (IntPtr) WM_KEYUP && MainWindow.Paused == false)
//            {
//                if ((Keys) vkCode == Keys.LMenu || (Keys) vkCode == Keys.RMenu)
//                {
//                    if (MainWindow.consoleEnabled)
//                        Console.Write(((Keys) vkCode).ToString() + " ");
//                    KeyDown(this, kea);
//                }
//            }
            return(CallNextHookEx(hookId, nCode, wParam, lParam));
        }
Exemplo n.º 24
0
 public void Register(KeyShortcut shortcut, Action action)
 {
     records.Add(new Record(shortcut, action));
 }
Exemplo n.º 25
0
 IDelimiterFinder GetFinder(KeyShortcut shortcut)
 {
     return(shortcut.UseRegex ? new RegexDelimiterFinder() : new NormalDelimiterFinder());
 }