//-------------------------------------------------------------- private void AddCommands() { // Add input gestures to routed commands. (Routed commands do not have a setter for InputGestures.) AvalonEditCommands.Comment.InputGestures.Add(new MultiKeyGesture(new[] { Key.K, Key.C }, ModifierKeys.Control)); AvalonEditCommands.Uncomment.InputGestures.Add(new MultiKeyGesture(new[] { Key.K, Key.U }, ModifierKeys.Control)); AvalonEditCommands.ConvertToUppercase.InputGestures.Add(new KeyGesture(Key.U, ModifierKeys.Control | ModifierKeys.Shift)); AvalonEditCommands.ConvertToLowercase.InputGestures.Add(new KeyGesture(Key.U, ModifierKeys.Control)); // Add CommandItems. _syntaxHighlightingItem = new SyntaxHighlightingItem(this); CommandItems.AddRange(new ICommandItem[] { new RoutedCommandItem(AvalonEditCommands.PasteMultiple) { Category = CommandCategories.Edit, Text = "Paste multiple", ToolTip = "Show the most recent entries in the clipboard." }, new DelegateCommandItem("GoToLine", new DelegateCommand(GoToLineNumber, CanGoToLineNumber)) { Category = CommandCategories.Edit, InputGestures = new InputGestureCollection { new KeyGesture(Key.G, ModifierKeys.Control) }, Text = "_Go to...", ToolTip = "Go to line" }, new RoutedCommandItem(AvalonEditCommands.RemoveLeadingWhitespace) { Category = CommandCategories.Edit, Text = "Remove leading white space" }, new RoutedCommandItem(AvalonEditCommands.RemoveTrailingWhitespace) { Category = CommandCategories.Edit, Text = "Remove trailing white space" }, new RoutedCommandItem(AvalonEditCommands.ConvertToUppercase) { Category = CommandCategories.Edit, Text = "Make upper case", ToolTip = "Converts the selected text to upper case." }, new RoutedCommandItem(AvalonEditCommands.ConvertToLowercase) { Category = CommandCategories.Edit, Text = "Make lower case", ToolTip = "Converts the selected text to lower case." }, new RoutedCommandItem(AvalonEditCommands.ConvertToTitleCase) { Category = CommandCategories.Edit, Text = "Make title case", ToolTip = "Converts the selected text to title case." }, new RoutedCommandItem(AvalonEditCommands.InvertCase) { Category = CommandCategories.Edit, Text = "Invert case", ToolTip = "Inverts the case in the selected text." }, new RoutedCommandItem(AvalonEditCommands.ConvertTabsToSpaces) { Category = CommandCategories.Edit, Text = "Tabs to spaces" }, new RoutedCommandItem(AvalonEditCommands.ConvertSpacesToTabs) { Category = CommandCategories.Edit, Text = "Spaces to tabs" }, new RoutedCommandItem(AvalonEditCommands.ConvertLeadingTabsToSpaces) { Category = CommandCategories.Edit, Text = "Leading tabs to spaces" }, new RoutedCommandItem(AvalonEditCommands.ConvertLeadingSpacesToTabs) { Category = CommandCategories.Edit, Text = "Leading spaces to tabs" }, new RoutedCommandItem(AvalonEditCommands.IndentSelection) { Category = CommandCategories.Edit, Text = "Indent selection" }, new RoutedCommandItem(AvalonEditCommands.Comment) { Category = CommandCategories.Edit, Icon = MultiColorGlyphs.Comment, Text = "Comment selection", ToolTip = "Comment out selected lines." }, new RoutedCommandItem(AvalonEditCommands.Uncomment) { Category = CommandCategories.Edit, Icon = MultiColorGlyphs.Uncomment, Text = "Uncomment selection", ToolTip = "Uncomment selected lines." }, new RoutedCommandItem(AvalonEditCommands.ToggleFold) { Category = CommandCategories.Edit, Text = "Fold/unfold", ToolTip = "Toggle the current fold." }, new RoutedCommandItem(AvalonEditCommands.ToggleAllFolds) { Category = CommandCategories.Edit, Text = "Fold/unfold All", ToolTip = "Toggle all folds (toggle outlining)." }, _syntaxHighlightingItem, }); }
//-------------------------------------------------------------- #region Methods //-------------------------------------------------------------- private void AddCommands() { // Add input gestures to routed commands. (Routed commands do not have a setter for InputGestures.) AvalonEditCommands.Comment.InputGestures.Add(new MultiKeyGesture(new[] { Key.K, Key.C }, ModifierKeys.Control)); AvalonEditCommands.Uncomment.InputGestures.Add(new MultiKeyGesture(new[] { Key.K, Key.U }, ModifierKeys.Control)); AvalonEditCommands.ConvertToUppercase.InputGestures.Add(new KeyGesture(Key.U, ModifierKeys.Control | ModifierKeys.Shift)); AvalonEditCommands.ConvertToLowercase.InputGestures.Add(new KeyGesture(Key.U, ModifierKeys.Control)); // Add CommandItems. _syntaxHighlightingItem = new SyntaxHighlightingItem(this); CommandItems.AddRange(new ICommandItem[] { new RoutedCommandItem(AvalonEditCommands.PasteMultiple) { Category = CommandCategories.Edit, Text = "Paste multiple", ToolTip = "Show the most recent entries in the clipboard." }, new DelegateCommandItem("GoToLine", new DelegateCommand(GoToLineNumber, CanGoToLineNumber)) { Category = CommandCategories.Edit, InputGestures = new InputGestureCollection { new KeyGesture(Key.G, ModifierKeys.Control) }, Text = "_Go to...", ToolTip = "Go to line" }, new RoutedCommandItem(AvalonEditCommands.RemoveLeadingWhitespace) { Category = CommandCategories.Edit, Text = "Remove leading white space" }, new RoutedCommandItem(AvalonEditCommands.RemoveTrailingWhitespace) { Category = CommandCategories.Edit, Text = "Remove trailing white space" }, new RoutedCommandItem(AvalonEditCommands.ConvertToUppercase) { Category = CommandCategories.Edit, Text = "Make upper case", ToolTip = "Converts the selected text to upper case." }, new RoutedCommandItem(AvalonEditCommands.ConvertToLowercase) { Category = CommandCategories.Edit, Text = "Make lower case", ToolTip = "Converts the selected text to lower case." }, new RoutedCommandItem(AvalonEditCommands.ConvertToTitleCase) { Category = CommandCategories.Edit, Text = "Make title case", ToolTip = "Converts the selected text to title case." }, new RoutedCommandItem(AvalonEditCommands.InvertCase) { Category = CommandCategories.Edit, Text = "Invert case", ToolTip = "Inverts the case in the selected text." }, new RoutedCommandItem(AvalonEditCommands.ConvertTabsToSpaces) { Category = CommandCategories.Edit, Text = "Tabs to spaces" }, new RoutedCommandItem(AvalonEditCommands.ConvertSpacesToTabs) { Category = CommandCategories.Edit, Text = "Spaces to tabs" }, new RoutedCommandItem(AvalonEditCommands.ConvertLeadingTabsToSpaces) { Category = CommandCategories.Edit, Text = "Leading tabs to spaces" }, new RoutedCommandItem(AvalonEditCommands.ConvertLeadingSpacesToTabs) { Category = CommandCategories.Edit, Text = "Leading spaces to tabs" }, new RoutedCommandItem(AvalonEditCommands.IndentSelection) { Category = CommandCategories.Edit, Text = "Indent selection" }, new RoutedCommandItem(AvalonEditCommands.Comment) { Category = CommandCategories.Edit, Icon = MultiColorGlyphs.Comment, Text = "Comment selection", ToolTip = "Comment out selected lines." }, new RoutedCommandItem(AvalonEditCommands.Uncomment) { Category = CommandCategories.Edit, Icon = MultiColorGlyphs.Uncomment, Text = "Uncomment selection", ToolTip = "Uncomment selected lines." }, new RoutedCommandItem(AvalonEditCommands.ToggleFold) { Category = CommandCategories.Edit, Text = "Fold/unfold", ToolTip = "Toggle the current fold." }, new RoutedCommandItem(AvalonEditCommands.ToggleAllFolds) { Category = CommandCategories.Edit, Text = "Fold/unfold All", ToolTip = "Toggle all folds (toggle outlining)." }, _syntaxHighlightingItem, }); }
private void RemoveCommands() { CommandItems.Clear(); _syntaxHighlightingItem = null; }