Beispiel #1
0
 protected virtual bool OnKey(KeyEventArgs args)
 {
     if (args.IsDown && !args.IsRepeat && (!this.IsButtonDown && !this.IsControlDown) && (!this.IsAltDown && !this.IsSpaceDown))
     {
         if (args.Key == Key.F2)
         {
             return(this.ToolBehaviorContext.View.TryEnterTextEditMode(false));
         }
         foreach (Tool tool in this.ToolBehaviorContext.ToolManager.Tools)
         {
             if (args.Key == tool.Key && tool.IsEnabled && tool.IsVisible)
             {
                 this.ToolBehaviorContext.ToolManager.ActiveTool = tool;
                 args.Handled = true;
                 CultureManager.ClearDeadKeyBuffer();
                 return(true);
             }
         }
         foreach (ToolCategoryGroup toolCategoryGroup in this.ToolBehaviorContext.ToolManager.ToolCategoryGroups)
         {
             if (args.Key == toolCategoryGroup.Key && toolCategoryGroup.Activate(this.ToolBehaviorContext.ToolManager))
             {
                 args.Handled = true;
                 CultureManager.ClearDeadKeyBuffer();
                 return(true);
             }
         }
     }
     return(false);
 }
Beispiel #2
0
        private void ApplicationWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (this.commandBarService == null || this.commandBarService.HasOpenSubmenu)
            {
                return;
            }
            if (!e.Handled && Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.F4)
            {
                this.commandService.Execute("Application_FileClose", CommandInvocationSource.AcceleratorKey);
                e.Handled = true;
            }
            if (!e.Handled)
            {
                this.HandleSwitchToDialog(e);
            }
            if (e.Handled)
            {
                return;
            }
            Key          shortcutKey = e.Key;
            ModifierKeys modifiers   = Keyboard.Modifiers;

            if (shortcutKey == Key.Back)
            {
                shortcutKey = Key.Delete;
            }
            if (shortcutKey == Key.Add)
            {
                shortcutKey = Key.OemPlus;
            }
            if (shortcutKey == Key.Subtract)
            {
                shortcutKey = Key.OemMinus;
            }
            if (shortcutKey == Key.System && (modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
            {
                shortcutKey = e.SystemKey;
            }
            if (!this.commandService.HandleShortcut(shortcutKey, modifiers))
            {
                return;
            }
            e.Handled = true;
            CultureManager.ClearDeadKeyBuffer();
        }