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


C# Commands.CommandTargetRoute类代码示例

本文整理汇总了C#中MonoDevelop.Components.Commands.CommandTargetRoute的典型用法代码示例。如果您正苦于以下问题:C# CommandTargetRoute类的具体用法?C# CommandTargetRoute怎么用?C# CommandTargetRoute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CommandTargetRoute类属于MonoDevelop.Components.Commands命名空间,在下文中一共展示了CommandTargetRoute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CommandResult

 public CommandResult(Command cmd, CommandInfo ci, CommandTargetRoute route, string match, string matchedString, int rank)
     : base(match, matchedString, rank)
 {
     this.ci = ci;
     command = cmd;
     this.route = route;
 }
开发者ID:Kalnor,项目名称:monodevelop,代码行数:7,代码来源:SearchResult.cs

示例2:

		void ICommandUserItem.Update (CommandTargetRoute targetRoute)
		{
			if (commandManager != null) {
				CommandInfo cinfo = commandManager.GetCommandInfo (commandId, targetRoute);
				this.initialTarget = targetRoute.InitialTarget;
				Update (cinfo);
			}
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:8,代码来源:CommandToolButton.cs

示例3:

		void ICommandUserItem.Update (CommandTargetRoute targetChain)
		{
			if (commandManager != null && !isArrayItem) {
				CommandInfo cinfo = commandManager.GetCommandInfo (commandId, targetChain);
				this.initialTarget = targetChain.InitialTarget;
				Update (cinfo);
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:8,代码来源:CommandCheckMenuItem.cs

示例4: AllResults

		void AllResults (WorkerResult lastResult, WorkerResult newResult, CancellationToken token)
		{
			CommandTargetRoute route = new CommandTargetRoute (MainToolbar.LastCommandTarget);
			newResult.filteredCommands = new List<Command> ();
			bool startsWithLastFilter = lastResult != null && lastResult.pattern != null && newResult.pattern.StartsWith (lastResult.pattern) && lastResult.filteredCommands != null;
			IEnumerable<Command> allCommands = startsWithLastFilter ? lastResult.filteredCommands : IdeApp.CommandService.GetCommands ();
			foreach (Command cmd in allCommands) {
				token.ThrowIfCancellationRequested ();
				SearchResult curResult = newResult.CheckCommand (cmd, route);
				if (curResult != null) {
					newResult.filteredCommands.Add (cmd);
					newResult.results.AddResult (curResult);
				}
			}
		}
开发者ID:ConorMurph1991,项目名称:monodevelop,代码行数:15,代码来源:CommandSearchCategory.cs

示例5: CommandTargetRoute

		void ICommandBar.Update (object defaultTarget)
		{
			if (!Visible)
				return;
			
			if (initialCommandTarget != null)
				defaultTarget = initialCommandTarget;

			CommandTargetRoute targetRoute = new CommandTargetRoute (defaultTarget);
			foreach (Gtk.Widget item in Children) {
				if (item is ICommandUserItem)
					((ICommandUserItem)item).Update (targetRoute);
				else
					item.Show ();
			}
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:16,代码来源:CommandToolbar.cs

示例6: GetResults

		public override Task GetResults (ISearchResultCallback searchResultCallback, SearchPopupSearchPattern pattern, CancellationToken token)
		{
			return Task.Run (delegate {
				try {
					if (pattern.HasLineNumber)
						return;
					CommandTargetRoute route = new CommandTargetRoute (MainToolbar.LastCommandTarget);
					var matcher = StringMatcher.GetMatcher (pattern.Pattern, false);

					foreach (var cmdTuple in allCommands) {
						token.ThrowIfCancellationRequested ();
						var cmd = cmdTuple.Item1;
						var matchString = cmdTuple.Item2;
						int rank;

						if (matcher.CalcMatchRank (matchString, out rank))
							searchResultCallback.ReportResult (new CommandResult (cmd, null, route, pattern.Pattern, matchString, rank));
					}
				} catch (OperationCanceledException) {
				}
			});
		}
开发者ID:gAdrev,项目名称:monodevelop,代码行数:22,代码来源:CommandSearchCategory.cs

示例7: GetNextCommandTarget

		object GetNextCommandTarget (CommandTargetRoute targetRoute, object cmdTarget)
		{
			if (cmdTarget is IMultiCastCommandRouter) 
				cmdTarget = new MultiCastDelegator (this, (IMultiCastCommandRouter)cmdTarget, targetRoute);
			
			if (cmdTarget is ICommandDelegatorRouter) {
				object oldCmdTarget = cmdTarget;
				cmdTarget = ((ICommandDelegatorRouter)oldCmdTarget).GetDelegatedCommandTarget ();
				if (cmdTarget != null)
					delegatorStack.Push (oldCmdTarget);
				else
					cmdTarget = ((ICommandDelegatorRouter)oldCmdTarget).GetNextCommandTarget ();
			}
			else if (cmdTarget is ICommandRouter)
				cmdTarget = ((ICommandRouter)cmdTarget).GetNextCommandTarget ();
			else if (cmdTarget is Gtk.Widget)
				cmdTarget = ((Gtk.Widget)cmdTarget).Parent;
			else
				cmdTarget = null;
			
			if (cmdTarget == null || !visitedTargets.Add (cmdTarget)) {
				if (delegatorStack.Count > 0) {
					ICommandDelegatorRouter del = (ICommandDelegatorRouter) delegatorStack.Pop ();
					cmdTarget = del.GetNextCommandTarget ();
					if (cmdTarget == CommandManager.CommandRouteTerminator)
						return null;
					if (cmdTarget != null)
						return cmdTarget;
				}
				return globalHandlerChain;
			} else
				return cmdTarget;
		}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:33,代码来源:CommandManager.cs

示例8: MultiCastDelegator

		public MultiCastDelegator (CommandManager manager, IMultiCastCommandRouter mcr, CommandTargetRoute route)
		{
			this.manager = manager;
			enumerator = mcr.GetCommandTargets ().GetEnumerator ();
			this.route = route;
		}
开发者ID:aBothe,项目名称:monodevelop,代码行数:6,代码来源:CommandManager.cs

示例9: GetNextCommandTarget

		object GetNextCommandTarget (CommandTargetRoute targetRoute, object cmdTarget, bool ignoreDelegator = false)
		{
			if (cmdTarget is IMultiCastCommandRouter) 
				cmdTarget = new MultiCastDelegator (this, (IMultiCastCommandRouter)cmdTarget, targetRoute);

			if (!ignoreDelegator && cmdTarget is ICommandDelegator) {
				if (cmdTarget is ICommandDelegatorRouter)
					throw new InvalidOperationException ("A type can't implement both ICommandDelegator and ICommandDelegatorRouter");
				object oldCmdTarget = cmdTarget;
				cmdTarget = ((ICommandDelegator)oldCmdTarget).GetDelegatedCommandTarget ();
				if (cmdTarget != null)
					delegatorStack.Push (oldCmdTarget);
				else
					cmdTarget = GetNextCommandTarget (targetRoute, oldCmdTarget, true);
			}
			else if (cmdTarget is ICommandDelegatorRouter) {
				object oldCmdTarget = cmdTarget;
				cmdTarget = ((ICommandDelegatorRouter)oldCmdTarget).GetDelegatedCommandTarget ();
				if (cmdTarget != null)
					delegatorStack.Push (oldCmdTarget);
				else
					cmdTarget = ((ICommandDelegatorRouter)oldCmdTarget).GetNextCommandTarget ();
			}
			else if (cmdTarget is ICommandRouter)
				cmdTarget = ((ICommandRouter)cmdTarget).GetNextCommandTarget ();
			else if (cmdTarget is Gtk.Widget)
				cmdTarget = ((Gtk.Widget)cmdTarget).Parent;
			else
				cmdTarget = null;
			
			if (cmdTarget == null || !visitedTargets.Add (cmdTarget)) {
				if (delegatorStack.Count > 0) {
					var del = delegatorStack.Pop ();
					if (del is ICommandDelegatorRouter)
						cmdTarget = ((ICommandDelegatorRouter)del).GetNextCommandTarget ();
					else
						cmdTarget = GetNextCommandTarget (targetRoute, del, true);
					if (cmdTarget == CommandManager.CommandRouteTerminator)
						return null;
					if (cmdTarget != null)
						return cmdTarget;
				}
				return globalHandlerChain;
			} else
				return cmdTarget;
		}
开发者ID:aBothe,项目名称:monodevelop,代码行数:46,代码来源:CommandManager.cs

示例10: DispatchCommandFromAccel

		internal bool DispatchCommandFromAccel (object commandId, object dataItem, object initialTarget)
		{
			// Dispatches a command that has been fired by an accelerator.
			// The difference from a normal dispatch is that there may
			// be several commands bound to the same accelerator, and in
			// this case it will execute the one that is enabled.
			
			// If the original key has been modified
			// by a CommandUpdate handler, it won't work. That's a limitation,
			// but checking all possible commands would be too slow.
			
			Command cmd = GetCommand (commandId);
			if (cmd == null)
				return false;
			
			string accel = cmd.AccelKey;
			KeyBinding binding;
			
			if (accel == null || !KeyBinding.TryParse (accel, out binding))
				return DispatchCommand (commandId, dataItem, initialTarget, CommandSource.Keybinding);
			
			List<Command> list = bindings.Commands (binding);
			if (list == null || list.Count == 1) {
				// The command is not overloaded, so it can be handled normally.
				return DispatchCommand (commandId, dataItem, initialTarget, CommandSource.Keybinding);
			}
			
			CommandTargetRoute targetChain = new CommandTargetRoute (initialTarget);
			
			// Get the accelerator used to fire the command and make sure it has not changed.
			CommandInfo accelInfo = GetCommandInfo (commandId, targetChain);
			bool res = DispatchCommand (commandId, accelInfo.DataItem, initialTarget, CommandSource.Keybinding);

			// If the accelerator has changed, we can't handle overloading.
			if (res || accel != accelInfo.AccelKey)
				return res;
			
			// Execution failed. Now try to execute alternate commands
			// bound to the same key.
			
			for (int i = 0; i < list.Count; i++) {
				if (list[i].Id == commandId) // already handled above.
					continue;
				
				CommandInfo cinfo = GetCommandInfo (list[i].Id, targetChain);
				if (cinfo.AccelKey != accel) // Key changed by a handler, just ignore the command.
					continue;
				
				if (DispatchCommand (list[i].Id, cinfo.DataItem, initialTarget, CommandSource.Keybinding))
					return true;
			}
			
			return false;
		}
开发者ID:aBothe,项目名称:monodevelop,代码行数:54,代码来源:CommandManager.cs

示例11: GetCommandInfo

		/// <summary>
		/// Retrieves status information about a command by looking for a handler in the active command route.
		/// </summary>
		/// <returns>
		/// The command information.
		/// </returns>
		/// <param name='commandId'>
		/// Identifier of the command.
		/// </param>
		/// <param name='targetRoute'>
		/// Command route origin
		/// </param>
		public CommandInfo GetCommandInfo (object commandId, CommandTargetRoute targetRoute)
		{
			commandId = CommandManager.ToCommandId (commandId);
			ActionCommand cmd = GetActionCommand (commandId);
			if (cmd == null)
				throw new InvalidOperationException ("Invalid action command id: " + commandId);

			NotifyCommandTargetScanStarted ();
			CommandInfo info = new CommandInfo (cmd);

			try {
				bool multiCastEnabled = true;
				bool multiCastVisible = false;

				CurrentCommand = cmd;

				object cmdTarget = GetFirstCommandTarget (targetRoute);
				
				while (cmdTarget != null)
				{
					HandlerTypeInfo typeInfo = GetTypeHandlerInfo (cmdTarget);
					CommandUpdaterInfo cui = typeInfo.GetCommandUpdater (commandId);
					
					bool bypass = false;
					bool handlerFound = false;
					
					if (cui != null) {
						if (cmd.CommandArray) {
							info.ArrayInfo = new CommandArrayInfo (info);
							cui.Run (cmdTarget, info.ArrayInfo);
							if (!info.ArrayInfo.Bypass) {
								if (guiLock > 0)
									info.Enabled = false;
								handlerFound = true;
							}
						}
						else {
							info.Bypass = false;
							cui.Run (cmdTarget, info);
							if (!info.Bypass) {
								if (guiLock > 0)
									info.Enabled = false;
								handlerFound = true;
							}
						}
						if (!handlerFound)
							bypass = true;
					}

					if (handlerFound) {
						handlerFoundInMulticast = true;
						if (!info.Enabled || !info.Visible)
							multiCastEnabled = false;
						if (info.Visible)
							multiCastVisible = true;
						cmdTarget = NextMulticastTarget (targetRoute);
						if (cmdTarget == null) {
							if (!multiCastEnabled)
								info.Enabled = false;
							if (multiCastVisible)
								info.Visible = true;
							return info;
						}
						continue;
					}
					else if (!bypass && typeInfo.GetCommandHandler (commandId) != null) {
						info.Enabled = guiLock == 0;
						info.Visible = true;
						
						return info;
					}
					
					cmdTarget = GetNextCommandTarget (targetRoute, cmdTarget);
				}
				
				info.Bypass = false;
				DefaultUpdateCommandInfo (cmd, info);
			}
			catch (Exception ex) {
				if (!commandUpdateErrors.Contains (commandId)) {
					commandUpdateErrors.Add (commandId);
					ReportError (commandId, "Error while updating status of command: " + commandId, ex);
				}
				info.Enabled = false;
				info.Visible = true;
			} finally {
				NotifyCommandTargetScanFinished ();
				CurrentCommand = null;
//.........这里部分代码省略.........
开发者ID:aBothe,项目名称:monodevelop,代码行数:101,代码来源:CommandManager.cs

示例12: GetNextCommandTarget

		object GetNextCommandTarget (CommandTargetRoute targetRoute, object cmdTarget, bool ignoreDelegator = false)
		{
			if (cmdTarget is IMultiCastCommandRouter) 
				cmdTarget = new MultiCastDelegator (this, (IMultiCastCommandRouter)cmdTarget, targetRoute);

			if (!ignoreDelegator && cmdTarget is ICommandDelegator) {
				if (cmdTarget is ICommandDelegatorRouter)
					throw new InvalidOperationException ("A type can't implement both ICommandDelegator and ICommandDelegatorRouter");
				object oldCmdTarget = cmdTarget;
				cmdTarget = ((ICommandDelegator)oldCmdTarget).GetDelegatedCommandTarget ();
				if (cmdTarget != null)
					delegatorStack.Push (oldCmdTarget);
				else
					cmdTarget = GetNextCommandTarget (targetRoute, oldCmdTarget, true);
			}
			else if (cmdTarget is ICommandDelegatorRouter) {
				object oldCmdTarget = cmdTarget;
				cmdTarget = ((ICommandDelegatorRouter)oldCmdTarget).GetDelegatedCommandTarget ();
				if (cmdTarget != null)
					delegatorStack.Push (oldCmdTarget);
				else
					cmdTarget = ((ICommandDelegatorRouter)oldCmdTarget).GetNextCommandTarget ();
			}
			else if (cmdTarget is ICommandRouter)
				cmdTarget = ((ICommandRouter)cmdTarget).GetNextCommandTarget ();
			else if (cmdTarget is Gtk.Widget)
				cmdTarget = ((Gtk.Widget)cmdTarget).Parent;
			#if MAC
			else if (cmdTarget is AppKit.NSView) {
				var v = (AppKit.NSView) cmdTarget;
				if (v.Superview != null && IsRootGdkQuartzView (v.Superview))
					// FIXME: We should get here the GTK parent of the superview. Since there is no api for this
					// right now, we rely on it being set by GetActiveWidget()
					cmdTarget = null;
				else
					cmdTarget = v.Superview;
			}
			#endif
			else
				cmdTarget = null;
			
			if (cmdTarget == null || !visitedTargets.Add (cmdTarget)) {
				if (delegatorStack.Count > 0) {
					var del = delegatorStack.Pop ();
					if (del is ICommandDelegatorRouter)
						cmdTarget = ((ICommandDelegatorRouter)del).GetNextCommandTarget ();
					else
						cmdTarget = GetNextCommandTarget (targetRoute, del, true);
					if (cmdTarget == CommandManager.CommandRouteTerminator)
						return null;
					if (cmdTarget != null)
						return cmdTarget;
				}
				return globalHandlerChain;
			} else
				return cmdTarget;
		}
开发者ID:lkalif,项目名称:monodevelop,代码行数:57,代码来源:CommandManager.cs

示例13: Update

		public void Update (CommandTargetRoute targetRoute)
		{
			CommandInfo cmdInfo = IdeApp.CommandService.GetCommandInfo (cmdId, targetRoute);
			
			bool hasAccel = string.IsNullOrEmpty (cmdInfo.AccelKey);
			bool hasIcon = !cmdInfo.Icon.IsNull;
			string desc = cmdInfo.Description;
			
			//If the button only has an icon it's not always clear what it does. In such cases, use the label as a
			//fallback tooltip. Also do this if there's an accelerator, so the user can see what it is.
			if (string.IsNullOrEmpty (desc) && (hasIcon || hasAccel))
				desc = cmdInfo.Text;
			
			if (lastDesc != desc) {
				string toolTip;
				if (hasAccel) {
					toolTip = desc;
				} else {
					toolTip = desc + " (" + KeyBindingManager.BindingToDisplayLabel (cmdInfo.AccelKey, false) + ")";
				}
				button.TooltipText = toolTip;
				lastDesc = desc;
			}
			
			if (!hasIcon && button.Label != cmdInfo.Text)
				button.Label = cmdInfo.Text;
			
			if (cmdInfo.Icon != stockId) {
				stockId = cmdInfo.Icon;
				button.Image = new Gtk.Image (cmdInfo.Icon, Gtk.IconSize.Menu);
			}
			if (cmdInfo.Enabled != button.Sensitive)
				button.Sensitive = cmdInfo.Enabled;
			if (cmdInfo.Visible != button.Visible)
				button.Visible = cmdInfo.Visible;
			
			ToggleButton toggle = button as ToggleButton;
			if (toggle != null && cmdInfo.Checked != toggle.Active)
				toggle.Active = cmdInfo.Checked;
				
			if (button.Image != null)
				button.Image.Show ();
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:43,代码来源:DockItemToolbarLoader.cs

示例14: Update

		internal void Update ()
		{
			CommandTargetRoute targetRoute = new CommandTargetRoute (initialCommandTarget);
			foreach (Gtk.Widget item in Children) {
				if (item is ICommandUserItem)
					((ICommandUserItem)item).Update (targetRoute);
				else if (item is Gtk.MenuItem) {
					Gtk.MenuItem mitem = (Gtk.MenuItem) item;
					CommandMenu men = mitem.Submenu as CommandMenu;
					if (men != null)
						men.InitialCommandTarget = initialCommandTarget;
					item.Show ();
					if (item is AutoHideMenuItem) {
						men.Update ();
						if (!((AutoHideMenuItem)item).HasVisibleChildren)
							item.Hide ();
					}
				}
				else
					item.Show ();
			}
			
			// After updating the menu, hide the separators which don't actually
			// separate items.
			bool prevWasItem = false;
			Gtk.Widget lastSeparator = null;
			foreach (Gtk.Widget item in Children) {
				if (item is Gtk.SeparatorMenuItem) {
					if (!prevWasItem)
						item.Hide ();
					else {
						prevWasItem = false;
						lastSeparator = item;
					}
				} else if (item.Visible)
					prevWasItem = true;
			}
			if (!prevWasItem && lastSeparator != null)
				lastSeparator.Hide ();
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:40,代码来源:CommandMenu.cs

示例15: InsertOptions

		public void InsertOptions (Gtk.Menu menu, CommandEntrySet entrySet, int index)
		{
			CommandTargetRoute route = new CommandTargetRoute ();
			foreach (CommandEntry entry in entrySet) {
				Gtk.MenuItem item = entry.CreateMenuItem (this);
				CustomItem ci = item.Child as CustomItem;
				if (ci != null)
					ci.SetMenuStyle (menu);
				int n = menu.Children.Length;
				menu.Insert (item, index);
				if (item is ICommandUserItem)
					((ICommandUserItem)item).Update (route);
				else
					item.Show ();
				index += menu.Children.Length - n;
			}
		}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:17,代码来源:CommandManager.cs


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