protected override void Update(CommandArrayInfo info) { int contentCount = WorkbenchSingleton.Workbench.ViewContentCollection.Count; if (contentCount == 0) return; for (int i = 0; i < contentCount; ++i) { IViewContent content = (IViewContent)WorkbenchSingleton.Workbench.ViewContentCollection[i]; CommandInfo item = null; if (content.WorkbenchWindow.ShowNotification) { item = new CommandInfo ("<span foreground=\"blue\">" + content.WorkbenchWindow.Title + "</span>"); item.UseMarkup = true; } else { item = new CommandInfo (content.WorkbenchWindow.Title); } item.Checked = (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == content.WorkbenchWindow); item.Description = GettextCatalog.GetString ("Activate this window"); if (i + 1 <= 9) item.AccelKey = "Alt|" + (i+1); info.Add (item, content.WorkbenchWindow); } }
protected void OnUpdateViewToolbar(CommandArrayInfo info) { foreach (IDockToolbar bar in Toolbars) { CommandInfo cmd = new CommandInfo (bar.Title); cmd.Checked = bar.Visible; info.Add (cmd, bar); } }
protected override void Update(CommandArrayInfo info) { for (int i = 0; i < ToolLoader.Tool.Count; ++i) { CommandInfo cmd = new CommandInfo (ToolLoader.Tool[i].ToString()); cmd.Description = GettextCatalog.GetString ("Start tool") + " " + String.Join(String.Empty, ToolLoader.Tool[i].ToString().Split('&')); info.Add (cmd, ToolLoader.Tool[i]); } }
protected override void Update(CommandArrayInfo info) { IWorkbench wb = WorkbenchSingleton.Workbench; if (wb.WorkbenchLayout != null) { string[] layouts = wb.WorkbenchLayout.Layouts; Array.Sort (layouts); foreach (string layout in layouts) { CommandInfo cmd = new CommandInfo (layout); cmd.Checked = (layout == wb.WorkbenchLayout.CurrentLayout); info.Add (cmd, layout); } } }
protected override void Update(CommandArrayInfo info) { IWorkbench wb = WorkbenchSingleton.Workbench; if (wb.WorkbenchLayout != null) { PadContentCollection pads = wb.WorkbenchLayout.PadContentCollection; foreach (IPadContent padContent in pads) { CommandInfo cmd = new CommandInfo (padContent.Title); cmd.UseMarkup = true; cmd.Checked = WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible (padContent); info.Add (cmd, padContent); } } }
public void Run(object cmdTarget, CommandArrayInfo info) { if (!isArray) throw new InvalidOperationException ("Invalid signature for command update handler: " + Method.DeclaringType + "." + Method.Name + "()"); Method.Invoke (cmdTarget, new object[] {info} ); }
public bool DispatchCommand(object commandId, object dataItem) { ActionCommand cmd = null; try { cmd = GetActionCommand (commandId); int globalPos; object cmdTarget = GetFirstCommandTarget (out globalPos); CommandInfo info = new CommandInfo (cmd); while (cmdTarget != null) { HandlerTypeInfo typeInfo = GetTypeHandlerInfo (cmdTarget); CommandUpdaterInfo cui = typeInfo.GetCommandUpdater (commandId); if (cui != null) { if (cmd.CommandArray) { // Make sure that the option is still active CommandArrayInfo ainfo = new CommandArrayInfo (info); cui.Run (cmdTarget, ainfo); bool found = false; foreach (CommandInfo ci in ainfo) { if (Object.Equals (dataItem, ci.DataItem)) { found = true; break; } } if (!found) return false; } else { cui.Run (cmdTarget, info); if (!info.Enabled || !info.Visible) return false; } } CommandHandlerInfo chi = typeInfo.GetCommandHandler (commandId); if (chi != null) { if (cmd.CommandArray) chi.Run (cmdTarget, dataItem); else chi.Run (cmdTarget); UpdateToolbars (); return true; } cmdTarget = GetNextCommandTarget (cmdTarget, ref globalPos); } return cmd.DispatchCommand (dataItem); } catch (Exception ex) { string name = (cmd != null && cmd.Text != null && cmd.Text.Length > 0) ? cmd.Text : commandId.ToString (); name = name.Replace ("_",""); ReportError (commandId, "Error while executing command: " + name, ex); return false; } }
protected void BuildTreeOptionsMenu(CommandArrayInfo info) { ITreeNavigator tnav = GetSelectedNode (); ITreeOptions currentOptions = tnav.Options; foreach (TreePadOption op in options) { CommandInfo ci = new CommandInfo (op.Label); ci.Checked = currentOptions [op.Id]; info.Add (ci, op.Id); } }
protected override void Update(CommandArrayInfo info) { RecentOpen recentOpen = Runtime.FileService.RecentOpen; if (recentOpen.RecentProject != null && recentOpen.RecentProject.Length > 0) { for (int i = 0; i < recentOpen.RecentProject.Length; ++i) { string accelaratorKeyPrefix = i < 10 ? "_" + ((i + 1) % 10).ToString() + " " : ""; RecentItem ri = recentOpen.RecentProject[i]; string label = ((ri.Private == null || ri.Private.Length < 1) ? Path.GetFileNameWithoutExtension (ri.ToString ()) : ri.Private); CommandInfo cmd = new CommandInfo (accelaratorKeyPrefix + label.Replace ("_", "__")); cmd.Description = String.Format (GettextCatalog.GetString ("load solution {0}"), ri.ToString ()); info.Add (cmd, ri); } } }
protected override void Update(CommandArrayInfo info) { RecentOpen recentOpen = Runtime.FileService.RecentOpen; if (recentOpen.RecentFile != null && recentOpen.RecentFile.Length > 0) { for (int i = 0; i < recentOpen.RecentFile.Length; ++i) { string accelaratorKeyPrefix = i < 10 ? "_" + ((i + 1) % 10).ToString() + " " : ""; RecentItem ri = recentOpen.RecentFile[i]; string label = ((ri.Private == null || ri.Private.Length < 1) ? Path.GetFileName (ri.ToString ()) : ri.Private); CommandInfo cmd = new CommandInfo (accelaratorKeyPrefix + label.Replace ("_", "__")); info.Add (cmd, ri); } } }
protected void OnUpdateInsertOption(CommandArrayInfo info) { foreach (string[] op in options) { if (op [0] == "-") info.AddSeparator (); else info.Add (op [0], op [1]); } }
protected internal virtual void Update(CommandArrayInfo info) { }