Ejemplo n.º 1
0
        static EditingCommandHandler()
        {
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, OnDelete(CaretMovementType.None), CanDelete));
            AddBinding(EditingCommands.Delete, ModifierKeys.None, Key.Delete, OnDelete(CaretMovementType.CharRight));
            AddBinding(EditingCommands.DeleteNextWord, ModifierKeys.Control, Key.Delete, OnDelete(CaretMovementType.WordRight));
            AddBinding(EditingCommands.Backspace, ModifierKeys.None, Key.Back, OnDelete(CaretMovementType.Backspace));
            InputBindings.Add(TextAreaDefaultInputHandler.CreateFrozenKeyBinding(EditingCommands.Backspace, ModifierKeys.Shift, Key.Back));             // make Shift-Backspace do the same as plain backspace
            AddBinding(EditingCommands.DeletePreviousWord, ModifierKeys.Control, Key.Back, OnDelete(CaretMovementType.WordLeft));
            AddBinding(EditingCommands.EnterParagraphBreak, ModifierKeys.None, Key.Enter, OnEnter);
            AddBinding(EditingCommands.EnterLineBreak, ModifierKeys.Shift, Key.Enter, OnEnter);
            AddBinding(EditingCommands.TabForward, ModifierKeys.None, Key.Tab, OnTab);
            AddBinding(EditingCommands.TabBackward, ModifierKeys.Shift, Key.Tab, OnShiftTab);

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, OnCopy, CanCutOrCopy));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, OnCut, CanCutOrCopy));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, OnPaste, CanPaste));

            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.ToggleOverstrike, OnToggleOverstrike));
            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.DeleteLine, OnDeleteLine));

            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.RemoveLeadingWhitespace, OnRemoveLeadingWhitespace));
            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.RemoveTrailingWhitespace, OnRemoveTrailingWhitespace));
            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.ConvertToUppercase, OnConvertToUpperCase));
            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.ConvertToLowercase, OnConvertToLowerCase));
            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.ConvertToTitleCase, OnConvertToTitleCase));
            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.InvertCase, OnInvertCase));
            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.ConvertTabsToSpaces, OnConvertTabsToSpaces));
            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.ConvertSpacesToTabs, OnConvertSpacesToTabs));
            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.ConvertLeadingTabsToSpaces, OnConvertLeadingTabsToSpaces));
            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.ConvertLeadingSpacesToTabs, OnConvertLeadingSpacesToTabs));
            CommandBindings.Add(new CommandBinding(UyghurEditPPCommands.IndentSelection, OnIndentSelection));

            TextAreaDefaultInputHandler.WorkaroundWPFMemoryLeak(InputBindings);
        }
Ejemplo n.º 2
0
 static void AddBinding(ICommand command, ModifierKeys modifiers, Key key, ExecutedRoutedEventHandler handler)
 {
     CommandBindings.Add(new CommandBinding(command, handler));
     InputBindings.Add(TextAreaDefaultInputHandler.CreateFrozenKeyBinding(command, modifiers, key));
 }