本文整理汇总了C#中MonoDevelop.Components.Commands.ActionCommand.SetDefaultHandlerTypeInfo方法的典型用法代码示例。如果您正苦于以下问题:C# ActionCommand.SetDefaultHandlerTypeInfo方法的具体用法?C# ActionCommand.SetDefaultHandlerTypeInfo怎么用?C# ActionCommand.SetDefaultHandlerTypeInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.Components.Commands.ActionCommand
的用法示例。
在下文中一共展示了ActionCommand.SetDefaultHandlerTypeInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateInstance
public override object CreateInstance ()
{
ActionType ct = ActionType.Normal;
bool isArray = false;
bool custom = false;
bool isAction = false;
foreach (string p in type.Split ('|')) {
switch (p) {
case "check":
ct = ActionType.Check;
if (isAction)
throw new InvalidOperationException ("Action type specified twice.");
isAction = true;
break;
case "radio":
ct = ActionType.Radio;
if (isAction)
throw new InvalidOperationException ("Action type specified twice.");
isAction = true;
break;
case "normal":
ct = ActionType.Normal;
if (isAction)
throw new InvalidOperationException ("Action type specified twice.");
isAction = true;
break;
case "custom":
if (widget == null)
throw new InvalidOperationException ("Widget type not specified in custom command.");
custom = true;
break;
case "array":
isArray = true;
break;
default:
throw new InvalidOperationException ("Unknown command type: " + p);
}
}
if (isAction && custom)
throw new InvalidOperationException ("Invalid command type combination: " + type);
Command cmd;
if (custom) {
if (isArray)
throw new InvalidOperationException ("Array custom commands are not allowed.");
CustomCommand ccmd = new CustomCommand ();
ccmd.Text = label;
ccmd.WidgetType = Addin.GetType (widget);
if (ccmd.WidgetType == null)
throw new InvalidOperationException ("Could not find command type '" + widget + "'.");
cmd = ccmd;
} else {
if (widget != null)
throw new InvalidOperationException ("Widget type can only be specified for custom commands.");
ActionCommand acmd = new ActionCommand ();
acmd.ActionType = ct;
acmd.CommandArray = isArray;
if (defaultHandler != null)
acmd.SetDefaultHandlerTypeInfo (Addin, defaultHandler);
cmd = acmd;
}
cmd.Id = ParseCommandId (this);
cmd.Text = StringParserService.Parse (BrandingService.BrandApplicationName (label));
if ((_description != null) && (_description.Length > 0)){
cmd.Description = BrandingService.BrandApplicationName (_description);
}
cmd.Description = cmd.Description;
if (icon != null)
cmd.Icon = GetStockId (Addin, icon);
var keyBinding = Platform.IsMac ? macShortcut : shortcut;
if (Platform.IsWindows && !string.IsNullOrEmpty (winShortcut))
keyBinding = winShortcut;
cmd.AccelKey = KeyBindingManager.CanonicalizeBinding (keyBinding);
cmd.DisabledVisible = disabledVisible;
// Assign the category of the command
CommandCategoryCodon cat = Parent as CommandCategoryCodon;
if (cat != null)
cmd.Category = cat.Name;
return cmd;
}