当前位置: 首页>>代码示例>>C#>>正文


C# ActionCommand.SetDefaultHandlerTypeInfo方法代码示例

本文整理汇总了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;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:98,代码来源:CommandCodon.cs


注:本文中的MonoDevelop.Components.Commands.ActionCommand.SetDefaultHandlerTypeInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。