本文整理汇总了C#中System.Windows.Input.CommandBinding类的典型用法代码示例。如果您正苦于以下问题:C# CommandBinding类的具体用法?C# CommandBinding怎么用?C# CommandBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandBinding类属于System.Windows.Input命名空间,在下文中一共展示了CommandBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DatasetVertexView
/// <summary>
/// Initializes a new instance of the <see cref="DatasetVertexView"/> class.
/// </summary>
/// <remarks>
/// This constructor is called internally by the WPF system because this class is part of a template
/// in the DatasetGraphView. No point in changing this constructor to take external arguments because
/// it won't work that way.
/// </remarks>
internal DatasetVertexView()
{
InitializeComponent();
// Bind the new dataset command
{
var cb = new CommandBinding(s_NewDatasetCommand, CommandNewDatasetExecuted, CommandNewDatasetCanExecute);
CommandBindings.Add(cb);
addChildDatasetButton.Command = s_NewDatasetCommand;
}
// Bind the delete dataset command
{
var cb = new CommandBinding(s_RemoveDatasetCommand, CommandDeleteDatasetExecuted, CommandDeleteDatasetCanExecute);
CommandBindings.Add(cb);
deleteDatasetButton.Command = s_RemoveDatasetCommand;
}
// Bind the activate / deactivate command
{
var cb = new CommandBinding(
s_ActivateOrDeactivateDatasetCommand,
CommandActivateDeactivateDatasetExecuted,
CommandActivateDeactivateDatasetCanExecute);
CommandBindings.Add(cb);
activateOrDeactivateDatasetButton.Command = s_ActivateOrDeactivateDatasetCommand;
}
// Bind the show detail view command
{
var cb = new CommandBinding(s_ShowDetailViewCommand, CommandShowDetailViewExecuted, CommandShowDetailViewCanExecute);
CommandBindings.Add(cb);
showDetailButton.Command = s_ShowDetailViewCommand;
}
}
示例2: MainWindow
public MainWindow ()
{
InitializeComponent ();
StatusBarText = String.Empty;
IsHlrOffPushed = false;
IsHlrOnPushed = true;
IsZoomWinEnabled = true;
#region menu operations
CommandBinding aBind_New = new CommandBinding (IECommands.New);
aBind_New.Executed += NewCommand_Executed;
CommandBindings.Add (aBind_New);
CommandBinding aBind_Close = new CommandBinding (IECommands.Close);
aBind_Close.Executed += CloseCommand_Executed;
aBind_Close.CanExecute += CloseCommand_CanExecute;
CommandBindings.Add (aBind_Close);
CommandBinding aBind_Quit = new CommandBinding (IECommands.Quit);
aBind_Quit.Executed += QuitCommand_Executed;
CommandBindings.Add (aBind_Quit);
CommandBinding aBind_About = new CommandBinding (IECommands.About);
aBind_About.Executed += AboutCommand_Executed;
CommandBindings.Add (aBind_About);
#endregion
}
示例3: TablesContextMenu
public TablesContextMenu(DatabaseMenuCommandParameters menuCommandParameters, ExplorerToolWindow parent)
{
var dcmd = new DatabaseMenuCommandsHandler(parent);
var createTableCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
dcmd.BuildTable);
var createTableMenuItem = new MenuItem
{
Header = "Build Table (beta)...",
Icon = ImageHelper.GetImageFromResource("../resources/AddTable_5632.png"),
Command = DatabaseMenuCommands.DatabaseCommand,
CommandParameter = menuCommandParameters
};
createTableMenuItem.CommandBindings.Add(createTableCommandBinding);
Items.Add(createTableMenuItem);
Items.Add(new Separator());
var refreshCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
dcmd.RefreshTables);
var refreshMenuItem = new MenuItem
{
Header = "Refresh",
Icon = ImageHelper.GetImageFromResource("../resources/refresh.png"),
Command = DatabaseMenuCommands.DatabaseCommand,
CommandParameter = menuCommandParameters
};
refreshMenuItem.CommandBindings.Add(refreshCommandBinding);
Items.Add(refreshMenuItem);
}
示例4: createCommandBindings
private void createCommandBindings()
{
CommandBinding bindNew = new CommandBinding();
CommandBinding bindOpen = new CommandBinding();
CommandBinding bindSave = new CommandBinding();
CommandBinding bindExit = new CommandBinding();
bindNew.Command = ApplicationCommands.New;
bindNew.Executed += NewGame_Executed;
bindNew.CanExecute += NewGame_CanExecute;
CommandBindings.Add(bindNew);
bindOpen.Command = ApplicationCommands.Open;
bindOpen.Executed += OpenFile_Executed;
bindOpen.CanExecute += OpenFile_CanExecute;
CommandBindings.Add(bindOpen);
bindSave.Command = ApplicationCommands.Save;
bindSave.Executed += SaveFile_Executed;
bindSave.CanExecute += SaveFile_CanExecute;
CommandBindings.Add(bindSave);
bindExit.Command = CustomCommands.Exit;
bindExit.Executed += ExitGame_Executed;
bindExit.CanExecute += ExitGame_CanExecute;
CommandBindings.Add(bindExit);
}
示例5: page_chat
public page_chat()
{
InitializeComponent();
RoutedCommand Input_SendMessage = new RoutedCommand();
RoutedCommand Input_Return = new RoutedCommand();
KeyBinding Input_SendMessage_Keybinding = new KeyBinding(Input_SendMessage, new KeyGesture(Key.Enter));
CommandBinding Input_SendMessage_Binding = new CommandBinding(Input_SendMessage, Input_SentMessage_Execute, CmdCanExecute);
KeyBinding Input_Return_Keybinding = new KeyBinding(Input_Return, new KeyGesture(Key.Enter, ModifierKeys.Control));
CommandBinding Input_Return_Binding = new CommandBinding(Input_Return, Input_Return_Execute, CmdCanExecute);
this.rtf_input.InputBindings.Add(Input_SendMessage_Keybinding);
this.rtf_input.CommandBindings.Add(Input_SendMessage_Binding);
this.rtf_input.InputBindings.Add(Input_Return_Keybinding);
this.rtf_input.CommandBindings.Add(Input_Return_Binding);
CommandBinding pasteCmdBinding = new CommandBinding(ApplicationCommands.Paste, OnPaste, OnCanExecutePaste);
this.rtf_input.CommandBindings.Add(pasteCmdBinding);
try
{
this.rtf_input.FontSize = Convert.ToDouble(ConfigManager.Instance.GetString("font_size", "12"));
this.rtf_input.FontFamily = new FontFamily(ConfigManager.Instance.GetString("font", "Segoe WP"));
this.rtf_input.Foreground = (SolidColorBrush)new BrushConverter().ConvertFromString(ConfigManager.Instance.GetString("font_color", "#000000"));
}
catch { }
this.rtf_input.AddHandler(RichTextBox.DragOverEvent, new DragEventHandler(rtf_DragOver), true);
this.rtf_input.AddHandler(RichTextBox.DropEvent, new DragEventHandler(rtf_DragDrop), true);
}
示例6: MainWindow_Loaded
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
// Creating the main panel
var mainStackPanel = new StackPanel();
AddChild(mainStackPanel);
// Button used to invoke the command
var commandButton = new Button
{
Command = ApplicationCommands.Open,
Content = "Open (KeyBindings: Ctrl-R, Ctrl-0)"
};
mainStackPanel.Children.Add(commandButton);
// Creating CommandBinding and attaching an Executed and CanExecute handler
var openCmdBinding = new CommandBinding(
ApplicationCommands.Open,
OpenCmdExecuted,
OpenCmdCanExecute);
CommandBindings.Add(openCmdBinding);
// Creating a KeyBinding between the Open command and Ctrl-R
var openCmdKeyBinding = new KeyBinding(
ApplicationCommands.Open,
Key.R,
ModifierKeys.Control);
InputBindings.Add(openCmdKeyBinding);
}
示例7: InitializeComponent
public 部門表()
{
InitializeComponent();
CommandBinding binding = new CommandBinding(ApplicationCommands.ContextMenu);
binding.Executed += ContextMenu_Executed;
this.CommandBindings.Add(binding);
}
示例8: SetF1CommandBinding
private void SetF1CommandBinding()
{
CommandBinding helpBinding = new CommandBinding(ApplicationCommands.Help);
helpBinding.CanExecute += CanHelpExecute;
helpBinding.Executed += HelpExecuted;
CommandBindings.Add(helpBinding);
}
示例9: MainWindow
public MainWindow(SessionInfo sessionInfo)
{
this.DataContext = sessionInfo;
#region Command bindings
//New command binding
CommandBinding newCommandBinding = new CommandBinding(InvoiceManagerCommands.New);
newCommandBinding.Executed += NewCommand_Executed;
newCommandBinding.CanExecute += NewCommand_CanExecute;
CommandBindings.Add(newCommandBinding);
//Edit command binding
CommandBinding editCommandBinding = new CommandBinding(InvoiceManagerCommands.Edit);
editCommandBinding.Executed += EditCommand_Executed;
editCommandBinding.CanExecute += EditCommand_CanExecute;
CommandBindings.Add(editCommandBinding);
//Delete command binding
CommandBinding deleteCommandBinding = new CommandBinding(InvoiceManagerCommands.Delete);
deleteCommandBinding.Executed += DeleteCommand_Executed;
deleteCommandBinding.CanExecute += DeleteCommand_CanExecute;
CommandBindings.Add(deleteCommandBinding);
#endregion
InitializeComponent();
App.Current.MainWindow = this;
}
示例10: MainWindow
public MainWindow()
{
SOTC_BindingErrorTracer.BindingErrorTraceListener.SetTrace();
this.InitializeComponent();
/*
// Insert code required on object creation below this point.
KeyBinding ib = new KeyBinding(
GlobalCommands.IncrementSectionNumber, new KeyGesture(Key.U, ModifierKeys.Control));
this.InputBindings.Add(ib);
*/
incrementCenterIndexCommand = new RoutedUICommand("+", "IncrementCenterIndexCommand", typeof(MainWindow));
decrementCenterIndexCommand = new RoutedUICommand("-", "DecrementCenterIndexCommand", typeof(MainWindow));
CommandBinding cb = new CommandBinding(incrementCenterIndexCommand, OnIncrementSectionNumber);
this.CommandBindings.Add(cb);
cb = new CommandBinding(decrementCenterIndexCommand, OnDecrementSectionNumber);
this.CommandBindings.Add(cb);
GlobalCommands.IncrementSectionNumber.RegisterCommand(incrementCenterIndexCommand);
GlobalCommands.IncrementSectionNumber.RegisterCommand(decrementCenterIndexCommand);
//GlobalCommands.IncrementSectionNumber.Execute(null);
OnStartup(null);
}
示例11: DateInputUC
public DateInputUC()
{
InitializeComponent();
toggleCalendarAction = new CommandBinding(ToggleCalendarAction, ToggleCalendar);
CommandBindings.Add(toggleCalendarAction);
this.AddHandler(Validation.ErrorEvent, new EventHandler<ValidationErrorEventArgs>(ValidationErrorEventHandler));
}
示例12: MessageWindowElement
public MessageWindowElement(MessageDailog dm)
: base()
{
var bindinAccept = new CommandBinding(AcceptCommand, OnAccept);
this.CommandBindings.Add(bindinAccept);
var bindingCancel = new CommandBinding(CancelCommand, OnCancel);
this.CommandBindings.Add(bindingCancel);
if (dm != null)
{
Buttons = dm.DialogButton;
Title = dm.Title;
Content = dm.Caption;
if (dm.DialogHeight != 0)
this.Height = dm.DialogHeight;
if (dm.DialogWidth != 0)
this.Height = dm.DialogWidth;
if(dm.IsSizeToContent)
this.SizeToContent = SizeToContent.WidthAndHeight;
}
CreateContainer();
}
示例13: MainWindow
// -------------------------------
// Window operations
// -------------------------------
/// <summary>
/// (Constructor) Initializes main window and sets up shortcut keys.
/// </summary>
public MainWindow()
{
InitializeComponent();
// Bind "New" command
CommandBinding cb = new CommandBinding( commandNew , new_Executed );
KeyGesture kg = new KeyGesture( Key.N , ModifierKeys.Control );
InputBinding ib = new InputBinding( commandNew , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "Open" command
cb = new CommandBinding( commandOpen , open_Executed );
kg = new KeyGesture( Key.O , ModifierKeys.Control );
ib = new InputBinding( commandOpen , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "Save" command
cb = new CommandBinding( commandSave , save_Executed );
kg = new KeyGesture( Key.S , ModifierKeys.Control );
ib = new InputBinding( commandSave , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "SaveAll" command
cb = new CommandBinding( commandSaveAll , saveAll_Executed );
kg = new KeyGesture( Key.S , ModifierKeys.Alt );
ib = new InputBinding( commandSaveAll , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "Exit" command
cb = new CommandBinding( commandExit , exit_Executed );
kg = new KeyGesture( Key.X , ModifierKeys.Control );
ib = new InputBinding( commandExit , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "Delete" command
cb = new CommandBinding( commandDelete , deleteBlock_Executed );
kg = new KeyGesture( Key.Delete );
ib = new InputBinding( commandDelete , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "Generate Mesh" command
cb = new CommandBinding( commandGenerateMesh , generateMesh_Executed );
kg = new KeyGesture( Key.F7 );
ib = new InputBinding( commandGenerateMesh , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "Run Analysis" command
cb = new CommandBinding( commandRunAnalysis , run_Executed );
kg = new KeyGesture( Key.F5 );
ib = new InputBinding( commandRunAnalysis , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
}
示例14: OnStartup
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var binding = new CommandBinding(Commands.CloseWindow, CloseWindow);
CommandManager.RegisterClassCommandBinding(typeof(Window), binding);
}
示例15: MainWindow
public MainWindow()
: base(SplashShowing)
{
Default = this;
#region initialize command bindings
SDWindow.NewCommand.Text = "New Receipt";
this.NewCommandBinding.Executed += NewReceiptCommand_Executed;
this.OptionsCommandBinding.Executed += OptionsCommand_Executed;
ReceiptSingularCommandBinding = new CommandBinding(ReceiptSingularCommand, ReceiptSingularCommand_Executed);
this.CommandBindings.Add(ReceiptSingularCommandBinding);
ReceiptTabularCommandBinding = new CommandBinding(ReceiptTabularCommand, ReceiptTabularCommand_Executed);
this.CommandBindings.Add(ReceiptTabularCommandBinding);
FeesRegisterCommandBinding = new CommandBinding(FeesRegisterCommand, FeesRegisterCommand_Executed);
this.CommandBindings.Add(FeesRegisterCommandBinding);
FeesBalancesCommandBinding = new CommandBinding(FeesBalancesCommand, FeesBalancesCommand_Executed);
this.CommandBindings.Add(FeesBalancesCommandBinding);
#endregion
try
{
InitializeComponent();
}
catch (Exception ex)
{
Errors.displayError("An error occured starting the application", ErrorCode.MainWindowConstructor, ErrorAction.Exit, ex);
}
}