public AdvancedRelayCommand(string text, string name, Type ownerType, InputGestureCollection inputGestures) : base(text, name, ownerType, inputGestures) { }
// Constructor. public XamlCruncher() { // New filter for File Open and Save dialog boxes. strFilter = "XAML Files(*.xaml)|*.xaml|All Files(*.*)|*.*"; // Find the DockPanel and remove the TextBox from it. DockPanel dock = txtbox.Parent as DockPanel; dock.Children.Remove(txtbox); // Create a Grid with three rows and columns, all 0 pixels. Grid grid = new Grid(); dock.Children.Add(grid); for (int i = 0; i < 3; i++) { RowDefinition rowdef = new RowDefinition(); rowdef.Height = new GridLength(0); grid.RowDefinitions.Add(rowdef); ColumnDefinition coldef = new ColumnDefinition(); coldef.Width = new GridLength(0); grid.ColumnDefinitions.Add(coldef); } // Initialize the first row and column to 100*. grid.RowDefinitions[0].Height = new GridLength(100, GridUnitType.Star); grid.ColumnDefinitions[0].Width = new GridLength(100, GridUnitType.Star); // Add two GridSplitter controls to the Grid. GridSplitter split = new GridSplitter(); split.HorizontalAlignment = HorizontalAlignment.Stretch; split.VerticalAlignment = VerticalAlignment.Center; split.Height = 6; grid.Children.Add(split); Grid.SetRow(split, 1); Grid.SetColumn(split, 0); Grid.SetColumnSpan(split, 3); split = new GridSplitter(); split.HorizontalAlignment = HorizontalAlignment.Center; split.VerticalAlignment = VerticalAlignment.Stretch; split.Width = 6; grid.Children.Add(split); Grid.SetRow(split, 0); Grid.SetColumn(split, 1); Grid.SetRowSpan(split, 3); // Create a Frame for displaying XAML object. frameParent = new Frame(); frameParent.NavigationUIVisibility = NavigationUIVisibility.Hidden; grid.Children.Add(frameParent); // Put the TextBox in the Grid. txtbox.TextChanged += TextBoxOnTextChanged; grid.Children.Add(txtbox); // Case the loaded settings to XamlCruncherSettings. settingsXaml = (XamlCruncherSettings)settings; // Insert "Xaml" item on top-level menu. MenuItem itemXaml = new MenuItem(); itemXaml.Header = "_Xaml"; menu.Items.Insert(menu.Items.Count - 1, itemXaml); // Create XamlOrientationMenuItem & add to menu. itemOrientation = new XamlOrientationMenuItem(grid, txtbox, frameParent); itemOrientation.Orientation = settingsXaml.Orientation; itemXaml.Items.Add(itemOrientation); // Menu item to set tab spaces. MenuItem itemTabs = new MenuItem(); itemTabs.Header = "_Tab Spaces..."; itemTabs.Click += TabSpacesOnClick; itemXaml.Items.Add(itemTabs); // Menu item to suppress parsing. MenuItem itemNoParse = new MenuItem(); itemNoParse.Header = "_Suspend Parsing"; itemNoParse.IsCheckable = true; itemNoParse.SetBinding(MenuItem.IsCheckedProperty, "IsSuspendParsing"); itemNoParse.DataContext = this; itemXaml.Items.Add(itemNoParse); // Command to reparse. InputGestureCollection collGest = new InputGestureCollection(); collGest.Add(new KeyGesture(Key.F6)); RoutedUICommand commReparse = new RoutedUICommand("_Reparse", "Reparse", GetType(), collGest); // Menu item to reparse. MenuItem itemReparse = new MenuItem(); itemReparse.Command = commReparse; itemXaml.Items.Add(itemReparse); // Command binding to reparse. CommandBindings.Add(new CommandBinding(commReparse, ReparseOnExecuted)); // Command to show window. collGest = new InputGestureCollection(); collGest.Add(new KeyGesture(Key.F7)); RoutedUICommand commShowWin = new RoutedUICommand("Show _Window", "ShowWindow", GetType(), collGest); // Menu item to show window. MenuItem itemShowWin = new MenuItem(); itemShowWin.Command = commShowWin; itemXaml.Items.Add(itemShowWin); // Command binding to show window. CommandBindings.Add(new CommandBinding(commShowWin, ShowWindowOnExecuted, ShowWindowCanExecute)); // Menu item to save as new startup document. MenuItem itemTemplate = new MenuItem(); itemTemplate.Header = "Save as Startup _Document"; itemTemplate.Click += NewStartupOnClick; itemXaml.Items.Add(itemTemplate); // Insert Help on Help menu. MenuItem itemXamlHelp = new MenuItem(); itemXamlHelp.Header = "_Help..."; itemXamlHelp.Click += HelpOnClick; MenuItem itemHelp = (MenuItem)menu.Items[menu.Items.Count - 1]; itemHelp.Items.Insert(0, itemXamlHelp); // New StatusBar item. statusParse = new StatusBarItem(); status.Items.Insert(0, statusParse); status.Visibility = Visibility.Visible; // Install handler for unhandled exception. // Comment out this code when experimenting with new features // or changes to the program! Dispatcher.UnhandledException += DispatcherOnUnhandledException; }
public UICommand(string name, Type declaringType, InputGestureCollection inputGestures) : base(name, declaringType, inputGestures) { _text = string.Empty; }
void AddEditMenu(Menu menu) { // Top-level Edit menu. MenuItem itemEdit = new MenuItem(); itemEdit.Header = "_Edit"; menu.Items.Add(itemEdit); // Undo menu item. MenuItem itemUndo = new MenuItem(); itemUndo.Header = "_Undo"; itemUndo.Command = ApplicationCommands.Undo; itemEdit.Items.Add(itemUndo); CommandBindings.Add(new CommandBinding( ApplicationCommands.Undo, UndoOnExecute, UndoCanExecute)); // Redo menu item. MenuItem itemRedo = new MenuItem(); itemRedo.Header = "_Redo"; itemRedo.Command = ApplicationCommands.Redo; itemEdit.Items.Add(itemRedo); CommandBindings.Add(new CommandBinding( ApplicationCommands.Redo, RedoOnExecute, RedoCanExecute)); itemEdit.Items.Add(new Separator()); // Cut, Copy, Paste, and Delete menu items. MenuItem itemCut = new MenuItem(); itemCut.Header = "Cu_t"; itemCut.Command = ApplicationCommands.Cut; itemEdit.Items.Add(itemCut); CommandBindings.Add(new CommandBinding( ApplicationCommands.Cut, CutOnExecute, CutCanExecute)); MenuItem itemCopy = new MenuItem(); itemCopy.Header = "_Copy"; itemCopy.Command = ApplicationCommands.Copy; itemEdit.Items.Add(itemCopy); CommandBindings.Add(new CommandBinding( ApplicationCommands.Copy, CopyOnExecute, CutCanExecute)); MenuItem itemPaste = new MenuItem(); itemPaste.Header = "_Paste"; itemPaste.Command = ApplicationCommands.Paste; itemEdit.Items.Add(itemPaste); CommandBindings.Add(new CommandBinding( ApplicationCommands.Paste, PasteOnExecute, PasteCanExecute)); MenuItem itemDel = new MenuItem(); itemDel.Header = "De_lete"; itemDel.Command = ApplicationCommands.Delete; itemEdit.Items.Add(itemDel); CommandBindings.Add(new CommandBinding( ApplicationCommands.Delete, DeleteOnExecute, CutCanExecute)); itemEdit.Items.Add(new Separator()); // Separate method adds Find, FindNext, and Replace. AddFindMenuItems(itemEdit); itemEdit.Items.Add(new Separator()); // Select All menu item. MenuItem itemAll = new MenuItem(); itemAll.Header = "Select _All"; itemAll.Command = ApplicationCommands.SelectAll; itemEdit.Items.Add(itemAll); CommandBindings.Add(new CommandBinding( ApplicationCommands.SelectAll, SelectAllOnExecute)); // The Time/Date item requires a custom RoutedUICommand. InputGestureCollection coll = new InputGestureCollection(); coll.Add(new KeyGesture(Key.F5)); RoutedUICommand commTimeDate = new RoutedUICommand("Time/_Date", "TimeDate", GetType(), coll); MenuItem itemDate = new MenuItem(); itemDate.Command = commTimeDate; itemEdit.Items.Add(itemDate); CommandBindings.Add( new CommandBinding(commTimeDate, TimeDateOnExecute)); }
public LocalizedRoutedCommand(string name, Type ownerType, InputGestureCollection inputGestures) : base(name, ownerType, inputGestures) { }
static StackHashCommands() { // Exit command InputGestureCollection exitInputs = new InputGestureCollection(); exitInputs.Add(new KeyGesture(Key.F4, ModifierKeys.Alt)); ExitCommand = new RoutedUICommand(Properties.Resources.Command_Exit, "Exit", typeof(StackHashCommands), exitInputs); SyncCommand = new RoutedUICommand(Properties.Resources.Command_Sync, "Sync", typeof(StackHashCommands)); SyncProductCommand = new RoutedUICommand(Properties.Resources.Command_SyncProduct, "SyncProduct", typeof(StackHashCommands)); CancelSyncCommand = new RoutedUICommand(Properties.Resources.Command_CancelSync, "CancelSync", typeof(StackHashCommands)); ProfileManagerCommand = new RoutedUICommand(Properties.Resources.Command_ProfileManager, "ProfileManager", typeof(StackHashCommands)); SearchCommand = new RoutedUICommand(Properties.Resources.Command_Search, "Search", typeof(StackHashCommands)); ClearSearchCommand = new RoutedUICommand(Properties.Resources.Command_ClearSearch, "ClearSearch", typeof(StackHashCommands)); BuildSearchCommand = new RoutedUICommand(Properties.Resources.Command_BuildSearch, "BuildSearch", typeof(StackHashCommands)); ResyncCommand = new RoutedUICommand(Properties.Resources.Command_Resync, "Resync", typeof(StackHashCommands)); ResyncProductCommand = new RoutedUICommand(Properties.Resources.Command_ResyncProduct, "ResyncProduct", typeof(StackHashCommands)); ScriptManagerCommand = new RoutedUICommand(Properties.Resources.Command_ScriptManager, "ScriptManager", typeof(StackHashCommands)); AboutCommand = new RoutedUICommand(Properties.Resources.Command_About, "About", typeof(StackHashCommands)); InputGestureCollection debugInputs = new InputGestureCollection(); debugInputs.Add(new KeyGesture(Key.F5, ModifierKeys.None)); DebugCommand = new RoutedUICommand(Properties.Resources.Command_Debug, "Debug", typeof(StackHashCommands), debugInputs); OptionsCommand = new RoutedUICommand(Properties.Resources.Command_Options, "Options", typeof(StackHashCommands)); ServiceStatusCommand = new RoutedUICommand(Properties.Resources.Command_ServiceStatus, "ServiceStatus", typeof(StackHashCommands)); ShowDisabledProductsCommand = new RoutedUICommand(Properties.Resources.Command_ShowDisabledProducts, "ShowDisabledProducts", typeof(StackHashCommands)); DebugVisualStudioCommand = new RoutedUICommand(Properties.Resources.Command_DebugVisualStudio, "DebugVisualStudio", typeof(StackHashCommands)); DebugX86Command = new RoutedUICommand(Properties.Resources.Command_DebugX86, "DebugX86", typeof(StackHashCommands)); DebugX64Command = new RoutedUICommand(Properties.Resources.Command_DebugX64, "DebugX64", typeof(StackHashCommands)); InputGestureCollection refreshInputs = new InputGestureCollection(); refreshInputs.Add(new KeyGesture(Key.R, ModifierKeys.Control)); RefreshCommand = new RoutedUICommand(Properties.Resources.Command_Refresh, "Refresh", typeof(StackHashCommands), refreshInputs); ExtractCabCommand = new RoutedUICommand(Properties.Resources.Command_ExtractCab, "ExtractCab", typeof(StackHashCommands)); ExtractAllCabsCommand = new RoutedUICommand(Properties.Resources.Command_ExtractAllCabs, "ExtractAllCabs", typeof(StackHashCommands)); RunScriptCommand = new RoutedUICommand(Properties.Resources.Command_RunScript, "RunScript", typeof(StackHashCommands)); RunScriptByNameCommand = new RoutedUICommand(Properties.Resources.Command_RunScriptByName, "RunScriptByName", typeof(StackHashCommands)); DebugUsingCommand = new RoutedUICommand(Properties.Resources.Command_DebugUsing, "DebugUsing", typeof(StackHashCommands)); ExportCommand = new RoutedUICommand(Properties.Resources.Command_Export, "Export", typeof(StackHashCommands)); ExportProductListCommand = new RoutedUICommand(Properties.Resources.Command_ExportProductList, "ExportProductList", typeof(StackHashCommands)); ExportEventListCommand = new RoutedUICommand(Properties.Resources.Command_ExportEventList, "ExportEventList", typeof(StackHashCommands)); ExportEventListFullCommand = new RoutedUICommand(Properties.Resources.Command_ExportEventListFull, "ExportEventListFull", typeof(StackHashCommands)); DownloadCabCommand = new RoutedUICommand(Properties.Resources.Command_DownloadCab, "DownloadCab", typeof(StackHashCommands)); SyncReportCommand = new RoutedUICommand(Properties.Resources.Command_SyncReport, "SyncReport", typeof(StackHashCommands)); SendAllToPluginsCommand = new RoutedUICommand(Properties.Resources.Command_SendAllToPlugins, "SendAllToPlugins", typeof(StackHashCommands)); UploadMappingCommand = new RoutedUICommand(Properties.Resources.Command_UploadMappingFile, "UploadMapping", typeof(StackHashCommands)); OpenCabFolderCommand = new RoutedUICommand(Properties.Resources.Command_OpenCabFolder, "OpenCabFolder", typeof(StackHashCommands)); ShowEventsWithoutCabsCommand = new RoutedUICommand(Properties.Resources.Command_ShowEventsWithoutCabs, "ShowEventsWithoutCabs", typeof(StackHashCommands)); }
public XamlCruncher() { strFilter = "XAML files (*.xaml)|*.xaml|All files (*.*)|*.*"; // find dockpanel and delete textbox inside it DockPanel dock = txtbox.Parent as DockPanel; dock.Children.Remove(txtbox); // create Grid panel 3x3 Grid grid = new Grid(); dock.Children.Add(grid); for (int i = 0; i < 3; i++) { RowDefinition rowdef = new RowDefinition() { Height = new GridLength(0) }; grid.RowDefinitions.Add(rowdef); ColumnDefinition coldef = new ColumnDefinition() { Width = new GridLength(0) }; grid.ColumnDefinitions.Add(coldef); } grid.RowDefinitions[0].Height = new GridLength(100, GridUnitType.Star); grid.ColumnDefinitions[0].Width = new GridLength(100, GridUnitType.Star); // two splitters GridSplitter split = new GridSplitter() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Height = 6 }; grid.Children.Add(split); Grid.SetRow(split, 1); Grid.SetColumn(split, 0); Grid.SetColumnSpan(split, 3); split = new GridSplitter() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Stretch, Height = 6 }; grid.Children.Add(split); Grid.SetRow(split, 0); Grid.SetColumn(split, 1); Grid.SetColumnSpan(split, 3); // frame for showing XAML frameParent = new Frame() { NavigationUIVisibility = NavigationUIVisibility.Hidden }; grid.Children.Add(frameParent); // textbox txtbox.TextChanged += TextboxOnTextChanged; grid.Children.Add(txtbox); // move settings to XamlCruncherSettings settingsXaml = (XamlCruncherSettings)settings; MenuItem itemXaml = new MenuItem() { Header = "_Xaml" }; menu.Items.Insert(menu.Items.Count - 1, itemXaml); // create XamlOrientationMenuItem itemOrientation = new XamlOrientationMenuItem(grid, txtbox, frameParent); itemOrientation.Orientation = settingsXaml.Orientation; itemXaml.Items.Add(itemOrientation); // menuItem for tabs MenuItem itemTabs = new MenuItem() { Header = "_Tab spaces..." }; itemTabs.Click += TabSpacesOnClick; itemXaml.Items.Add(itemTabs); // menuItem for stopping parsing MenuItem itemNoParse = new MenuItem() { Header = "_Suspend Parsing", IsChecked = true }; itemNoParse.SetBinding(MenuItem.IsCheckedProperty, "IsSuspendParsing"); itemNoParse.DataContext = this; itemXaml.Items.Add(itemNoParse); // command for continue parsing InputGestureCollection collGest = new InputGestureCollection(); collGest.Add(new KeyGesture(Key.F6)); RoutedUICommand commReparse = new RoutedUICommand( "_Reparse", "Reparse", GetType(), collGest); // menuItem for reparse MenuItem itemReparse = new MenuItem() { Command = commReparse }; itemXaml.Items.Add(itemReparse); CommandBindings.Add(new CommandBinding(commReparse, ReparseOnExecuted)); // command for show window collGest = new InputGestureCollection(); collGest.Add(new KeyGesture(Key.F7)); RoutedUICommand commShowWin = new RoutedUICommand( "Show _Window", "ShowWindow", GetType(), collGest); // menuItem for showing window MenuItem itemShowWin = new MenuItem() { Command = commShowWin }; itemXaml.Items.Add(itemShowWin); CommandBindings.Add(new CommandBinding( commShowWin, ShowWindowOnExecuted, ShowWindowCanExecute)); // menuItem for saving current content to a new document MenuItem itemTemplate = new MenuItem() { Header = "Save as Startup _Document" }; itemTemplate.Click += NewStartupOnClick; itemXaml.Items.Add(itemTemplate); // help menuItem MenuItem itemXamlHelp = new MenuItem() { Header = "_Help..." }; itemXamlHelp.Click += HelpOnClick; MenuItem itemHelp = (MenuItem)menu.Items[menu.Items.Count - 1]; itemHelp.Items.Insert(0, itemXamlHelp); // new StatusBar statusParse = new StatusBarItem(); status.Items.Insert(0, statusParse); status.Visibility = Visibility.Visible; // handler for exceptions. Comment this line when experimentating! Dispatcher.UnhandledException += DispatcherOnUnhandledException; }
internal static void AddGesturesFromResourceStrings(string keyGestures, string displayStrings, InputGestureCollection gestures) { while (!string.IsNullOrEmpty(keyGestures)) { string str; string str2; int index = keyGestures.IndexOf(";", StringComparison.Ordinal); if (index >= 0) { str2 = keyGestures.Substring(0, index); keyGestures = keyGestures.Substring(index + 1); } else { str2 = keyGestures; keyGestures = string.Empty; } index = displayStrings.IndexOf(";", StringComparison.Ordinal); if (index >= 0) { str = displayStrings.Substring(0, index); displayStrings = displayStrings.Substring(index + 1); } else { str = displayStrings; displayStrings = string.Empty; } var inputGesture = CreateFromResourceStrings(str2, str); if (inputGesture != null) { gestures.Add(inputGesture); } } }
/// <summary> /// Define custom commands and their key gestures /// </summary> static AppCommand() { InputGestureCollection inputs = null; // Initialize the exit command inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.F4, ModifierKeys.Alt, "Alt+F4")); AppCommand.exit = new RoutedUICommand("Exit", "Exit", typeof(AppCommand), inputs); // Execute file open command (without user interaction) inputs = new InputGestureCollection(); AppCommand.loadFile = new RoutedUICommand("Open ...", "LoadFile", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); AppCommand.saveAll = new RoutedUICommand("Save All ...", "SaveAll", typeof(AppCommand), inputs); // Initialize pin command (to set or unset a pin in MRU and re-sort list accordingly) inputs = new InputGestureCollection(); AppCommand.pinUnpin = new RoutedUICommand("Pin or Unpin", "Pin", typeof(AppCommand), inputs); // Execute add recent files list etnry pin command (to add another MRU entry into the list) inputs = new InputGestureCollection(); AppCommand.addMruEntry = new RoutedUICommand("Add Entry", "AddEntry", typeof(AppCommand), inputs); // Execute remove pin command (remove a pin from a recent files list entry) inputs = new InputGestureCollection(); AppCommand.removeMruEntry = new RoutedUICommand("Remove Entry", "RemoveEntry", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.F4, ModifierKeys.Control, "Ctrl+F4")); inputs.Add(new KeyGesture(Key.W, ModifierKeys.Control, "Ctrl+W")); AppCommand.closeFile = new RoutedUICommand("Close", "Close", typeof(AppCommand), inputs); // Initialize the viewTheme command inputs = new InputGestureCollection(); ////inputs.Add(new KeyGesture(Key.F4, ModifierKeys.Alt, "Alt+F4")); AppCommand.viewTheme = new RoutedUICommand("View Theme", "ViewTheme", typeof(AppCommand), inputs); #region Text Edit Commands /*** inputs = new InputGestureCollection(); * inputs.Add(new KeyGesture(Key.C, ModifierKeys.Control, "Ctrl+C")); * AppCommand.copyItem = new RoutedUICommand("Copy", "Copy", typeof(AppCommand), inputs); * * inputs = new InputGestureCollection(); * inputs.Add(new KeyGesture(Key.X, ModifierKeys.Control, "Ctrl+X")); * AppCommand.cutItem = new RoutedUICommand("Cut", "Cut", typeof(AppCommand), inputs); * * inputs = new InputGestureCollection(); * inputs.Add(new KeyGesture(Key.V, ModifierKeys.Control, "Ctrl+V")); * AppCommand.pasteItem = new RoutedUICommand("Paste", "Paste", typeof(AppCommand), inputs); * * inputs = new InputGestureCollection(); * ////inputs.Add(new KeyGesture(Key.X, ModifierKeys.Control, "Ctrl+X")); * AppCommand.deleteItem = new RoutedUICommand("Delete", "Delete", typeof(AppCommand), inputs); ***/ inputs = new InputGestureCollection(); // Toggle state command ////inputs.Add(new KeyGesture(Key.X, ModifierKeys.Control, "Ctrl+X")); AppCommand.wordWrap = new RoutedUICommand("Switch word-wrap document display mode on/off", "WordWrap", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); // Toggle state command ////inputs.Add(new KeyGesture(Key.X, ModifierKeys.Control, "Ctrl+X")); AppCommand.showLineNumbers = new RoutedUICommand("Show a line number for each line in a document", "ShowLineNumbers", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); // Toggle state command ////inputs.Add(new KeyGesture(Key.X, ModifierKeys.Control, "Ctrl+X")); AppCommand.showEndOfLine = new RoutedUICommand("Highlight the end of each line in document", "ShowEndOfLine", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); // Toggle state command AppCommand.showTabs = new RoutedUICommand("Highlight tabulator characters with a special character in a document", "ShowTabs", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); // Toggle state command AppCommand.showSpaces = new RoutedUICommand("Highlight spaces with a special character in a document", "ShowSpaces", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); // Goto Line n in the current document inputs.Add(new KeyGesture(Key.A, ModifierKeys.Control, "Ctrl + A")); AppCommand.selectAll = new RoutedUICommand("Select all items in a document", "SelectAll", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); // Goto Line n in the current document inputs.Add(new KeyGesture(Key.G, ModifierKeys.Control, "Ctrl + G")); AppCommand.gotoLine = new RoutedUICommand("Go to a specific line in a document", "GotoLine", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); // Goto Line n in the current document inputs.Add(new KeyGesture(Key.F, ModifierKeys.Control, "Ctrl + F")); AppCommand.findText = new RoutedUICommand("Find specific text in a document", "FindText", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); // Goto Line n in the current document inputs.Add(new KeyGesture(Key.F3, ModifierKeys.None, "F3")); AppCommand.findNextText = new RoutedUICommand("Find next occurrance of specific text in a document", "FindNextText", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); // Goto Line n in the current document inputs.Add(new KeyGesture(Key.F3, ModifierKeys.Shift, "Shift+F3")); AppCommand.findPreviousText = new RoutedUICommand("Find previous occurrance of specific text in a document", "FindNextText", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); // Goto Line n in the current document inputs.Add(new KeyGesture(Key.H, ModifierKeys.Control, "Ctrl + H")); AppCommand.replaceText = new RoutedUICommand("Find and replace a specific text in a document", "FindReplaceText", typeof(AppCommand), inputs); #endregion Text Edit Commands inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.F5, ModifierKeys.None, "F5")); AppCommand.runScript = new RoutedUICommand("Run", "RunScript", typeof(AppCommand), inputs); }
/// <summary> /// Creates a new command that can always execute. /// </summary> /// <param name="execute">The execution logic.</param> static CustomCommands() { InputGestureCollection inputs = null; inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.Q, ModifierKeys.Control, "Ctrl+Q")); cancelJobs = new RoutedUICommand("Cmd_CancelJobs", "Cmd_CancelJobs", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.M, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+M")); manageItem = new RoutedUICommand("Cmd_ManageItem", "Cmd_ManageItem", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.Delete, ModifierKeys.None, "Del")); deleteChildItem = new RoutedUICommand("Cmd_DeleteChildItem", "Cmd_DeleteChildItem", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.N, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+N")); newChildItem = new RoutedUICommand("Cmd_NewChildItem", "Cmd_NewChildItem", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.O, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+O")); openOutputSolution = new RoutedUICommand("Cmd_OpenOutputSolution", "Cmd_OpenOutputSolution", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.U, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+U")); updateOutputSolution = new RoutedUICommand("Cmd_UpdateOutputSolution", "Cmd_UpdateOutputSolution", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.C, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+C")); compileSolution = new RoutedUICommand("Cmd_CompileSolution", "Cmd_CompileSolution", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.A, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+A")); saveAs = new RoutedUICommand("Cmd_SaveAs", "Cmd_SaveAs", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+S")); saveAll = new RoutedUICommand("Cmd_SaveAll", "Cmd_SaveAll", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.E, ModifierKeys.Control, "Ctrl+E")); update = new RoutedUICommand("Cmd_Update", "Cmd_Update", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.X, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+X")); close = new RoutedUICommand("Cmd_Close", "Cmd_Close", typeof(CustomCommands), inputs); explicitOpen = new RoutedUICommand("Cmd_ExplicitOpen", "Cmd_ExplicitOpen", typeof(CustomCommands)); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.T, ModifierKeys.Control, "Ctrl+T")); closeTab = new RoutedUICommand("Cmd_CloseTab", "Cmd_CloseTab", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.T, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+T")); closeOtherTabs = new RoutedUICommand("Cmd_CloseOtherTabs", "Cmd_CloseOtherTabs", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.Z, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+Z")); nextTab = new RoutedUICommand("Cmd_NextTab", "Cmd_NextTab", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.X, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+X")); nextInnerTab = new RoutedUICommand("Cmd_NextInnerTab", "Cmd_NextInnerTab", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.A, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+A")); pasteTextTags = new RoutedUICommand("Cmd_PasteTextTags", "Cmd_PasteTextTags", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.D, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+D")); pasteSplitTextTags = new RoutedUICommand("Cmd_PasteSplitTextTags", "Cmd_PasteSplitTextTags", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.Q, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+Q")); pasteEvaluationTags = new RoutedUICommand("Cmd_PasteEvaluationTags", "Cmd_PasteEvaluationTags", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.W, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+W")); pastePropertyTags = new RoutedUICommand("Cmd_PastePropertyTags", "Cmd_PastePropertyTags", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+S")); pasteOutputTags = new RoutedUICommand("Cmd_PasteOutputTags", "Cmd_PasteOutputTags", typeof(CustomCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.X, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+X")); clearText = new RoutedUICommand("Cmd_ClearText", "Cmd_ClearText", typeof(CustomCommands), inputs); }
static DialCommands() { InputGestureCollection inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.NumPad1, ModifierKeys.None, "1")); DialNum1 = new RoutedUICommand("1", "DialNum1", typeof(DialCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.NumPad2, ModifierKeys.None, "2")); DialNum2 = new RoutedUICommand("2", "DialNum2", typeof(DialCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.NumPad3, ModifierKeys.None, "3")); DialNum3 = new RoutedUICommand("3", "DialNum3", typeof(DialCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.NumPad4, ModifierKeys.None, "4")); DialNum4 = new RoutedUICommand("4", "DialNum3", typeof(DialCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.NumPad5, ModifierKeys.None, "5")); DialNum5 = new RoutedUICommand("5", "DialNum5", typeof(DialCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.NumPad6, ModifierKeys.None, "6")); DialNum6 = new RoutedUICommand("6", "DialNum6", typeof(DialCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.NumPad7, ModifierKeys.None, "7")); DialNum7 = new RoutedUICommand("7", "DialNum7", typeof(DialCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.NumPad8, ModifierKeys.None, "8")); DialNum8 = new RoutedUICommand("8", "DialNum8", typeof(DialCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.NumPad9, ModifierKeys.None, "9")); DialNum9 = new RoutedUICommand("9", "DialNum9", typeof(DialCommands), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.NumPad0, ModifierKeys.None, "0")); DialNum0 = new RoutedUICommand("0", "DialNum0", typeof(DialCommands), inputs); //inputs = new InputGestureCollection(); //inputs.Add(new KeyGesture(Key.Back, ModifierKeys.None, "←")); //DialBackSpace = new RoutedUICommand("←", "DialBackSpace", typeof(DialCommands), inputs); //inputs = new InputGestureCollection(); //inputs.Add(new KeyGesture(Key.D8, ModifierKeys.Shift, "*")); //DialAsterisk = new RoutedUICommand("*", "DialAsterisk", typeof(DialCommands), inputs); //inputs = new InputGestureCollection(); //inputs.Add(new KeyGesture(Key.D3, ModifierKeys.Shift, "#")); //DialSharp = new RoutedUICommand("#", "DialSharp", typeof(DialCommands), inputs); //inputs = new InputGestureCollection(); //inputs.Add(new KeyGesture(Key.Delete, ModifierKeys.None, "CLR")); //DialClear = new RoutedUICommand("CLR", "DialClear", typeof(DialCommands), inputs); //inputs = new InputGestureCollection(); //inputs.Add(new KeyGesture(Key.Q, ModifierKeys.Alt, "Hangup")); //DialHangup = new RoutedUICommand("Hangup", "DialHangup", typeof(DialCommands), inputs); }
void AddEditMenu(Menu menu) { // top level Edit menu MenuItem itemEdit = new MenuItem() { Header = "_Edit" }; menu.Items.Add(itemEdit); // Undo command MenuItem itemUndo = new MenuItem() { Header = "_Undo", Command = ApplicationCommands.Undo }; itemEdit.Items.Add(itemUndo); CommandBindings.Add( new CommandBinding( ApplicationCommands.Undo, UndoOnExecute, UndoCanExecute)); // Redo command MenuItem itemRedo = new MenuItem() { Header = "_Redo", Command = ApplicationCommands.Redo }; itemEdit.Items.Add(itemRedo); CommandBindings.Add( new CommandBinding( ApplicationCommands.Redo, RedoOnExecute, RedoCanExecute)); itemEdit.Items.Add(new Separator()); // commands Cut, Copy, Paste, Delete MenuItem itemCut = new MenuItem() { Header = "Cu_t", Command = ApplicationCommands.Cut }; itemEdit.Items.Add(itemCut); CommandBindings.Add( new CommandBinding( ApplicationCommands.Cut, CutOnExecute, CutCanExecute)); MenuItem itemCopy = new MenuItem() { Header = "_Copy", Command = ApplicationCommands.Copy }; itemEdit.Items.Add(itemCopy); CommandBindings.Add( new CommandBinding( ApplicationCommands.Copy, CopyOnExecute, CutCanExecute)); MenuItem itemPaste = new MenuItem() { Header = "_Paste", Command = ApplicationCommands.Paste }; itemEdit.Items.Add(itemPaste); CommandBindings.Add( new CommandBinding( ApplicationCommands.Paste, PasteOnExecute, PasteCanExecute)); MenuItem itemDel = new MenuItem() { Header = "De_lete", Command = ApplicationCommands.Delete }; itemEdit.Items.Add(itemDel); CommandBindings.Add( new CommandBinding( ApplicationCommands.Delete, DeleteOnExecute, CutCanExecute)); itemEdit.Items.Add(new Separator()); // commands Find, FindNext, Replace AddFindMenuItems(itemEdit); itemEdit.Items.Add(new Separator()); // command Select All MenuItem itemAll = new MenuItem() { Header = "Select _All", Command = ApplicationCommands.SelectAll }; itemEdit.Items.Add(itemAll); CommandBindings.Add( new CommandBinding( ApplicationCommands.SelectAll, SelectAllOnExecute)); // commands Time/Date InputGestureCollection col = new InputGestureCollection(); col.Add(new KeyGesture(Key.F5)); RoutedUICommand commTimeDate = new RoutedUICommand("Time/_Date", "TimeDate", GetType(), col); MenuItem itemDate = new MenuItem() { Command = commTimeDate }; itemEdit.Items.Add(itemDate); CommandBindings.Add( new CommandBinding(commTimeDate, TimeDateOnExecute)); }
public PreviewWindowModel(IEnumerable <PreviewResult> results) { PreviewResults = results; Title = Resources.WindowTitle_PreviewChanges; CopyGestures = ApplicationCommands.Copy.InputGestures; }
static MainWindowCommands() { // Menu file // new original InputGestureCollection newOriginalInputs = new InputGestureCollection(); newOriginalInputs.Add(new KeyGesture(Key.N, ModifierKeys.Control)); NewOriginalCommand = new RoutedUICommand("New original", "NewOriginal", typeof(MainWindowCommands), newOriginalInputs); // new translation InputGestureCollection newTranslationInputs = new InputGestureCollection(); newTranslationInputs.Add(new KeyGesture(Key.N, ModifierKeys.Control | ModifierKeys.Shift)); NewTranslationCommand = new RoutedUICommand("New translation", "NewTranslation", typeof(MainWindowCommands), newTranslationInputs); // open project InputGestureCollection openProjectInputs = new InputGestureCollection(); openProjectInputs.Add(new KeyGesture(Key.P, ModifierKeys.Control)); OpenProjectCommand = new RoutedUICommand("Open project", "OpenProject", typeof(MainWindowCommands), openProjectInputs); // open original InputGestureCollection openOriginalInputs = new InputGestureCollection(); openOriginalInputs.Add(new KeyGesture(Key.O, ModifierKeys.Control)); OpenOriginalCommand = new RoutedUICommand("Open original", "OpenOriginal", typeof(MainWindowCommands), openOriginalInputs); // open translation InputGestureCollection openTranslationInputs = new InputGestureCollection(); openTranslationInputs.Add(new KeyGesture(Key.O, ModifierKeys.Control | ModifierKeys.Shift)); OpenTranslationCommand = new RoutedUICommand("Open translation", "OpenTranslation", typeof(MainWindowCommands), openTranslationInputs); // save project InputGestureCollection saveProjectInputs = new InputGestureCollection(); saveProjectInputs.Add(new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Alt)); SaveProjectCommand = new RoutedUICommand("Save project", "SaveProject", typeof(MainWindowCommands), saveProjectInputs); // save original InputGestureCollection saveOriginalInputs = new InputGestureCollection(); saveOriginalInputs.Add(new KeyGesture(Key.S, ModifierKeys.Control)); SaveOriginalCommand = new RoutedUICommand("Save original", "SaveOriginal", typeof(MainWindowCommands), saveOriginalInputs); // save translation InputGestureCollection saveTranslationInputs = new InputGestureCollection(); saveTranslationInputs.Add(new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Shift)); SaveTranslationCommand = new RoutedUICommand("Save translation", "SaveTranslation", typeof(MainWindowCommands), saveTranslationInputs); //save as project SaveAsProjectCommand = new RoutedUICommand("Save As project", "SaveAsProject", typeof(MainWindowCommands)); // save original SaveAsOriginalCommand = new RoutedUICommand("Save As original", "SaveAsOriginal", typeof(MainWindowCommands)); // save translation SaveAsTranslationCommand = new RoutedUICommand("Save As translation", "SaveAsTranslation", typeof(MainWindowCommands)); // close CloseCommand = new RoutedUICommand("Close", "Close", typeof(MainWindowCommands)); // exit InputGestureCollection exitInputs = new InputGestureCollection(); exitInputs.Add(new KeyGesture(Key.F4, ModifierKeys.Alt)); ExitCommand = new RoutedUICommand("Exit application", "ExitApplication", typeof(MainWindowCommands), exitInputs); // Menu Video // open video InputGestureCollection openVideoInputs = new InputGestureCollection(); openVideoInputs.Add(new KeyGesture(Key.P, ModifierKeys.Alt)); OpenVideoCommand = new RoutedUICommand("Open video", "OpenVideo", typeof(MainWindowCommands), openVideoInputs); // close video InputGestureCollection closeVideoInputs = new InputGestureCollection(); closeVideoInputs.Add(new KeyGesture(Key.P, ModifierKeys.Alt | ModifierKeys.Shift)); CloseVideoCommand = new RoutedUICommand("Close video", "CloseVideo", typeof(MainWindowCommands), closeVideoInputs); // play/pause video InputGestureCollection VideoPlayInputs = new InputGestureCollection(); VideoPlayInputs.Add(new KeyGesture(Key.Space, ModifierKeys.Control)); VideoPlayCommand = new RoutedUICommand("Play Video", "PlayVideo", typeof(MainWindowCommands), VideoPlayInputs); // stop video InputGestureCollection VideoStopInputs = new InputGestureCollection(); VideoStopInputs.Add(new KeyGesture(Key.Back, ModifierKeys.Control)); VideoStopCommand = new RoutedUICommand("Stop Video", "StopVideo", typeof(MainWindowCommands), VideoStopInputs); // skip more backward InputGestureCollection VideoMoreBackwardInputs = new InputGestureCollection(); VideoMoreBackwardInputs.Add(new KeyGesture(Key.Left, ModifierKeys.Alt | ModifierKeys.Shift)); VideoMoreBackwardCommand = new RoutedUICommand("Skip more backward", "SkipMoreBackward", typeof(MainWindowCommands), VideoMoreBackwardInputs); // skip backaward InputGestureCollection VideoBackwardInputs = new InputGestureCollection(); VideoBackwardInputs.Add(new KeyGesture(Key.Left, ModifierKeys.Alt)); VideoBackwardCommand = new RoutedUICommand("Skip backward", "SkipBackward", typeof(MainWindowCommands), VideoBackwardInputs); // skip forward InputGestureCollection VideoForwardInputs = new InputGestureCollection(); VideoForwardInputs.Add(new KeyGesture(Key.Right, ModifierKeys.Alt)); VideoForwardCommand = new RoutedUICommand("Skip forward", "SkipForward", typeof(MainWindowCommands), VideoForwardInputs); // skip more forward InputGestureCollection VideoMoreForwardInputs = new InputGestureCollection(); VideoMoreForwardInputs.Add(new KeyGesture(Key.Right, ModifierKeys.Alt | ModifierKeys.Shift)); VideoMoreForwardCommand = new RoutedUICommand("Skip more forward", "SkipMoreForward", typeof(MainWindowCommands), VideoMoreForwardInputs); // skip to previous subtitle InputGestureCollection VideoPreviousSubtitleInputs = new InputGestureCollection(); VideoPreviousSubtitleInputs.Add(new KeyGesture(Key.Left, ModifierKeys.Control)); VideoPreviousSubtitleCommand = new RoutedUICommand("Skip to previous subtitle", "SkipPreviousSubtitle", typeof(MainWindowCommands), VideoPreviousSubtitleInputs); // skip to next subtitle InputGestureCollection VideoNextSubtitleInputs = new InputGestureCollection(); VideoNextSubtitleInputs.Add(new KeyGesture(Key.Right, ModifierKeys.Control)); VideoNextSubtitleCommand = new RoutedUICommand("Skip to next subtitle", "SkipNextSubtitle", typeof(MainWindowCommands), VideoNextSubtitleInputs); }
static UICommands() { InputGestureCollection inputKeys; inputKeys = new InputGestureCollection { new KeyGesture(Key.L, ModifierKeys.Control, "Ctrl+L") }; _loadDrive = new RoutedUICommand("Load Drive", "LoadDrive", typeof(UICommands), inputKeys); _loadSecondaryDrive = new RoutedUICommand("Load Secondary Drive", "LoadSecondaryDrive", typeof(UICommands)); _unloadSecondaryDrive = new RoutedUICommand("Unload Secondary Drive", "UnloadSecondaryDrive", typeof(UICommands)); inputKeys = new InputGestureCollection { new KeyGesture(Key.Q, ModifierKeys.Control, "Ctrl+Q"), new KeyGesture(Key.X, ModifierKeys.Alt, "Alt+X") }; _exit = new RoutedUICommand("Exit", "Exit", typeof(UICommands), inputKeys); inputKeys = new InputGestureCollection { new KeyGesture(Key.E, ModifierKeys.Control, "Ctrl+E") }; _extract = new RoutedUICommand("Extract ISO...", "Extract", typeof(UICommands), inputKeys); inputKeys = new InputGestureCollection { new KeyGesture(Key.A, ModifierKeys.Control, "Ctrl+A") }; _addToDrive = new RoutedUICommand("Add to Drive", "Add", typeof(UICommands), inputKeys); inputKeys = new InputGestureCollection { new KeyGesture(Key.D, ModifierKeys.Control, "Ctrl+D") }; _removeFromDrive = new RoutedUICommand("Delete", "Delete", typeof(UICommands), inputKeys); inputKeys = new InputGestureCollection { new KeyGesture(Key.R, ModifierKeys.Control, "Ctrl+R") }; _removeFromList = new RoutedUICommand("Remove From List", "Remove", typeof(UICommands), inputKeys); inputKeys = new InputGestureCollection { new KeyGesture(Key.B, ModifierKeys.Control, "Ctrl+B") }; _browse = new RoutedUICommand("Browse...", "Browse", typeof(UICommands), inputKeys); inputKeys = new InputGestureCollection { new KeyGesture(Key.C, ModifierKeys.Alt, "Alt+C") }; _clearList = new RoutedUICommand("Clear List", "Clear", typeof(UICommands), inputKeys); _format = new RoutedUICommand("Format", "Format", typeof(UICommands)); _renameOnDrive = new RoutedUICommand("Rename", "RenameOnDrive", typeof(UICommands)); _renameOnAdd = new RoutedUICommand("Rename", "RenameOnAdd", typeof(UICommands)); _sortByName = new RoutedUICommand("Sort By Name", "SortByName", typeof(UICommands)); _sortById = new RoutedUICommand("Sort By ID", "SortById", typeof(UICommands)); _sortBySize = new RoutedUICommand("Sort By Size", "SortBySize", typeof(UICommands)); _sortByStatus = new RoutedUICommand("Sort By Status", "SortByStatus", typeof(UICommands)); _sortByIndex = new RoutedUICommand("Sort By Index", "SortByIndex", typeof(UICommands)); _sortByFilePath = new RoutedUICommand("Sort By Path", "SortByFilePath", typeof(UICommands)); _setCoversDir = new RoutedUICommand("Set Covers Directory...", "SetCoversDir", typeof(UICommands)); _showCovers = new RoutedUICommand("Show Covers", "ShowCovers", typeof(UICommands)); _showOptions = new RoutedUICommand("Show Options", "ShowOptions", typeof(UICommands)); _makeSingleHBC = new RoutedUICommand("Make HBC Entry", "MakeSingleHBC", typeof(UICommands)); _makeAllHBC = new RoutedUICommand("Make HBC Entries for All", "MakeAllHBC", typeof(UICommands)); _createChannel = new RoutedUICommand("Create Channel(s)", "CreateChannel", typeof(UICommands)); _changeLanguage = new RoutedUICommand("Language", "ChangeLanguage", typeof(UICommands)); _checkForUpdates = new RoutedUICommand("Check for Updates", "CheckForUpdates", typeof(UICommands)); _downloadCoversFromWeb = new RoutedUICommand("Download Covers from Web", "DownloadCoversFromWeb", typeof(UICommands)); _exportListToFile = new RoutedUICommand("Export List to File", "ExportListToFile", typeof(UICommands)); _refreshDriveLists = new RoutedUICommand("Refresh Drive List", "RefreshDriveLists", typeof(UICommands)); _cloneToDrive = new RoutedUICommand("Clone", "CloneToDrive", typeof(UICommands)); _driveToDriveCopy = new RoutedUICommand("Drive-To-Drive Copy", "DriveToDriveCopy", typeof(UICommands)); inputKeys = new InputGestureCollection { new KeyGesture(Key.A, ModifierKeys.Alt, "Alt+A") }; _about = new RoutedUICommand("About...", "About", typeof(UICommands), inputKeys); }
public ObjectSelectedCommand(string name, Type ownerType, InputGestureCollection inputGestures) : base(name, ownerType, inputGestures) { }
public CmdSaveData(ICommand cmd, bool isMenuE, bool isGestureE, bool isGesNeedMenu, InputGestureCollection igc) { SetCommand(cmd); SetGestuers(igc); IsMenuEnabled = isMenuE; IsGestureEnabled = isGestureE; IsGesNeedMenu = isGesNeedMenu; }
internal static InputGestureCollection LoadDefaultGestureFromResource(byte commandId) { InputGestureCollection inputGestureCollection = new InputGestureCollection(); return(inputGestureCollection); }
static Commands() { var inputGestures = new InputGestureCollection(); inputGestures.Add(new _MultiKeyGesture(new Key[] { Key.A, Key.Q }, ModifierKeys.Control)); }
/// <summary> /// Gets the collection of default gestures for the specified command. /// </summary> private static InputGestureCollection GetInputGestures(String name) { var gestures = new InputGestureCollection(); return(gestures); }
public PNRoutedUICommand(string text, string name, Type ownerType, InputGestureCollection inputGestures) : base(text, name, ownerType, inputGestures) { }
private void Init() { this.Title = "Command the Menu"; DockPanel dock = new DockPanel(); this.Content = dock; Menu menu = new Menu(); dock.Children.Add(menu); DockPanel.SetDock(menu, Dock.Top); text = new TextBlock(); text.Text = "Sample clipboard text"; text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; text.FontSize = 32; text.TextWrapping = TextWrapping.Wrap; dock.Children.Add(text); MenuItem itemEdit = new MenuItem(); itemEdit.Header = "_Edit"; menu.Items.Add(itemEdit); MenuItem itemCut = new MenuItem(); //itemCut.Header = "Cu_t"; //如果没有设置Header属性,它会默认使用RoutedUICommand的Text的值,此处为‘剪切’,但没有前面的下划线,并且会将Ctrl+X文字加入菜单项中 itemCut.Command = ApplicationCommands.Cut; itemEdit.Items.Add(itemCut); MenuItem itemCopy = new MenuItem(); itemCopy.Header = "_Copy"; itemCopy.Command = ApplicationCommands.Copy; itemEdit.Items.Add(itemCopy); MenuItem itemPaste = new MenuItem(); itemPaste.Header = "_Paste"; itemPaste.Command = ApplicationCommands.Paste; itemEdit.Items.Add(itemPaste); MenuItem itemDelete = new MenuItem(); itemDelete.Header = "_Delete"; itemDelete.Command = ApplicationCommands.Delete; itemEdit.Items.Add(itemDelete); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, CutOnExecute, CutCopyDeletCanExecute)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, CopyOnExecute, CutCopyDeletCanExecute)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, PasteOnExecute, PasteCanExecute)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, DeleteOnExecute, CutCopyDeletCanExecute)); /* 定义一个RoutedUICommand命令 */ //由于一个RoutedUICommand可以和多个键盘手势关联,即使只想要一个手势,仍需定义一个collection集合 InputGestureCollection collGestures = new InputGestureCollection(); collGestures.Add(new KeyGesture(Key.R, ModifierKeys.Control)); //创建一个Restore命令 RoutedUICommand commRestore = new RoutedUICommand("_Restore", "Restore", GetType(), collGestures); MenuItem itemRestore = new MenuItem(); //无需设置Header属性,可以从RoutedUICommand中取出Text属性 itemRestore.Command = commRestore; itemEdit.Items.Add(itemRestore); //将命令加入到窗口的命令集合中 this.CommandBindings.Add(new CommandBinding(commRestore, RestoreOnExecute)); }
/// <summary> /// Define custom commands and their key gestures /// </summary> static AppCommand() { InputGestureCollection inputs = null; // Initialize the exit command inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.F4, ModifierKeys.Alt, "Alt+F4")); AppCommand.exit = new RoutedUICommand(Strings.CMD_App_Exit_Describtion, "Exit", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); AppCommand.about = new RoutedUICommand(Strings.CMD_APP_About_Description, "About", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); AppCommand.programSettings = new RoutedUICommand("Edit or Review your program settings", "ProgramSettings", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); AppCommand.showToolWindow = new RoutedUICommand("Hide or display toolwindow", "ShowToolWindow", typeof(AppCommand), inputs); // Execute file open command (without user interaction) inputs = new InputGestureCollection(); AppCommand.loadFile = new RoutedUICommand(Strings.CMD_APP_Open_Description, "LoadFile", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); AppCommand.saveAll = new RoutedUICommand(Strings.CMD_APP_SaveAll_Description, "SaveAll", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); AppCommand.exportUMLToImage = new RoutedUICommand(Strings.CMD_APP_ExportUMLToImage_Description, "ExportUMLToImage", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); AppCommand.exportTextToHTML = new RoutedUICommand(Strings.CMD_APP_ExportTextToHTML_Description, "ExportTextToHTML", typeof(AppCommand), inputs); // Initialize pin command (to set or unset a pin in MRU and re-sort list accordingly) inputs = new InputGestureCollection(); AppCommand.pinUnpin = new RoutedUICommand(Strings.CMD_MRU_Pin_Description, "Pin", typeof(AppCommand), inputs); // Execute add recent files list etnry pin command (to add another MRU entry into the list) inputs = new InputGestureCollection(); AppCommand.addMruEntry = new RoutedUICommand(Strings.CMD_MRU_AddEntry_Description, "AddEntry", typeof(AppCommand), inputs); // Execute remove pin command (remove a pin from a recent files list entry) inputs = new InputGestureCollection(); AppCommand.removeMruEntry = new RoutedUICommand(Strings.CMD_MRU_RemoveEntry_Description, "RemoveEntry", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.F4, ModifierKeys.Control, "Ctrl+F4")); inputs.Add(new KeyGesture(Key.W, ModifierKeys.Control, "Ctrl+W")); AppCommand.closeFile = new RoutedUICommand(Strings.CMD_APP_CloseDoc_Description, "Close", typeof(AppCommand), inputs); // Initialize the viewTheme command inputs = new InputGestureCollection(); AppCommand.viewTheme = new RoutedUICommand(Strings.CMD_APP_ViewTheme_Description, "ViewTheme", typeof(AppCommand), inputs); // Execute browse Internt URL (without user interaction) inputs = new InputGestureCollection(); AppCommand.browseURL = new RoutedUICommand(Strings.CMD_APP_OpenURL_Description, "OpenURL", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); AppCommand.showStartPage = new RoutedUICommand(Strings.CMD_APP_ShowStartPage_Description, "StartPage", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); AppCommand.toggleOptimizeWorkspace = new RoutedUICommand(Strings.CMD_APP_ToggleOptimizeWorkspace_Description, "ToggleOptimizeWorkspace", typeof(AppCommand), inputs); #region Text Edit Commands inputs = new InputGestureCollection(); AppCommand.disableHighlighting = new RoutedUICommand(Strings.CMD_TXT_DisableHighlighting_Description, "DisableHighlighting", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); // Goto Line n in the current document inputs.Add(new KeyGesture(Key.G, ModifierKeys.Control, "Ctrl+G")); AppCommand.gotoLine = new RoutedUICommand(Strings.CMD_TXT_GotoLine_Description, "GotoLine", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.F, ModifierKeys.Control, "Ctrl+F")); AppCommand.findText = new RoutedUICommand(Strings.CMD_TXT_FindNext_Description, "FindText", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.F3, ModifierKeys.None, "F3")); AppCommand.findNextText = new RoutedUICommand(Strings.CMD_TXT_FindNextText_Description, "FindNextText", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.F3, ModifierKeys.Shift, "Shift+F3")); AppCommand.findPreviousText = new RoutedUICommand(Strings.CMD_TXT_FindPreviousText_Description, "FindPreviousText", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); inputs.Add(new KeyGesture(Key.H, ModifierKeys.Control, "Ctrl+H")); AppCommand.replaceText = new RoutedUICommand(Strings.CMD_TXT_FindReplaceText_Description, "FindReplaceText", typeof(AppCommand), inputs); #endregion Text Edit Commands }
/// <summary> /// Decode the strings keyGestures and displayStrings, creating a sequence of KeyGestures. Add each /// AnyKeyGesture to the given InputGestureCollection. The two input strings typically come from a resource /// file. /// </summary> internal static void AddGesturesFromResourceStrings(string keyGestures, string displayStrings, InputGestureCollection gestures) { while (!string.IsNullOrEmpty(keyGestures)) { string keyGestureToken; string keyDisplayString; // break apart first gesture from the rest int index = keyGestures.IndexOf(MULTIPLEGESTURE_DELIMITER, StringComparison.Ordinal); if (index >= 0) // multiple gestures exist { keyGestureToken = keyGestures.Substring(0, index); keyGestures = keyGestures.Substring(index + 1); } else { keyGestureToken = keyGestures; keyGestures = string.Empty; } // similarly, break apart first display string from the rest index = displayStrings.IndexOf(MULTIPLEGESTURE_DELIMITER, StringComparison.Ordinal); if (index >= 0) // multiple display strings exist { keyDisplayString = displayStrings.Substring(0, index); displayStrings = displayStrings.Substring(index + 1); } else { keyDisplayString = displayStrings; displayStrings = string.Empty; } AnyKeyGesture keyGesture = CreateFromResourceStrings(keyGestureToken, keyDisplayString); if (keyGesture != null) { gestures.Add(keyGesture); } } }
public RoutedCommand(string name, Type declaringType, InputGestureCollection inputGestures) { _name = name; _declaringType = declaringType; _inputGestures = inputGestures; }
/// <summary> /// Define custom commands and their key gestures /// </summary> static AppCommand() { // Initialize the exit command var inputs = new InputGestureCollection { new KeyGesture(Key.F4, ModifierKeys.Alt, "Alt+F4") }; Exit = new RoutedUICommand(Strings.CMD_App_Exit_Describtion, "Exit", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); About = new RoutedUICommand(Strings.CMD_APP_About_Description, "About", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); ProgramSettings = new RoutedUICommand("Edit or Review your program settings", "ProgramSettings", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); ShowToolWindow = new RoutedUICommand("Hide or display toolwindow", "ShowToolWindow", typeof(AppCommand), inputs); // Execute file open command (without user interaction) inputs = new InputGestureCollection(); LoadFile = new RoutedUICommand(Strings.CMD_APP_Open_Description, "LoadFile", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); SaveAll = new RoutedUICommand(Strings.CMD_APP_SaveAll_Description, "SaveAll", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); ExportUmlToImage = new RoutedUICommand(Strings.CMD_APP_ExportUMLToImage_Description, "ExportUMLToImage", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); ExportTextToHtml = new RoutedUICommand(Strings.CMD_APP_ExportTextToHTML_Description, "ExportTextToHTML", typeof(AppCommand), inputs); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // MRU Commands inputs = new InputGestureCollection(); ClearAllMruItemsCommand = new RoutedUICommand(string.Empty, "Remove All MRU Entries", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); RemoveItemsOlderThanThisCommand = new RoutedUICommand(string.Empty, "Remove Entries older than this", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); MovePinnedMruItemUpCommand = new RoutedUICommand(string.Empty, "Move Up", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); MovePinnedMruItemDownCommand = new RoutedUICommand(string.Empty, "Move Down", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); PinItemCommand = new RoutedUICommand(string.Empty, "Pin to this list", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); UnPinItemCommand = new RoutedUICommand(string.Empty, "Unpin from this list", typeof(AppCommand), inputs); // Initialize pin command (to set or unset a pin in MRU and re-sort list accordingly) inputs = new InputGestureCollection(); PinUnpin = new RoutedUICommand(Strings.CMD_MRU_Pin_Description, "Pin", typeof(AppCommand), inputs); // Execute add recent files list etnry pin command (to add another MRU entry into the list) inputs = new InputGestureCollection(); AddMruEntry = new RoutedUICommand(Strings.CMD_MRU_AddEntry_Description, "AddEntry", typeof(AppCommand), inputs); // Execute remove pin command (remove a pin from a recent files list entry) inputs = new InputGestureCollection(); RemoveMruEntry = new RoutedUICommand(Strings.CMD_MRU_RemoveEntry_Description, "RemoveEntry", typeof(AppCommand), inputs); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Window Close Command inputs = new InputGestureCollection { new KeyGesture(Key.F4, ModifierKeys.Control, "Ctrl+F4"), new KeyGesture(Key.W, ModifierKeys.Control, "Ctrl+W") }; CloseFile = new RoutedUICommand(Strings.CMD_APP_CloseDoc_Description, "Close", typeof(AppCommand), inputs); // Initialize the viewTheme command inputs = new InputGestureCollection(); ViewTheme = new RoutedUICommand(Strings.CMD_APP_ViewTheme_Description, "ViewTheme", typeof(AppCommand), inputs); // Execute browse Internt URL (without user interaction) inputs = new InputGestureCollection(); BrowseUrl = new RoutedUICommand(Strings.CMD_APP_OpenURL_Description, "OpenURL", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); ShowStartPage = new RoutedUICommand(Strings.CMD_APP_ShowStartPage_Description, "StartPage", typeof(AppCommand), inputs); inputs = new InputGestureCollection(); ToggleOptimizeWorkspace = new RoutedUICommand(Strings.CMD_APP_ToggleOptimizeWorkspace_Description, "ToggleOptimizeWorkspace", typeof(AppCommand), inputs); #region Text Edit Commands inputs = new InputGestureCollection(); DisableHighlighting = new RoutedUICommand(Strings.CMD_TXT_DisableHighlighting_Description, "DisableHighlighting", typeof(AppCommand), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.G, ModifierKeys.Control, "Ctrl+G") }; // Goto Line n in the current document GotoLine = new RoutedUICommand(Strings.CMD_TXT_GotoLine_Description, "GotoLine", typeof(AppCommand), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.F, ModifierKeys.Control, "Ctrl+F") }; FindText = new RoutedUICommand(Strings.CMD_TXT_FindNext_Description, "FindText", typeof(AppCommand), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.F3, ModifierKeys.None, "F3") }; FindNextText = new RoutedUICommand(Strings.CMD_TXT_FindNextText_Description, "FindNextText", typeof(AppCommand), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.F3, ModifierKeys.Shift, "Shift+F3") }; FindPreviousText = new RoutedUICommand(Strings.CMD_TXT_FindPreviousText_Description, "FindPreviousText", typeof(AppCommand), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.H, ModifierKeys.Control, "Ctrl+H") }; ReplaceText = new RoutedUICommand(Strings.CMD_TXT_FindReplaceText_Description, "FindReplaceText", typeof(AppCommand), inputs); #endregion Text Edit Commands }
static EditorRoutedCommands() { InputGestureCollection inputs; inputs = new InputGestureCollection { new KeyGesture(Key.A, ModifierKeys.Control | ModifierKeys.Alt, "Ctrl+Alt+A") }; FoldTree = new RoutedUICommand("Fold Tree", "FoldTree", typeof(EditorRoutedCommands), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Alt, "Ctrl+Alt+S") }; UnfoldTree = new RoutedUICommand("Unfold Tree", "UnfoldTree", typeof(EditorRoutedCommands), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.G, ModifierKeys.Control, "Ctrl+G") }; FoldRegion = new RoutedUICommand("Fold Region", "FoldRegion", typeof(EditorRoutedCommands), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.U, ModifierKeys.Control, "Ctrl+U") }; UnfoldAsRegion = new RoutedUICommand("Unfold as Region", "UnfoldAsRegion", typeof(EditorRoutedCommands), inputs); GoToLineX = new RoutedUICommand("Go to line X", "GoToLineX", typeof(EditorRoutedCommands)); FixNodeAttributes = new RoutedUICommand("Fix Node Attribute", "FixNodeAttribute", typeof(EditorRoutedCommands)); inputs = new InputGestureCollection { new KeyGesture(Key.F4) }; SwitchBan = new RoutedUICommand("Ban", "Ban", typeof(EditorRoutedCommands), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.F2) }; ViewCode = new RoutedUICommand("View Code", "ViewCode", typeof(EditorRoutedCommands), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.F5) }; RunProject = new RoutedUICommand("Run Project", "RunProject", typeof(EditorRoutedCommands), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.F6) }; SCDebug = new RoutedUICommand("Debug SpellCard", "DebugSC", typeof(EditorRoutedCommands), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.F7) }; StageDebug = new RoutedUICommand("Debug Stage", "DebugStage", typeof(EditorRoutedCommands), inputs); ExportCode = new RoutedUICommand("Export Code", "ExportCode", typeof(EditorRoutedCommands)); ExportZip = new RoutedUICommand("Export Zip", "ExportZip", typeof(EditorRoutedCommands)); InsertPreset = new RoutedUICommand("Insert Preset", "InsertPreset", typeof(EditorRoutedCommands)); SavePreset = new RoutedUICommand("Save Preset", "SavePreset", typeof(EditorRoutedCommands)); RefreshPreset = new RoutedUICommand("Refresh Preset", "RefreshPreset", typeof(EditorRoutedCommands)); inputs = new InputGestureCollection { new KeyGesture(Key.Up, ModifierKeys.Alt, "Alt+Up") }; SwitchBefore = new RoutedUICommand("Switch Before State", "SwitchBefore", typeof(EditorRoutedCommands), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.Down, ModifierKeys.Alt, "Alt+Down") }; SwitchAfter = new RoutedUICommand("Switch After State", "SwitchAfter", typeof(EditorRoutedCommands), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.Right, ModifierKeys.Alt, "Alt+Right") }; SwitchChild = new RoutedUICommand("Switch Child State", "SwitchChild", typeof(EditorRoutedCommands), inputs); inputs = new InputGestureCollection { new KeyGesture(Key.Left, ModifierKeys.Alt, "Alt+Left") }; SwitchParent = new RoutedUICommand("Switch Parent State", "SwitchParent", typeof(EditorRoutedCommands), inputs); ViewFileFolder = new RoutedUICommand("View File Folder", "ViewFileFolder", typeof(EditorRoutedCommands)); ViewModFolder = new RoutedUICommand("View Mod Folder", "ViewModFolder", typeof(EditorRoutedCommands)); ViewDefinition = new RoutedUICommand("View Definition", "ViewDefination", typeof(EditorRoutedCommands)); Settings = new RoutedUICommand("Settings", "Settings", typeof(EditorRoutedCommands)); AboutNode = new RoutedUICommand("About Node", "AboutNode", typeof(EditorRoutedCommands)); AdjustProp = new RoutedUICommand("Adjust Properties", "AdjustProperties", typeof(EditorRoutedCommands)); }
public CommandTheMenu() { Title = "Command The Menu"; // Creation DockPanel DockPanel dock = new DockPanel(); Content = dock; // Creation menu in the top of window Menu menu = new Menu(); dock.Children.Add(menu); DockPanel.SetDock(menu, Dock.Top); // Creation TextBlock object, for other free space text = new TextBlock(); text.Text = "Sample clipboard text"; text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; text.FontSize = 32; //24 p text.TextWrapping = TextWrapping.Wrap; dock.Children.Add(text); // Creation menu Edit MenuItem itemEdit = new MenuItem(); itemEdit.Header = "_Edit"; menu.Items.Add(itemEdit); // Creation commands of menu Edit MenuItem itemCut = new MenuItem(); itemCut.Header = "Cu_t"; itemCut.Command = ApplicationCommands.Cut; itemEdit.Items.Add(itemCut); MenuItem itemCopy = new MenuItem(); itemCopy.Header = "_Copy"; itemCopy.Command = ApplicationCommands.Copy; itemEdit.Items.Add(itemCopy); MenuItem itemPaste = new MenuItem(); itemPaste.Header = "_Paste"; itemPaste.Command = ApplicationCommands.Paste; itemEdit.Items.Add(itemPaste); MenuItem itemDelete = new MenuItem(); itemDelete.Header = "_Delete"; itemDelete.Command = ApplicationCommands.Delete; itemEdit.Items.Add(itemDelete); // Adding a bindings of commands in main window collection CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, CutOnExecute, CutCanExecute)); CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, CopyOnExecute, CutCanExecute)); CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, PasteOnExecute, PasteCanExecute)); CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, DeleteOnExecute, CutCanExecute)); // Addon InputGestureCollection collGestures = new InputGestureCollection(); collGestures.Add(new KeyGesture(Key.R, ModifierKeys.Control)); RoutedUICommand commRestore = new RoutedUICommand("_Restore", "Restore", GetType(), collGestures); MenuItem itemRestore = new MenuItem(); itemRestore.Header = "_Restore"; itemRestore.Command = commRestore; itemEdit.Items.Add(itemRestore); CommandBindings.Add(new CommandBinding(commRestore, RestoreOnExecute)); }
public UICommand(string name, Type declaringType, InputGestureCollection inputGestures, string text) : base(name, declaringType, inputGestures) { _text = text; }
static ZoomBoxPanel() { // WPF properties PaddingProperty = DependencyProperty.Register( "Padding", typeof(Thickness), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata( new Thickness(DEFAULTLEFTRIGHTMARGIN, DEFAULTTOPBOTTOMMARGIN, DEFAULTLEFTRIGHTMARGIN, DEFAULTTOPBOTTOMMARGIN), FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, null, null), null); CenterContentProperty = DependencyProperty.Register( "CenterContent", typeof(bool), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, null, null), null); MinZoomProperty = DependencyProperty.Register( "MinZoom", typeof(double), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(1.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, PropertyChanged_Zoom, CoerceMinZoom), new ValidateValueCallback(ZoomBoxPanel.ValidateIsPositiveNonZero)); MaxZoomProperty = DependencyProperty.Register( "MaxZoom", typeof(double), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(1000.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, PropertyChanged_Zoom, CoerceMaxZoom), new ValidateValueCallback(ZoomBoxPanel.ValidateIsPositiveNonZero)); ZoomProperty = DependencyProperty.Register( "Zoom", typeof(double), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(100.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, PropertyChanged_Zoom, CoerceZoom), new ValidateValueCallback(ZoomBoxPanel.ValidateIsPositiveNonZero)); CanIncreaseZoomPropertyKey = DependencyProperty.RegisterReadOnly( "CanIncreaseZoom", typeof(bool), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(false, null, null)); CanDecreaseZoomPropertyKey = DependencyProperty.RegisterReadOnly( "CanDecreaseZoom", typeof(bool), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(false, null, null)); CanRotateKey = DependencyProperty.RegisterReadOnly( "CanRotate", typeof(bool), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(true, null, null)); ZoomIncrementProperty = DependencyProperty.Register( "ZoomIncrement", typeof(double), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(20.0), new ValidateValueCallback(ZoomBoxPanel.ValidateIsPositiveNonZero)); RotateIncrementProperty = DependencyProperty.Register( "RotateIncrement", typeof(double), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(15.0, null, CoerceRotateIncrement), new ValidateValueCallback(ZoomBoxPanel.ValidateIsPositiveNonZero)); WheelZoomDeltaProperty = DependencyProperty.Register( "WheelZoomDelta", typeof(double), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(10.0), new ValidateValueCallback(ZoomBoxPanel.ValidateIsPositiveNonZero)); WheelModeProperty = DependencyProperty.Register( "WheelMode", typeof(ZoomBoxPanel.eWheelMode), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(ZoomBoxPanel.eWheelMode.Zoom, PropertyChanged_AMode), null); ZoomModeProperty = DependencyProperty.Register( "ZoomMode", typeof(ZoomBoxPanel.eZoomMode), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(ZoomBoxPanel.eZoomMode.FitPage, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, PropertyChanged_AMode, null), null); MouseModeProperty = DependencyProperty.Register( "MouseMode", typeof(ZoomBoxPanel.eMouseMode), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(ZoomBoxPanel.eMouseMode.None, PropertyChanged_AMode), null); AnimationsProperty = DependencyProperty.Register( "Animations", typeof(bool), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(true, null), null); LockContentProperty = DependencyProperty.Register( "LockContent", typeof(bool), typeof(ZoomBoxPanel), new FrameworkPropertyMetadata(false, null), null); //----------------------------------------------------------------- // Commands CommandManager.RegisterClassCommandBinding(typeof(ZoomBoxPanel), new CommandBinding(NavigationCommands.IncreaseZoom, ExecutedEventHandler_IncreaseZoom, CanExecuteEventHandler_IfCanIncreaseZoom)); CommandManager.RegisterClassCommandBinding(typeof(ZoomBoxPanel), new CommandBinding(NavigationCommands.DecreaseZoom, ExecutedEventHandler_DecreaseZoom, CanExecuteEventHandler_IfCanDecreaseZoom)); InputGestureCollection rotateInputGestures = new InputGestureCollection(); rotateInputGestures.Add(new KeyGesture(Key.R, ModifierKeys.Control)); rotateClockwiseCommand = new RoutedUICommand("Rotate Clockwise", "RotateClockwise", typeof(ZoomBoxPanel), rotateInputGestures); CommandManager.RegisterClassCommandBinding(typeof(ZoomBoxPanel), new CommandBinding(rotateClockwiseCommand, ExecutedEventHandler_RotateClockwise, CanExecuteEventHandler_IfHasContent)); InputGestureCollection rotateCounterInputGestures = new InputGestureCollection(); rotateCounterInputGestures.Add(new KeyGesture(Key.R, ModifierKeys.Alt)); rotateCounterclockwiseCommand = new RoutedUICommand("Rotate Counterclockwise", "RotateCounterclockwise", typeof(ZoomBoxPanel), rotateCounterInputGestures); CommandManager.RegisterClassCommandBinding(typeof(ZoomBoxPanel), new CommandBinding(rotateCounterclockwiseCommand, ExecutedEventHandler_RotateCounterclockwise, CanExecuteEventHandler_IfHasContent)); InputGestureCollection rotateHomeInputGestures = new InputGestureCollection(); rotateHomeInputGestures.Add(new KeyGesture(Key.Home, ModifierKeys.None)); rotateHomeCommand = new RoutedUICommand("Rotate Home", "RotateHome", typeof(ZoomBoxPanel), rotateHomeInputGestures); CommandManager.RegisterClassCommandBinding(typeof(ZoomBoxPanel), new CommandBinding(rotateHomeCommand, ExecutedEventHandler_RotateHome, CanExecuteEventHandler_IfHasContent)); InputGestureCollection rotateReverseInputGestures = new InputGestureCollection(); rotateReverseInputGestures.Add(new KeyGesture(Key.End, ModifierKeys.None)); rotateReverseCommand = new RoutedUICommand("Rotate Reverse", "RotateReverse", typeof(ZoomBoxPanel), rotateReverseInputGestures); CommandManager.RegisterClassCommandBinding(typeof(ZoomBoxPanel), new CommandBinding(rotateReverseCommand, ExecutedEventHandler_RotateReverse, CanExecuteEventHandler_IfHasContent)); //----------------------------------------------------------------- }
internal static void AddGesturesFromResourceStrings(string keyGestures, string displayStrings, InputGestureCollection gestures) { while (!string.IsNullOrEmpty(keyGestures)) { var length1 = keyGestures.IndexOf(";", StringComparison.Ordinal); string keyGestureToken; if (length1 >= 0) { keyGestureToken = keyGestures.Substring(0, length1); keyGestures = keyGestures.Substring(length1 + 1); } else { keyGestureToken = keyGestures; keyGestures = string.Empty; } var length2 = displayStrings.IndexOf(";", StringComparison.Ordinal); string keyDisplayString; if (length2 >= 0) { keyDisplayString = displayStrings.Substring(0, length2); displayStrings = displayStrings.Substring(length2 + 1); } else { keyDisplayString = displayStrings; displayStrings = string.Empty; } var fromResourceStrings = CreateFromResourceStrings(keyGestureToken, keyDisplayString); if (fromResourceStrings != null) { gestures.Add(fromResourceStrings); } } }
static CustomCommands() { InputGestureCollection myInputGestures = new InputGestureCollection(); myInputGestures.Add(new KeyGesture(Key.L, ModifierKeys.Control)); Launch = new RoutedUICommand("Запуск", "Launch", typeof(CustomCommands), myInputGestures); }