Пример #1
0
 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;
 }
		internal CommandInfo (Command cmd)
		{
			text = cmd.Text;
			icon = cmd.Icon;
			accelKey = cmd.AccelKey;
			description = cmd.Description;
		}
Пример #3
0
		public virtual Command GetCommand (CommandManager manager)
		{
			if (localCmd != null) {
				if (manager.GetCommand (localCmd.Id) == null)
					manager.RegisterCommand (localCmd);
				localCmd = null;
			}
				
			return manager.GetCommand (cmdId);
		}
Пример #4
0
		public void Run (object cmdTarget, Command cmd)
		{
			if (customHandlerChain != null) {
				cmd.HandlerData = Method;
				customHandlerChain.Run (cmdTarget, cmd);
			}
			else
				Method.Invoke (cmdTarget, null);
		}
Пример #5
0
		static Gtk.MenuItem CreateMenuItem (CommandManager manager, Command cmd, object cmdId, bool isArrayMaster, string overrideLabel, bool disabledVisible)
		{
			cmdId = CommandManager.ToCommandId (cmdId);
			if (cmdId == CommandManager.ToCommandId (Command.Separator))
				return new Gtk.SeparatorMenuItem ();
			
			if (cmd == null)
				cmd = manager.GetCommand (cmdId);

			if (cmd == null) {
				MonoDevelop.Core.LoggingService.LogWarning ("Unknown command '{0}'", cmdId);
				return new Gtk.MenuItem ("<Unknown Command>");
			}
			
			if (cmd is CustomCommand) {
				Gtk.Widget child = (Gtk.Widget) Activator.CreateInstance (((CustomCommand)cmd).WidgetType);
				CustomMenuItem ti = new CustomMenuItem ();
				ti.Child = child;
				return ti;
			}
			
			ActionCommand acmd = cmd as ActionCommand;
			if (acmd.ActionType == ActionType.Normal || (isArrayMaster && acmd.CommandArray))
				return new CommandMenuItem (cmdId, manager, overrideLabel, disabledVisible);
			else
				return new CommandCheckMenuItem (cmdId, manager, overrideLabel, disabledVisible);
		}	
Пример #6
0
		bool GetSelectedCommandIter (out TreeIter iter, out Command cmd)
		{
			TreeSelection sel = keyTreeView.Selection;
			if (!sel.GetSelected (out iter)) {
				cmd = null;
				return false;
			}
			
			cmd = (Command)filterModel.GetValue (iter, commandCol);
			if (cmd == null)
				return false;
			
			if (keyStore.GetIterFirst (out iter) && FindIterForCommand (cmd, iter, out iter))
				return true;
			
			throw new Exception ("Did not find command in underlying model");
		}
Пример #7
0
			protected override void Run (object target, Command cmd)
			{
				NodeCommandHandler nch = (NodeCommandHandler) target;
				if (nch.tree == null) {
					base.Run (target, cmd);
					return;
				}
				try {
					nch.tree.LockUpdates ();
					base.Run (target, cmd);
				} finally {
					nch.tree.UnlockUpdates ();
				}
			}
Пример #8
0
		public KeyBindingChangedEventArgs (Command command, KeyBinding oldKeyBinding)
		{
			OldKeyBinding = oldKeyBinding;
			Command = command;
		}
Пример #9
0
 void ICommandArrayTargetHandler.Run(object target, Command cmd, object data)
 {
     Run(target, cmd, data);
 }
Пример #10
0
		public static void StoreDefaultBinding (Command cmd)
		{
			defaultSchemeBindings.StoreBinding (cmd);
		}
		public bool CommandIsRegistered (Command command)
		{
			return commands.Contains (command);
		}
Пример #12
0
 /// <summary>
 /// Runs a command
 /// </summary>
 /// <param name='target'>
 /// Object that implements the command handler
 /// </param>
 /// <param name='cmd'>
 /// The command to be executed
 /// </param>
 /// <remarks>
 /// The default implementation of this method runs the command handler method
 /// to which this attribute is applied. A custom implementation of this method can call
 /// base.Run at any point to run the method handler, or not call it at all if it
 /// wants to provide a replacement implementation.
 /// </remarks>
 protected virtual void Run(object target, Command cmd)
 {
     next.Run(target, cmd);
 }
