public RelayCommandModel(RelayCommandAttribute attr, QPP.Command.ICommand command) { Command = command; Name = attr.Name; Target = attr.Target; Usage = attr.Usage; Icon = attr.Icon; VisibleIndex = attr.VisibleIndex; BeginGroup = attr.BeginGroup; if (attr.Key != System.Windows.Input.Key.None) InputGestures.Add(new System.Windows.Input.KeyGesture(attr.Key, attr.ModifierKeys)); }
/// <summary> /// /// </summary> /// <param name="baseOn">命令描述</param> public RelayCommandAttribute(RelayCommandAttribute baseOn) { Name = baseOn.Name; Usage = baseOn.Usage; Target = baseOn.Target; Icon = baseOn.Icon; Key = baseOn.Key; ModifierKeys = baseOn.ModifierKeys; BeginGroup = baseOn.BeginGroup; VisibleIndex = baseOn.VisibleIndex; }
static RelayCommandAttribute() { //SearchCommand SearchCommand = new RelayCommandAttribute("SearchCommand", CommandUsage.ToolBar | CommandUsage.KeyBinding); SearchCommand.VisibleIndex = 10; SearchCommand.Icon = "/QPP.Resources;component/Images/page_find.png"; SearchCommand.Key = Key.Q; SearchCommand.ModifierKeys = ModifierKeys.Control; //ResetFilterCommand ResetFilterCommand = new RelayCommandAttribute("ResetFilterCommand", CommandUsage.ToolBar); ResetFilterCommand.VisibleIndex = 20; ResetFilterCommand.Icon = "/QPP.Resources;component/Images/textfield_rename.png"; //CreateCommand CreateCommand = new RelayCommandAttribute("CreateCommand", CommandUsage.ToolBar | CommandUsage.KeyBinding); CreateCommand.VisibleIndex = 30; CreateCommand.Icon = "/QPP.Resources;component/Images/page_add.png"; CreateCommand.BeginGroup = true; CreateCommand.Key = Key.N; CreateCommand.ModifierKeys = ModifierKeys.Control; //DeleteSelectedCommand DeleteSelectedCommand = new RelayCommandAttribute("DeleteSelectedCommand", CommandUsage.ToolBar | CommandUsage.KeyBinding); DeleteSelectedCommand.VisibleIndex = 40; DeleteSelectedCommand.Icon = "/QPP.Resources;component/Images/page_delete.png"; DeleteSelectedCommand.Key = Key.Delete; DeleteSelectedCommand.ModifierKeys = ModifierKeys.Control; //ExportCommand ExportCommand = new RelayCommandAttribute("ExportCommand", CommandUsage.ToolBar); ExportCommand.VisibleIndex = 50; ExportCommand.Icon = "/QPP.Resources;component/Images/application_put.png"; ImportCommand = new RelayCommandAttribute("ImportCommand", CommandUsage.ToolBar); ImportCommand.VisibleIndex = 60; //CopyCommand CopyCommand = new RelayCommandAttribute("CopyCommand", CommandUsage.ToolBar | CommandUsage.KeyBinding); CopyCommand.VisibleIndex = 70; CopyCommand.Icon = "/QPP.Resources;component/Images/page_copy.png"; CopyCommand.BeginGroup = true; CopyCommand.Key = Key.D; CopyCommand.ModifierKeys = ModifierKeys.Control; //SaveCommand SaveCommand = new RelayCommandAttribute("SaveCommand", CommandUsage.ToolBar | CommandUsage.KeyBinding); SaveCommand.VisibleIndex = 80; SaveCommand.Icon = "/QPP.Resources;component/Images/save.png"; SaveCommand.BeginGroup = false; SaveCommand.Key = Key.S; SaveCommand.ModifierKeys = ModifierKeys.Control; //UndoCommand UndoCommand = new RelayCommandAttribute("UndoCommand", CommandUsage.ToolBar | CommandUsage.KeyBinding); UndoCommand.VisibleIndex = 90; UndoCommand.Icon = "/QPP.Resources;component/Images/undo.png"; UndoCommand.BeginGroup = true; UndoCommand.Key = Key.Z; UndoCommand.ModifierKeys = ModifierKeys.Control; //RedoCommand RedoCommand = new RelayCommandAttribute("RedoCommand", CommandUsage.ToolBar | CommandUsage.KeyBinding); RedoCommand.VisibleIndex = 100; RedoCommand.Icon = "/QPP.Resources;component/Images/redo.png"; RedoCommand.Key = Key.Y; RedoCommand.ModifierKeys = ModifierKeys.Control; //ApproveCommand ApproveCommand = new RelayCommandAttribute("ApproveCommand", CommandUsage.ToolBar); ApproveCommand.VisibleIndex = 110; ApproveCommand.Icon = "/QPP.Resources;component/Images/accept.png"; //DisapproveCommand DisapproveCommand = new RelayCommandAttribute("DisapproveCommand", CommandUsage.ToolBar); DisapproveCommand.VisibleIndex = 120; DisapproveCommand.Icon = "/QPP.Resources;component/Images/cancel.png"; //OpenSearchCommand OpenSearchCommand = new RelayCommandAttribute("OpenSearchCommand", CommandUsage.ToolBar); OpenSearchCommand.VisibleIndex = 140; OpenSearchCommand.Icon = "/QPP.Resources;component/Images/table_find.png"; OpenSearchCommand.BeginGroup = true; //EditCommand EditCommand = new RelayCommandAttribute("EditCommand", CommandUsage.ContextMenu); //DeleteCommand DeleteCommand = new RelayCommandAttribute("DeleteCommand", CommandUsage.ContextMenu); //BrowseBackCommand BrowseBackCommand = new RelayCommandAttribute("BrowseBackCommand", CommandUsage.KeyBinding); BrowseBackCommand.Key = Key.Left; BrowseBackCommand.ModifierKeys = ModifierKeys.Alt; //BrowseForwardCommand BrowseForwardCommand = new RelayCommandAttribute("BrowseForwardCommand", CommandUsage.KeyBinding); BrowseForwardCommand.Key = Key.Right; BrowseForwardCommand.ModifierKeys = ModifierKeys.Alt; //FirstPageCommand FirstPageCommand = new RelayCommandAttribute("FirstPageCommand", CommandUsage.KeyBinding); FirstPageCommand.Key = Key.Home; FirstPageCommand.ModifierKeys = ModifierKeys.Alt; //LastPageCommand LastPageCommand = new RelayCommandAttribute("LastPageCommand", CommandUsage.KeyBinding); LastPageCommand.Key = Key.End; LastPageCommand.ModifierKeys = ModifierKeys.Alt; //NextPageCommand NextPageCommand = new RelayCommandAttribute("NextPageCommand", CommandUsage.KeyBinding); NextPageCommand.Key = Key.PageDown; NextPageCommand.ModifierKeys = ModifierKeys.Alt; //PreviousPageCommand PreviousPageCommand = new RelayCommandAttribute("PreviousPageCommand", CommandUsage.KeyBinding); PreviousPageCommand.Key = Key.PageUp; PreviousPageCommand.ModifierKeys = ModifierKeys.Alt; //GoToPageCommand GoToPageCommand = new RelayCommandAttribute("GoToPageCommand", CommandUsage.None); //RefreshCommand RefreshCommand = new RelayCommandAttribute("RefreshCommand", CommandUsage.ToolBar | CommandUsage.KeyBinding); RefreshCommand.VisibleIndex = 130; RefreshCommand.Icon = "/QPP.Resources;component/Images/refresh.png"; RefreshCommand.Key = Key.F5; RefreshCommand.ModifierKeys = ModifierKeys.Control; //PrintCommand PrintCommand = new RelayCommandAttribute("PrintCommand", CommandUsage.ToolBar); PrintCommand.VisibleIndex = 150; PrintCommand.Icon = "/QPP.Resources;component/Images/printer.png"; //PrintPriviewCommand PrintPreviewCommand = new RelayCommandAttribute("PrintPreviewCommand", CommandUsage.ToolBar); PrintPreviewCommand.VisibleIndex = 160; PrintPreviewCommand.Icon = "/QPP.Resources;component/Images/page_print.png"; }