private void DefineCmd(Guid guidCmdSet, int cmdid, ExecuteCmdHandler executeCmd, CanExecuteCmdHandler canExecuteCmd) { var invokeHandler = executeCmd == null ? (EventHandler)null : (sender, e) => { if (_currentExplorerInfo != null) { executeCmd(_currentExplorerInfo._explorerFrame); } }; Debug.Assert(null != invokeHandler, "DefineCmd: Could not define command - null invokeHandler"); if (null != invokeHandler) { var menuCmd = DefineCommandHandler(invokeHandler, guidCmdSet, cmdid); Debug.Assert(null != menuCmd, "Unable to define OleMenuCommand for GUID " + guidCmdSet + ", cmdid " + cmdid); if (null != menuCmd) { menuCmd.BeforeQueryStatus += (sender, arguments) => { if (null != _currentExplorerInfo) { var canExecute = null != _currentExplorerInfo._explorerFrame && canExecuteCmd(_currentExplorerInfo._explorerFrame); var oleMenuCommandSender = (OleMenuCommand)sender; oleMenuCommandSender.Enabled = oleMenuCommandSender.Visible = canExecute; } }; } } }
private void DefineCmd(RoutedCommand cmdId, ExecuteCmdHandler executeCmd, CanExecuteCmdHandler canExecuteCmd) { var cmd = new CommandBinding( cmdId, delegate(object sender, ExecutedRoutedEventArgs e) { executeCmd(); e.Handled = true; }, delegate(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = canExecuteCmd(); }); CommandBindings.Add(cmd); }
private void DefineCmd(RoutedCommand cmdId, ExecuteCmdHandler executeCmd, CanExecuteCmdHandler canExecuteCmd) { var cmd = new CommandBinding( cmdId, delegate(object sender, ExecutedRoutedEventArgs e) { executeCmd(); e.Handled = true; }, delegate(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = canExecuteCmd(); }); CommandBindings.Add(cmd); }
private void DefineCmd(Guid guidCmdSet, int cmdid, ExecuteCmdHandler executeCmd, CanExecuteCmdHandler canExecuteCmd) { var invokeHandler = executeCmd == null ? (EventHandler)null : (sender, e) => { if (_currentExplorerInfo != null) { executeCmd(_currentExplorerInfo._explorerFrame); } }; Debug.Assert(null != invokeHandler, "DefineCmd: Could not define command - null invokeHandler"); if (null != invokeHandler) { var menuCmd = DefineCommandHandler(invokeHandler, guidCmdSet, cmdid); Debug.Assert(null != menuCmd, "Unable to define OleMenuCommand for GUID " + guidCmdSet + ", cmdid " + cmdid); if (null != menuCmd) { menuCmd.BeforeQueryStatus += (sender, arguments) => { if (null != _currentExplorerInfo) { var canExecute = null != _currentExplorerInfo._explorerFrame && canExecuteCmd(_currentExplorerInfo._explorerFrame); var oleMenuCommandSender = (OleMenuCommand)sender; oleMenuCommandSender.Enabled = oleMenuCommandSender.Visible = canExecute; } }; } } }