Пример #13
0
 /// <summary>
 /// Runs a command
 /// </summary>
 /// <param name='target'>
 /// Object that implements the command handler
 /// </param>
 /// <param name='cmd'>
 /// The command to be executed
 /// </param>
 /// <param name='data'>
 /// Data item provided by the command update handler
 /// </param>
 /// <remarks>
 /// The default implementation of this method runs the command handler method
 /// to which this attribute is applied. A custom implementation of this method can call
 /// base.Run at any point to run the method handler, or not call it at all if it
 /// wants to provide a replacement implementation.
 /// </remarks>
 protected virtual void Run(object target, Command cmd, object data)
 {
     nextArray.Run(target, cmd, data);
 }
Пример #14
0
 void ICommandTargetHandler.Run(object target, Command cmd)
 {
     Run(target, cmd);
 }
Пример #15
0
		public void Run (object target, Command cmd, object data)
		{
			MethodInfo mi = (MethodInfo) cmd.HandlerData;
			if (mi != null)
				mi.Invoke (target, new object[] {data} );
		}
Пример #16
0
		/// <summary>
		/// Unregisters a command.
		/// </summary>
		/// <param name='cmd'>
		/// The command.
		/// </param>
		public void UnregisterCommand (Command cmd)
		{
			bindings.UnregisterCommand (cmd);
			cmds.Remove (cmd.Id);
		}
Пример #17
0
		public static void StoreBinding (Command cmd)
		{
			current.StoreBinding (cmd);
		}
			internal SearchResult CheckCommand (Command c)
			{
				ActionCommand cmd = c as ActionCommand;
				if (cmd == null || cmd.CommandArray)
					return null;

				int rank;
				string matchString = cmd.Text.Replace ("_", "");
				if (MatchName (matchString, out rank)) {
					var ci = IdeApp.CommandService.GetCommandInfo (cmd.Id);
					if (ci.Enabled && ci.Visible)
						return new CommandResult (cmd, pattern, matchString, rank);
				}
				return null;
			}
Пример #19
0
		internal static string GetCommandKey (Command cmd)
		{
			if (cmd.Id is Enum)
				return cmd.Id.GetType () + "." + cmd.Id;
			else
				return cmd.Id.ToString ();
		}
Пример #20
0
		static uint GetNewMenuItemId (Command cmd)
		{
			uint macCmdId;
			CarbonCommandID standardId;
			//use mapped values if possible
			if (cmdIdMap.TryGetValue (cmd.Id, out standardId))
				macCmdId = (uint) standardId;
			//or generate a new value
			else {
				//but avoid conflicts
				do cmdSeq++;
				while (commands.ContainsKey (cmdSeq));
				macCmdId = cmdSeq;
				cmdIdMap[cmd.Id] = (CarbonCommandID)macCmdId;
			}
			
			commands[macCmdId] = cmd.Id;
			return macCmdId;
		}
		void ICommandArrayTargetHandler.Run (object target, Command cmd, object data)
		{
			Run (target, cmd, data);
		}
		public KeyBindingChangedEventArgs (Command command, string oldBinding)
		{
			this.command = command;
			this.binding = oldBinding;
		}
		void ICommandTargetHandler.Run (object target, Command cmd)
		{
			Run (target, cmd);
		}
Пример #24
0
			protected override void Run (object target, Command cmd, object data)
			{
				base.Run (target, cmd, data);
			}
		protected virtual void Run (object target, Command cmd, object data)
		{
			nextArray.Run (target, cmd, data);
		}
Пример #26
0
		void SelectCommand (Command cmd)
		{
			//item may not be visible if the list is filtered
			searchEntry.Entry.Text = "";
			
			TreeIter iter;
			if (!keyStore.GetIterFirst (out iter))
				return;
			do {
				TreeIter citer;
				keyStore.IterChildren (out citer, iter);
				do {
					Command command = (Command) keyStore.GetValue (citer, commandCol);
					if (command == cmd) {
						TreePath path = keyStore.GetPath (citer);
						keyTreeView.ExpandToPath (path);
						keyTreeView.Selection.SelectPath (path);
						keyTreeView.ScrollToCell (path, keyTreeView.Columns[0], true, 0.5f, 0f);
						return;
					}
				} while (keyStore.IterNext (ref citer));
			} while (keyStore.IterNext (ref iter));
		}
		protected virtual void Run (object target, Command cmd)
		{
			next.Run (target, cmd);
		}
Пример #28
0
		public CommandEntry (Command localCmd) : this (localCmd.Id, null, true)
		{
			this.localCmd = localCmd;
		}
