Пример #1
0
        private void NoteEdit_OnKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (Settings != null)
            {
                var ekey = KeyInterop.KeyFromVirtualKey((int)e.KeyCode);
                var emod = ModifierKeys.None;
                if (e.Control)
                {
                    emod |= ModifierKeys.Control;
                }
                if (e.Alt)
                {
                    emod |= ModifierKeys.Alt;
                }
                if (e.Shift)
                {
                    emod |= ModifierKeys.Shift;
                }

                foreach (var sc in Settings.Shortcuts)
                {
                    if (sc.Value.Scope == AlephShortcutScope.NoteEdit || sc.Value.Scope == AlephShortcutScope.Window)
                    {
                        var kk = (Key)sc.Value.Key;
                        var mm = (ModifierKeys)sc.Value.Modifiers;
                        if (kk == ekey && mm == (emod & mm))
                        {
                            ShortcutManager.Execute(this, sc.Key);
                            e.Handled = true;
                        }
                    }
                }
            }
        }
Пример #2
0
        private void MainWindow_OnKeyDown(object sender, KeyEventArgs e)
        {
            if (Settings != null && ReferenceEquals(e.OriginalSource, NoteEditHost))
            {
                foreach (var sc in Settings.Shortcuts)
                {
                    if (sc.Value.Scope == AlephShortcutScope.NoteEdit)
                    {
                        var kk = (Key)sc.Value.Key;
                        var mm = (ModifierKeys)sc.Value.Modifiers;
                        if (kk == e.Key && mm == (e.KeyboardDevice.Modifiers & mm))
                        {
                            ShortcutManager.Execute(this, sc.Key);
                            e.Handled = true;
                            return;
                        }
                    }
                }
            }

            if (e.Key == Key.System && ReferenceEquals(e.OriginalSource, NoteEditHost) && Settings?.SciRectSelection == true)
            {
                // Prevent ALT key removing focus of control
                e.Handled = true;
                return;
            }
        }
Пример #3
0
        private void OnMenuClick(object sender, RoutedEventArgs e)
        {
            var p = GetParent(ParentAnchor) ?? GetParent(this) ?? MainWindow.Instance;

            if (p != null)
            {
                ShortcutManager.Execute(p, AlephAction);
            }
        }
Пример #4
0
 public void SetShortcuts(MainWindow mw, List <KeyValuePair <string, ShortcutDefinition> > shortcuts)
 {
     NotesList.InputBindings.Clear();
     foreach (var sc in shortcuts.Where(s => s.Value.Scope == AlephShortcutScope.NoteList))
     {
         var sckey = sc.Key;
         var cmd   = new RelayCommand(() => ShortcutManager.Execute(mw, sckey));
         var ges   = new KeyGesture((Key)sc.Value.Key, (ModifierKeys)sc.Value.Modifiers);
         NotesList.InputBindings.Add(new InputBinding(cmd, ges));
     }
 }
Пример #5
0
        private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int WM_HOTKEY = 0x0312;

            if (msg == WM_HOTKEY)
            {
                var hkid = wParam.ToInt32();

                var hk = _hotkeys.FirstOrDefault(p => p.Item3 == hkid && p.Item2 == (((int)lParam >> 16) & 0xFFFF));
                if (hk != null)
                {
                    var curr = Application.Current;
                    if (curr != null)
                    {
                        curr.Dispatcher.BeginInvoke(new Action(() => ShortcutManager.Execute(_window, hk.Item4)));
                        handled = true;
                    }
                }
            }
            return(IntPtr.Zero);
        }
Пример #6
0
        public void UpdateShortcuts(AppSettings settings)
        {
            // ================ WINDOW ================
            InputBindings.Clear();
            foreach (var sc in settings.Shortcuts.Where(s => s.Value.Scope == AlephShortcutScope.Window))
            {
                var sckey = sc.Key;
                var cmd   = new RelayCommand(() => ShortcutManager.Execute(this, sckey));
                var ges   = new KeyGesture((Key)sc.Value.Key, (ModifierKeys)sc.Value.Modifiers);
                InputBindings.Add(new InputBinding(cmd, ges));
            }

            // ================ NOTESLIST ================
            NotesViewControl.SetShortcuts(this, settings.Shortcuts.ToList());             // via InputBindings

            // ================ GLOBAL ================
            _scManager.Clear();
            foreach (var sc in settings.Shortcuts.Where(s => s.Value.Scope == AlephShortcutScope.Global))
            {
                _scManager.Register(sc.Value.Modifiers, sc.Value.Key, sc.Key);
            }
        }
Пример #7
0
        public void SetShortcuts(MainWindow mw, List <KeyValuePair <string, ShortcutDefinition> > shortcuts)
        {
            App.Logger.Trace("NotesViewHierarchical", "SetShortcuts", string.Join("\n", shortcuts.Select(s => s.Key.PadRight(48, ' ') + s.Value.Serialize())));

            HierarchicalNotesList.InputBindings.Clear();
            foreach (var sc in shortcuts.Where(s => s.Value.Scope == AlephShortcutScope.NoteList))
            {
                var sckey = sc.Key;
                var cmd   = new RelayCommand(() => ShortcutManager.Execute(mw, sckey));
                var ges   = new KeyGesture((Key)sc.Value.Key, (ModifierKeys)sc.Value.Modifiers);
                HierarchicalNotesList.InputBindings.Add(new InputBinding(cmd, ges));
            }

            //---------

            FolderTreeView.InputBindings.Clear();
            foreach (var sc in shortcuts.Where(s => s.Value.Scope == AlephShortcutScope.FolderList))
            {
                var sckey = sc.Key;
                var cmd   = new RelayCommand(() => ShortcutManager.Execute(mw, sckey));
                var ges   = new KeyGesture((Key)sc.Value.Key, (ModifierKeys)sc.Value.Modifiers);
                FolderTreeView.InputBindings.Add(new InputBinding(cmd, ges));
            }
        }