예제 #1
0
		void UpdateGlobalWarningLabel ()
		{
			KeyBindingConflict[] conflicts = currentBindings.CheckKeyBindingConflicts (IdeApp.CommandService.GetCommands ());
			if (conflicts.Length == 0) {
				globalWarningBox.Hide ();
				return;
			}
			globalWarningBox.Show ();

			conflicButton.ContextMenuRequested = delegate {
				ContextMenu menu = new ContextMenu ();
				bool first = true;

				foreach (KeyBindingConflict conf in conflicts) {
					if (first == false) {
						ContextMenuItem item = new SeparatorContextMenuItem ();
						menu.Items.Add (item);
					}

					foreach (Command cmd in conf.Commands) {
						string txt = currentBindings.GetBinding (cmd) + " - " + cmd.Text;
						ContextMenuItem item = new ContextMenuItem (txt);
						Command localCmd = cmd;

						item.Clicked += (sender, e) => SelectCommand (localCmd);

						menu.Items.Add (item);
						first = false;
					}
				}

				return menu;
			};
		}
예제 #2
0
		void UpdateConflictsWarning ()
		{
			duplicates = new Dictionary<string, HashSet<Command>> ();
			foreach (var conflict in currentBindings.CheckKeyBindingConflicts (IdeApp.CommandService.GetCommands ())) {
				HashSet<Command> cmds = null;
				if (!duplicates.TryGetValue (conflict.Key, out cmds))
					duplicates [conflict.Key] = cmds = new HashSet<Command> ();
				foreach (var cmd in conflict.Commands)
					cmds.Add (cmd);
			}
			conflicts = new Dictionary<string, HashSet<Command>> ();

			foreach (var dup in duplicates) {
				foreach (var cmd in dup.Value) {
					HashSet<Command> cmdDuplicates;
					if (IdeApp.CommandService.Conflicts.TryGetValue (cmd, out cmdDuplicates)) {
						cmdDuplicates = new HashSet<Command> (cmdDuplicates.Intersect (dup.Value));
						if (cmdDuplicates.Count > 0) {
							HashSet<Command> cmdConflicts;
							if (!conflicts.TryGetValue (dup.Key, out cmdConflicts))
								conflicts [dup.Key] = cmdConflicts = new HashSet<Command> ();
							conflicts [dup.Key].UnionWith (cmdDuplicates);
						}
					}
				}
			}

			if (conflicts.Count == 0) {
				globalWarningBox.Hide ();
				return;
			}

			globalWarningBox.Show ();

			conflicButton.ContextMenuRequested = delegate {
				ContextMenu menu = new ContextMenu ();
				bool first = true;

				foreach (var conf in conflicts) {
					if (first == false) {
						ContextMenuItem item = new SeparatorContextMenuItem ();
						menu.Items.Add (item);
					}

					foreach (Command cmd in conf.Value.OrderBy (cmd => cmd.DisplayName)) {
						string txt = conf.Key + " \u2013 " + cmd.DisplayName;
						ContextMenuItem item = new ContextMenuItem (txt);
						Command localCmd = cmd;

						item.Clicked += (sender, e) => SelectCommand (localCmd);

						menu.Items.Add (item);
						first = false;
					}
				}

				return menu;
			};
		}