本文整理汇总了C#中CommandSource类的典型用法代码示例。如果您正苦于以下问题:C# CommandSource类的具体用法?C# CommandSource怎么用?C# CommandSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandSource类属于命名空间,在下文中一共展示了CommandSource类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MDSubMenuItem
public MDSubMenuItem (CommandManager manager, CommandEntrySet ces, CommandSource commandSource = CommandSource.MainMenu, object initialCommandTarget = null)
{
this.ces = ces;
this.Submenu = new MDMenu (manager, ces, commandSource, initialCommandTarget);
this.Title = this.Submenu.Title;
}
示例2: TitleMenuItem
public TitleMenuItem (MonoDevelop.Components.Commands.CommandManager manager, CommandEntry entry, CommandInfo commandArrayInfo = null, CommandSource commandSource = CommandSource.MainMenu, object initialCommandTarget = null, Menu menu = null)
{
this.manager = manager;
this.initialCommandTarget = initialCommandTarget;
this.commandSource = commandSource;
this.commandArrayInfo = commandArrayInfo;
this.menu = menu;
menuEntry = entry;
menuEntrySet = entry as CommandEntrySet;
menuLinkEntry = entry as LinkCommandEntry;
if (commandArrayInfo != null) {
Header = commandArrayInfo.Text;
var commandArrayInfoSet = commandArrayInfo as CommandInfoSet;
if (commandArrayInfoSet != null) {
foreach (var item in commandArrayInfoSet.CommandInfos) {
if (item.IsArraySeparator)
Items.Add (new Separator { UseLayoutRounding = true, });
else
Items.Add (new TitleMenuItem (manager, entry, item, commandSource, initialCommandTarget, menu));
}
}
}
if (menuEntrySet != null) {
Header = menuEntrySet.Name;
foreach (CommandEntry item in menuEntrySet) {
if (item.CommandId == MonoDevelop.Components.Commands.Command.Separator) {
Items.Add (new Separator { UseLayoutRounding = true, });
} else
Items.Add (new TitleMenuItem (manager, item, menu: menu));
}
} else if (menuLinkEntry != null) {
Header = menuLinkEntry.Text;
Click += OnMenuLinkClicked;
} else if (entry != null) {
actionCommand = manager.GetCommand (menuEntry.CommandId) as ActionCommand;
if (actionCommand == null)
return;
IsCheckable = actionCommand.ActionType == ActionType.Check;
// FIXME: Use proper keybinding text.
if (actionCommand.KeyBinding != null)
InputGestureText = actionCommand.KeyBinding.ToString ();
if (!actionCommand.Icon.IsNull)
Icon = new Image { Source = actionCommand.Icon.GetImageSource (Xwt.IconSize.Small) };
Click += OnMenuClicked;
}
Height = SystemParameters.CaptionHeight;
UseLayoutRounding = true;
}
示例3: MDMenuItem
public MDMenuItem (CommandManager manager, CommandEntry ce, ActionCommand command, CommandSource commandSource, object initialCommandTarget)
{
this.ce = ce;
this.manager = manager;
this.initialCommandTarget = initialCommandTarget;
this.commandSource = commandSource;
isArrayItem = command.CommandArray;
Target = this;
Action = ActionSel;
}
示例4: MDMenu
public MDMenu (CommandManager manager, CommandEntrySet ces, CommandSource commandSource, object initialCommandTarget)
{
this.WeakDelegate = this;
AutoEnablesItems = false;
Title = (ces.Name ?? "").Replace ("_", "");
foreach (CommandEntry ce in ces) {
if (ce.CommandId == Command.Separator) {
AddItem (NSMenuItem.SeparatorItem);
if (!string.IsNullOrEmpty (ce.OverrideLabel))
AddItem (new MDMenuHeaderItem (ce.OverrideLabel));
continue;
}
if (string.Equals (ce.CommandId as string, servicesID, StringComparison.Ordinal)) {
AddItem (new MDServicesMenuItem ());
continue;
}
var subset = ce as CommandEntrySet;
if (subset != null) {
AddItem (new MDSubMenuItem (manager, subset, commandSource, initialCommandTarget));
continue;
}
var lce = ce as LinkCommandEntry;
if (lce != null) {
AddItem (new MDLinkMenuItem (lce));
continue;
}
Command cmd = manager.GetCommand (ce.CommandId);
if (cmd == null) {
LoggingService.LogError ("MacMenu: '{0}' maps to null command", ce.CommandId);
continue;
}
if (cmd is CustomCommand) {
LoggingService.LogWarning ("MacMenu: '{0}' is unsupported custom-rendered command' '", ce.CommandId);
continue;
}
var acmd = cmd as ActionCommand;
if (acmd == null) {
LoggingService.LogWarning ("MacMenu: '{0}' has unknown command type '{1}'", cmd.GetType (), ce.CommandId);
continue;
}
AddItem (new MDMenuItem (manager, ce, acmd, commandSource, initialCommandTarget));
}
}
示例5: frmMain
/// <summary>
/// Contructor
/// </summary>
public frmMain()
{
InitializeComponent();
selectedOperation = CommandSource.workWithFolders;
_commandParams = new CommandParameters();
_executorParams = new ExecutorParameters();
_executorParams.Source = selectedOperation;
_commands = new CommandsCollection();
_formats.Add("По умолчанию");
_formats.Add("Unicode");
_formats.Add("Big Endian Unicode");
_formats.Add("ASCII");
_formats.Add("UTF32");
_formats.Add("UTF7");
_formats.Add("UTF8");
}
示例6: DispatchCommand
/// <summary>
/// Dispatches a command.
/// </summary>
/// <returns>
/// True if a handler for the command was found
/// </returns>
/// <param name='commandId'>
/// Identifier of the command
/// </param>
/// <param name='dataItem'>
/// Data item for the command. It must be one of the data items obtained by calling GetCommandInfo.
/// </param>
/// <param name='initialTarget'>
/// Initial command route target. The command handler will start looking for command handlers in this object.
/// </param>
/// <param name='source'>
/// What is causing the command to be dispatched
/// </param>
public bool DispatchCommand (object commandId, object dataItem, object initialTarget, CommandSource source)
{
RegisterUserInteraction ();
if (guiLock > 0)
return false;
commandId = CommandManager.ToCommandId (commandId);
List<HandlerCallback> handlers = new List<HandlerCallback> ();
ActionCommand cmd = null;
try {
cmd = GetActionCommand (commandId);
if (cmd == null)
return false;
CurrentCommand = cmd;
CommandTargetRoute targetRoute = new CommandTargetRoute (initialTarget);
object cmdTarget = GetFirstCommandTarget (targetRoute);
CommandInfo info = new CommandInfo (cmd);
while (cmdTarget != null)
{
HandlerTypeInfo typeInfo = GetTypeHandlerInfo (cmdTarget);
bool bypass = false;
CommandUpdaterInfo cui = typeInfo.GetCommandUpdater (commandId);
if (cui != null) {
if (cmd.CommandArray) {
// Make sure that the option is still active
info.ArrayInfo = new CommandArrayInfo (info);
cui.Run (cmdTarget, info.ArrayInfo);
if (!info.ArrayInfo.Bypass) {
if (info.ArrayInfo.FindCommandInfo (dataItem) == null)
return false;
} else
bypass = true;
} else {
info.Bypass = false;
cui.Run (cmdTarget, info);
bypass = info.Bypass;
if (!bypass && (!info.Enabled || !info.Visible))
return false;
}
}
if (!bypass) {
CommandHandlerInfo chi = typeInfo.GetCommandHandler (commandId);
if (chi != null) {
object localTarget = cmdTarget;
if (cmd.CommandArray) {
handlers.Add (delegate {
OnCommandActivating (commandId, info, dataItem, localTarget, source);
chi.Run (localTarget, cmd, dataItem);
OnCommandActivated (commandId, info, dataItem, localTarget, source);
});
}
else {
handlers.Add (delegate {
OnCommandActivating (commandId, info, dataItem, localTarget, source);
chi.Run (localTarget, cmd);
OnCommandActivated (commandId, info, dataItem, localTarget, source);
});
}
handlerFoundInMulticast = true;
cmdTarget = NextMulticastTarget (targetRoute);
if (cmdTarget == null)
break;
else
continue;
}
}
cmdTarget = GetNextCommandTarget (targetRoute, cmdTarget);
}
if (handlers.Count > 0) {
foreach (HandlerCallback c in handlers)
c ();
UpdateToolbars ();
return true;
//.........这里部分代码省略.........
示例7: CommandActivationEventArgs
public CommandActivationEventArgs (object commandId, CommandInfo commandInfo, object dataItem, object target, CommandSource source)
{
this.CommandId = commandId;
this.CommandInfo = commandInfo;
this.Target = target;
this.Source = source;
this.DataItem = dataItem;
}
示例8: OnCommandActivated
void OnCommandActivated (object commandId, CommandInfo commandInfo, object dataItem, object target, CommandSource source)
{
if (CommandActivated != null)
CommandActivated (this, new CommandActivationEventArgs (commandId, commandInfo, dataItem, target, source));
}
示例9: DefaultDispatchCommand
bool DefaultDispatchCommand (ActionCommand cmd, CommandInfo info, object dataItem, object target, CommandSource source)
{
DefaultUpdateCommandInfo (cmd, info);
if (cmd.CommandArray) {
//if (info.ArrayInfo.FindCommandInfo (dataItem) == null)
// return false;
}
else if (!info.Enabled || !info.Visible)
return false;
if (cmd.DefaultHandler == null) {
if (cmd.DefaultHandlerType == null)
return false;
cmd.DefaultHandler = (CommandHandler) Activator.CreateInstance (cmd.DefaultHandlerType);
}
OnCommandActivating (cmd.Id, info, dataItem, target, source);
cmd.DefaultHandler.InternalRun (dataItem);
OnCommandActivated (cmd.Id, info, dataItem, target, source);
return true;
}
示例10: ExecuteCommand
public void ExecuteCommand (object cmd, object dataItem = null, CommandSource source = CommandSource.Unknown)
{
Gtk.Application.Invoke (delegate {
AutoTestService.CommandManager.DispatchCommand (cmd, dataItem, null, source);
});
}
示例11: OnCommandActivating
void OnCommandActivating (object commandId, CommandInfo commandInfo, object target, CommandSource source)
{
if (CommandActivating != null)
CommandActivating (this, new CommandActivationEventArgs (commandId, commandInfo, target, source));
}
示例12: MDMenu
public MDMenu (CommandManager manager, CommandEntrySet ces, CommandSource commandSource, object initialCommandTarget) : this (manager, ces, commandSource, initialCommandTarget, null)
{
}
示例13: CommandActivationEventArgs
public CommandActivationEventArgs (object commandId, CommandInfo commandInfo, object dataItem, object target, CommandSource source, TimeSpan executionTime = default(TimeSpan))
{
this.CommandId = commandId;
this.CommandInfo = commandInfo;
this.Target = target;
this.Source = source;
this.DataItem = dataItem;
this.ExecutionTime = executionTime;
}
示例14: ExecutorParameters
/// <summary>
/// Constructor
/// </summary>
public ExecutorParameters()
{
_source = CommandSource.workWithFolders;
_format = Encoding.Default;
}