Пример #29
0
            internal SearchResult CheckCommand(Command c, CommandTargetRoute route)
            {
                ActionCommand cmd = c as ActionCommand;
                if (cmd == null || cmd.CommandArray)
                    return null;

                int rank;
                string matchString = cmd.Text.Replace ("_", "");
                if (MatchName (matchString, out rank)) {
                    try {
                        var ci = IdeApp.CommandService.GetCommandInfo (cmd.Id, route);
                        if (ci.Enabled && ci.Visible)
                            return new CommandResult (cmd, ci, route, pattern, matchString, rank);
                    } catch (Exception 	ex) {
                        LoggingService.LogError ("Failure while checking command: " + cmd.Id, ex);
                    }
                }
                return null;
            }
Пример #30
0
		public void Run (object cmdTarget, Command cmd, object dataItem)
		{
			if (customArrayHandlerChain != null) {
				cmd.HandlerData = Method;
				customArrayHandlerChain.Run (cmdTarget, cmd, dataItem);
			}
			else
				Method.Invoke (cmdTarget, new object[] {dataItem});
		}
		public void Add (Command cmd)
		{
			cmds.Add (new CommandEntry (cmd));
		}
Пример #32
0
		/// <summary>
		/// Registers a new command.
		/// </summary>
		/// <param name='cmd'>
		/// The command.
		/// </param>
		public void RegisterCommand (Command cmd)
		{
			KeyBindingService.StoreDefaultBinding (cmd);
			KeyBindingService.LoadBinding (cmd);
			
			cmds[cmd.Id] = cmd;
			bindings.RegisterCommand (cmd);
		}
Пример #33
0
			public KeyBindingSelectedEventArgs (IEnumerable<string> keys, int selectedKey, Command command, TreeIter iter)
			{
				if (command == null)
					throw new ArgumentNullException (nameof (command));
				AllKeys = new List<string> (keys);
				if (selectedKey < 0 || ((selectedKey != 0 && AllKeys.Count != 0) && selectedKey >= AllKeys.Count))
					throw new ArgumentOutOfRangeException (nameof (selectedKey));
				SelectedKey =  selectedKey;
				Command = command;
				Iter = iter;
			}
		public CommandResult (Command cmd, string match, string matchedString, int rank): base (match, matchedString, rank)
		{
			command = cmd;
		}
Пример #35
0
			KeyBindingHitTestResult HitTest (double mouseX, double mouseY)
			{
				KeyBindingHitTestResult result = new KeyBindingHitTestResult ();
				TreeIter iter;
				TreePath path;
				int cellx, celly, mx, my;
				mx = (int)mouseX;
				my = (int)mouseY;

				if (!GetCellPosition (mx, my, out cellx, out celly, out iter, out path))
					return result;

				Text = keyBindingsTree.Model.GetValue (iter, bindingCol) as string ?? string.Empty;
				Command = keyBindingsTree.Model.GetValue (iter, commandCol) as Command;

				var filter = keyBindingsTree.Model as TreeModelFilter;
				if (filter != null)
					iter = filter.ConvertIterToChildIter (iter);

				result.Command = Command;
				result.AllKeys = Text.Split (new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList ();
				result.Iter = iter;

				using (var layout = new Pango.Layout (keyBindingsTree.PangoContext)) {

					// GetCellArea reports the outer cell bounds, therefore we need to add 2px
					var xpad = (int)Xpad + 2;
					var cellBounds = keyBindingsTree.GetCellArea (path, keyBindingsPanel.bindingTVCol);
					keyBindingsTree.ConvertBinWindowToWidgetCoords (cellBounds.X, cellBounds.Y, out cellBounds.X, out cellBounds.Y);
					int i = 0;
					foreach (var key in result.AllKeys) {
						layout.SetText (KeyBindingManager.BindingToDisplayLabel (key, false));
						layout.FontDescription = KeySymbolFont;
						int w, h;
						layout.GetPixelSize (out w, out h);

						int buttonWidth = w + (2 * KeyHPadding);
						int buttonHeight = h + (2 * KeyVPadding);
						var ypad = 2 + ((cellBounds.Height / 2) - (buttonHeight / 2));

						if (cellx > xpad && cellx <= xpad + buttonWidth &&
						    celly > ypad && celly <= ypad + buttonHeight) {
							keyBindingsPanel.bindingTVCol.CellGetPosition (this, out cellx, out w);
							cellBounds.X += cellx;

							result.SelectedKey = i;
							result.ButtonBounds = new Gdk.Rectangle (cellBounds.X + xpad, cellBounds.Y + ypad, buttonWidth, buttonHeight);
							result.ButtonBounds.Inflate (0, 2);
							return result;
						}

						xpad += buttonWidth + Spacing;
						i++;
					}
				}
				return result;
			}