本文整理匯總了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;
}