コード例 #1
0
ファイル: SearchResult.cs プロジェクト: Kalnor/monodevelop
 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;
 }
コード例 #2
0
		internal CommandInfo (Command cmd)
		{
			text = cmd.Text;
			icon = cmd.Icon;
			accelKey = cmd.AccelKey;
			description = cmd.Description;
		}
コード例 #3
0
ファイル: CommandEntry.cs プロジェクト: Kalnor/monodevelop
		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
ファイル: CommandManager.cs プロジェクト: aBothe/monodevelop
		public void Run (object cmdTarget, Command cmd)
		{
			if (customHandlerChain != null) {
				cmd.HandlerData = Method;
				customHandlerChain.Run (cmdTarget, cmd);
			}
			else
				Method.Invoke (cmdTarget, null);
		}
コード例 #5
0
ファイル: CommandEntry.cs プロジェクト: zenek-y/monodevelop
		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
ファイル: Command.cs プロジェクト: Kalnor/monodevelop
		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);
		}
コード例 #11
0
		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
ファイル: CommandManager.cs プロジェクト: aBothe/monodevelop
		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
ファイル: CommandManager.cs プロジェクト: aBothe/monodevelop
		/// <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);
		}
コード例 #18
0
			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
ファイル: OSXMenu.cs プロジェクト: Tak/monodevelop-novell
		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);
		}
コード例 #22
0
		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
ファイル: CommandEntry.cs プロジェクト: zenek-y/monodevelop
		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
ファイル: CommandManager.cs プロジェクト: aBothe/monodevelop
		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});
		}
コード例 #31
0
		public void Add (Command cmd)
		{
			cmds.Add (new CommandEntry (cmd));
		}
コード例 #32
0
ファイル: CommandManager.cs プロジェクト: aBothe/monodevelop
		/// <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;
			}
コード例 #34
0
		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;
			}