protected override void Update(CommandArrayInfo info) { ResolverContextStack ctxt; var rr = Resolver.DResolverWrapper.ResolveHoveredCode(out ctxt); bool noRes = true; if (rr != null && rr.Length > 0) { res = rr[rr.Length - 1]; n = DResolver.GetResultMember(res); if (n != null) { noRes = false; info.Add(IdeApp.CommandService.GetCommandInfo(RefactoryCommands.GotoDeclaration), new Action(GotoDeclaration)); info.Add(IdeApp.CommandService.GetCommandInfo(RefactoryCommands.FindReferences), new Action(FindReferences)); if (RenamingRefactoring.CanRename(n)) { info.AddSeparator(); info.Add(IdeApp.CommandService.GetCommandInfo(EditCommands.Rename), new Action(RenameSymbol)); } } } if (noRes) { info.Add(IdeApp.CommandService.GetCommandInfo(RefactoryCommands.ImportSymbol), new Action(ImportSymbol)); } info.Add(IdeApp.CommandService.GetCommandInfo(Commands.OpenDDocumentation), new Action(OpenDDoc)); }
protected override async Task UpdateAsync(CommandArrayInfo info, CancellationToken cancelToken) { var editor = IdeApp.Workbench.ActiveDocument?.Editor; var ext = editor?.GetContent <CodeActionEditorExtension> (); if (ext == null) { return; } try { info.Add(new CommandInfo(GettextCatalog.GetString("Loading..."), false, false), null); var currentFixes = await ext.GetCurrentFixesAsync(cancelToken); var menu = await CodeFixMenuService.CreateFixMenu(editor, currentFixes, cancelToken); info.Clear(); foreach (var item in menu.Items) { AddItem(info, item); } if (menu.Items.Count == 0) { info.Add(new CommandInfo(GettextCatalog.GetString("No code fixes available"), false, false), null); } info.NotifyChanged(); } catch (OperationCanceledException) { } catch (Exception e) { LoggingService.LogError("Error while creating quick fix menu.", e); info.Clear(); info.Add(new CommandInfo(GettextCatalog.GetString("No code fixes available"), false, false), null); info.NotifyChanged(); } }
protected override void Update(CommandArrayInfo info) { var proj = IdeApp.ProjectOperations.CurrentSelectedProject as IPhoneProject; if (proj == null) { return; } var workspaceConfig = IdeApp.Workspace.ActiveConfigurationId; var conf = proj.GetConfiguration(new SolutionConfigurationSelector(workspaceConfig)) as IPhoneProjectConfiguration; if (conf == null || conf.Platform != IPhoneProject.PLAT_SIM) { return; } var projSetting = proj.GetSimulatorTarget(conf); var def = info.Add("Default", null); if (projSetting == null) { def.Checked = true; } foreach (var st in IPhoneFramework.GetSimulatorTargets(IPhoneSdkVersion.Parse(conf.MtouchMinimumOSVersion), proj.SupportedDevices)) { var i = info.Add(st.ToString(), st); if (projSetting != null && projSetting.Equals(st)) { i.Checked = true; } } }
protected override void Update(CommandArrayInfo info) { if (ProfilingService.ProfilerCount > 0) { foreach (IProfiler prof in ProfilingService.Profilers) { CommandInfo cmd = new CommandInfo(GettextCatalog.GetString(prof.Name)); cmd.UseMarkup = true; cmd.Icon = prof.IconString; if (prof.IsSupported) { if (IdeApp.Workspace.IsOpen) { cmd.Enabled = IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted; } else { cmd.Enabled = (IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.IsBuildTarget); } } else { cmd.Enabled = false; } info.Add(cmd, prof); } } else { CommandInfo cmd = new CommandInfo(GettextCatalog.GetString("No profilers detected.")); cmd.Enabled = false; info.Add(cmd, null); } }
public static void PopulateInfos(CommandArrayInfo infos, Document doc, IEnumerable <FixableResult> results) { //FIXME: ellipsize long messages int mnemonic = 1; foreach (var result in results) { bool firstAction = true; foreach (var action in GetActions(doc, result)) { if (firstAction) { //FIXME: make this header item insensitive but not greyed out infos.Add(new CommandInfo(result.Message, false, false) { Icon = GetIcon(result.Level) }, null); firstAction = false; } var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString() + " " + action.Label : " " + action.Label; infos.Add(label, action); } } }
public static void PopulateInfos(CommandArrayInfo infos, Document doc, IEnumerable <FixableResult> results) { //FIXME: ellipsize long messages int mnemonic = 1; foreach (var result in results) { bool firstAction = true; foreach (var action in GetActions(doc, result)) { if (firstAction) { //FIXME: make this header item insensitive but not greyed out infos.Add(new CommandInfo(result.Message.Replace("_", "__"), false, false) { Icon = GetIcon(result.Level) }, null); firstAction = false; } var escapedLabel = action.Label.Replace("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel : " " + escapedLabel; infos.Add(label, action); } if (result.HasOptionsDialog) { var label = GettextCatalog.GetString("_Inspection options for \"{0}\"", result.OptionsTitle); infos.Add(label, result); } } }
void AddItem(CommandArrayInfo cis, CodeFixMenuEntry item) { if (item == CodeFixMenuEntry.Separator) { if (cis.Count == 0) { return; } cis.AddSeparator(); } else if (item is CodeFixMenu) { var menu = (CodeFixMenu)item; var submenu = new CommandInfoSet { Text = menu.Label }; foreach (var subItem in menu.Items) { AddItem(submenu.CommandInfos, subItem); } cis.Add(submenu, item.Action); } else { var info = new CommandInfo(item.Label); info.Enabled = item.Action != null; cis.Add(info, item.Action); } }
protected override void Update(CommandArrayInfo info) { var doc = IdeApp.Workbench.ActiveDocument; if (doc == null || doc.FileName == FilePath.Null || doc.ParsedDocument == null) { return; } var msbuildEditor = doc.GetContent <MSBuildTextEditorExtension> (); if (msbuildEditor == null) { return; } CommandInfo goToDeclarationCommand = IdeApp.CommandService.GetCommandInfo(RefactoryCommands.GotoDeclaration); CommandInfo findReferenceCommand = IdeApp.CommandService.GetCommandInfo(RefactoryCommands.FindReferences); if (goToDeclarationCommand.Enabled) { info.Add(goToDeclarationCommand, new Action(() => IdeApp.CommandService.DispatchCommand(RefactoryCommands.GotoDeclaration))); } if (findReferenceCommand.Enabled) { info.Add(findReferenceCommand, new Action(() => IdeApp.CommandService.DispatchCommand(RefactoryCommands.FindReferences))); } }
internal static void PopulateOpenWithViewers(CommandArrayInfo info, Project project, string filePath) { var viewers = DisplayBindingService.GetFileViewers(filePath, project).ToList(); //show the default viewer first var def = viewers.FirstOrDefault(v => v.CanUseAsDefault) ?? viewers.FirstOrDefault(v => v.IsExternal); if (def != null) { CommandInfo ci = info.Add(def.Title, def); ci.Description = GettextCatalog.GetString("Open with '{0}'", def.Title); if (viewers.Count > 1) { info.AddSeparator(); } } //then the builtins, followed by externals FileViewer prev = null; foreach (FileViewer fv in viewers) { if (def != null && fv.Equals(def)) { continue; } if (prev != null && fv.IsExternal != prev.IsExternal) { info.AddSeparator(); } CommandInfo ci = info.Add(fv.Title, fv); ci.Description = GettextCatalog.GetString("Open with '{0}'", fv.Title); prev = fv; } }
public static void GenerateExecutionModeCommands(SolutionEntityItem project, CanExecuteDelegate runCheckDelegate, CommandArrayInfo info) { CommandExecutionContext ctx = new CommandExecutionContext(project, runCheckDelegate); bool supportsParameterization = false; foreach (List <IExecutionMode> modes in GetExecutionModeCommands(ctx, false, true)) { foreach (IExecutionMode mode in modes) { CommandInfo ci = info.Add(mode.Name, new CommandItem(ctx, mode)); if ((mode.ExecutionHandler is ParameterizedExecutionHandler) || ((mode is CustomExecutionMode) && ((CustomExecutionMode)mode).PromptForParameters)) { // It will prompt parameters, so we need command to end with '..'. // However, some commands may end with '...' already and we don't want to break // already-translated strings by altering them if (!ci.Text.EndsWith("...")) { ci.Text += "..."; } supportsParameterization = true; } else { // The parameters window will be shown if ctrl is pressed ci.Description = GettextCatalog.GetString("Run With: {0}", ci.Text); if (SupportsParameterization(mode, ctx)) { ci.Description += " - " + GettextCatalog.GetString("Hold Control key to display the execution parameters dialog."); supportsParameterization = true; } } } if (info.Count > 0) { info.AddSeparator(); } } var targets = new List <ExecutionTarget> (); FlattenExecutionTargets(targets, project.GetExecutionTargets(IdeApp.Workspace.ActiveConfiguration)); if (targets.Count > 1) { foreach (var t in targets) { var h = new TargetedExecutionHandler(Runtime.ProcessService.DefaultExecutionHandler, t); CommandInfo ci = info.Add(t.FullName, new CommandItem(ctx, new ExecutionMode(t.Id, t.FullName, h))); ci.Description = GettextCatalog.GetString("Run With: {0}", ci.Text); } info.AddSeparator(); } if (supportsParameterization) { info.AddSeparator(); info.Add(GettextCatalog.GetString("Edit Custom Modes..."), new CommandItem(ctx, null)); } }
protected override void Update(CommandArrayInfo ainfo) { CommandInfo info = ainfo.Add(GettextCatalog.GetString("_Errors & Warnings"), new Action(delegate { MonoDevelop.Ide.IdeApp.Preferences.ShowMessageBubbles = MonoDevelop.Ide.ShowMessageBubbles.ForErrorsAndWarnings; })); info.Checked = MonoDevelop.Ide.IdeApp.Preferences.ShowMessageBubbles == MonoDevelop.Ide.ShowMessageBubbles.ForErrorsAndWarnings; info = ainfo.Add(GettextCatalog.GetString("E_rrors only"), new Action(delegate { MonoDevelop.Ide.IdeApp.Preferences.ShowMessageBubbles = MonoDevelop.Ide.ShowMessageBubbles.ForErrors; })); info.Checked = MonoDevelop.Ide.IdeApp.Preferences.ShowMessageBubbles == MonoDevelop.Ide.ShowMessageBubbles.ForErrors; }
protected override void Update(CommandArrayInfo ainfo) { ainfo.Add(NavigationBar.HideStatusBox ? GettextCatalog.GetString("_Show Caret Panel") : GettextCatalog.GetString("_Hide Caret Panel"), new System.Action(delegate { IdeApp.Workbench.StatusBar.ClearCaretState(); NavigationBar.HideStatusBox = !NavigationBar.HideStatusBox; })); if (!NavigationBar.HideStatusBox) { ainfo.Add(StatusBox.ShowRealColumns ? GettextCatalog.GetString("_Show logical caret position") : GettextCatalog.GetString("_Show visual caret position"), new System.Action(delegate { StatusBox.ShowRealColumns = !StatusBox.ShowRealColumns; })); } }
protected override void Update(CommandArrayInfo ainfo) { CommandInfo info = ainfo.Add(GettextCatalog.GetString("E_rrors"), new Action(delegate { IdeApp.Preferences.ShowMessageBubbles.Value = ShowMessageBubbles.ForErrors; IdeApp.Preferences.DefaultHideMessageBubbles.Value = false; })); info.Checked = !IdeApp.Preferences.DefaultHideMessageBubbles && IdeApp.Preferences.ShowMessageBubbles.Value == ShowMessageBubbles.ForErrors; info = ainfo.Add(GettextCatalog.GetString("_Errors and Warnings"), new Action(delegate { IdeApp.Preferences.ShowMessageBubbles.Value = ShowMessageBubbles.ForErrorsAndWarnings; IdeApp.Preferences.DefaultHideMessageBubbles.Value = false; })); info.Checked = !IdeApp.Preferences.DefaultHideMessageBubbles && IdeApp.Preferences.ShowMessageBubbles == ShowMessageBubbles.ForErrorsAndWarnings; }
public void UpdateAddNodeBefore(CommandArrayInfo cinfo) { foreach (ExtensionNodeType ntype in GetAllowedChildTypes()) { cinfo.Add(ntype.NodeName, ntype); } }
protected override void Update(CommandArrayInfo info) { int i = 0; foreach (Document document in IdeApp.Workbench.Documents) { //Create CommandInfo object CommandInfo commandInfo = new CommandInfo(); commandInfo.Text = document.Window.Title.Replace("_", "__"); if (document == IdeApp.Workbench.ActiveDocument) { commandInfo.Checked = true; } commandInfo.Description = GettextCatalog.GetString("Activate window '{0}'", commandInfo.Text); if (document.Window.ShowNotification) { commandInfo.UseMarkup = true; document.Window.Title = "<span foreground=" + '"' + "blue" + '"' + ">" + commandInfo.Text + "</span>"; } //Add AccelKey if (i < 10) { commandInfo.AccelKey = ((PropertyService.IsMac) ? "Meta" : "Alt") + "|" + ((i + 1) % 10).ToString(); } //Add menu item info.Add(commandInfo, document); i++; } }
/// <summary> /// The Update method is used to determine if the command can run within the current context. /// /// Note that we have overriden the Update which provides a CommandArrayInfo object; in the /// manifest we provided 'array' to the type attribute. This specifies to the command engine that /// this command provides multiple choices that the user can execute. /// /// We provide a CommandInfoSet object into the provided CommandArrayInfo to specify all the choices /// are user can make when running our command; we provide multiple 'CommandInfos' to specify what the user /// can execute. /// </summary> /// <param name="info">Info.</param> protected override void Update(CommandArrayInfo info) { if (PropertyService.HasValue(PropertyKeys.TranslationApiPropertyKey) == false) { return; // Can't run } var doc = IdeApp.Workbench.ActiveDocument; var editor = doc.Editor; if (doc != null && editor != null) { var loc = editor.CaretLocation; Microsoft.CodeAnalysis.SyntaxToken token; if (SyntaxTokenHelper.ResolveSyntaxToken(doc, loc, out token)) { var commandSet = new CommandInfoSet(); commandSet.CommandInfos.Add(new CommandInfo("English"), new TranslationSetting("en", token)); commandSet.CommandInfos.Add(new CommandInfo("German"), new TranslationSetting("de", token)); commandSet.CommandInfos.Add(new CommandInfo("Spanish"), new TranslationSetting("es", token)); commandSet.CommandInfos.Add(new CommandInfo("French"), new TranslationSetting("fr", token)); info.Add(commandSet); } } }
protected override async Task UpdateAsync(CommandArrayInfo info, CancellationToken cancelToken) { var repo = Repository; if (repo == null) { return; } var wob = IdeApp.ProjectOperations.CurrentSelectedItem as WorkspaceObject; if (wob == null) { return; } if (((wob is WorkspaceItem) && ((WorkspaceItem)wob).ParentWorkspace == null) || (wob.BaseDirectory.CanonicalPath == repo.RootPath.CanonicalPath)) { var currentBranch = await repo.GetCurrentBranchAsync(cancelToken); foreach (var branch in await repo.GetLocalBranchNamesAsync(cancelToken)) { var ci = info.Add(branch, branch); if (branch == currentBranch) { ci.Checked = true; } } } }
protected override void Update(CommandArrayInfo info) { var files = DesktopService.RecentFiles.GetFiles(); if (files.Count == 0) { return; } int i = 0; foreach (var ri in files) { string acceleratorKeyPrefix = i < 10 ? "_" + ((i + 1) % 10).ToString() + " " : ""; var cmd = new CommandInfo(acceleratorKeyPrefix + ri.DisplayName.Replace("_", "__")) { Description = GettextCatalog.GetString("Open {0}", ri.FileName) }; Gdk.Pixbuf icon = DesktopService.GetPixbufForFile(ri.FileName, IconSize.Menu); #pragma warning disable 618 if (icon != null) { cmd.Icon = ImageService.GetStockId(icon, IconSize.Menu); } #pragma warning restore 618 info.Add(cmd, ri.FileName); i++; } }
public void OnAddSpecialDirectoryUpdate(CommandArrayInfo info) { AspNetAppProject proj = CurrentNode.DataItem as AspNetAppProject; if (proj == null) { return; } List <string> dirs = new List <string> (proj.GetSpecialDirectories()); dirs.Sort(); List <FilePath> fullPaths = new List <FilePath> (dirs.Count); foreach (string s in dirs) { fullPaths.Add(proj.BaseDirectory.Combine(s)); } RemoveDirsNotInProject(fullPaths, proj); if (fullPaths.Count == 0) { return; } foreach (string dir in dirs) { if (!fullPaths.Contains(proj.BaseDirectory.Combine(dir))) { continue; } info.Add(dir.Replace("_", "__"), dir); } }
public void OnSetBuildActionUpdate (CommandArrayInfo info) { Set<string> toggledActions = new Set<string> (); Project proj = null; foreach (ITreeNavigator node in CurrentNodes) { ProjectFile finfo = (ProjectFile) node.DataItem; //disallow multi-slect on more than one project, since available build actions may differ if (proj == null && finfo.Project != null) { proj = finfo.Project; } else if (proj == null || proj != finfo.Project) { info.Clear (); return; } toggledActions.Add (finfo.BuildAction); } foreach (string action in proj.GetBuildActions ()) { if (action == "--") { info.AddSeparator (); } else { CommandInfo ci = info.Add (action, action); ci.Checked = toggledActions.Contains (action); if (ci.Checked) ci.CheckedInconsistent = toggledActions.Count > 1; } } }
protected override void Update(CommandArrayInfo info) { foreach (Components.Window window in IdeApp.CommandService.TopLevelWindowStack) { #if !WINDOWS //we don't want include hidden windows if (!window.IsRealized || !window.IsVisible || Components.Mac.GtkMacInterop.IsGdkQuartzWindow(window)) { continue; } #endif //Create CommandInfo object var commandInfo = new CommandInfo(); commandInfo.Text = window.Title.Replace("_", "__").Replace("-", "\u2013").Replace(" \u2013 " + BrandingService.ApplicationName, ""); if (string.IsNullOrEmpty(commandInfo.Text)) { commandInfo.Text = GettextCatalog.GetString("No description"); } if (window.HasTopLevelFocus) { commandInfo.Checked = true; } commandInfo.Description = GettextCatalog.GetString("Activate window '{0}'", commandInfo.Text); //Add menu item info.Add(commandInfo, window.Title); } }
protected override void Update(CommandArrayInfo ainfo) { MonoDevelop.Ide.Gui.Document doc = IdeApp.Workbench.ActiveDocument; if (doc != null) { SourceEditorView view = IdeApp.Workbench.ActiveDocument.GetContent <SourceEditorView>(); if (view != null) { DocumentLocation location = view.TextEditor.Caret.Location; if (location.IsEmpty) { return; } DocumentLine line = view.Document.GetLine(location.Line); if (line == null || line.Markers == null) { return; } foreach (TextLineMarker marker in line.Markers) { UrlMarker urlMarker = marker as UrlMarker; if (urlMarker != null) { if (urlMarker.StartColumn <= location.Column && location.Column < urlMarker.EndColumn) { ainfo.Add(urlMarker.UrlType == UrlType.Email ? GettextCatalog.GetString("_Write an e-mail to...") : GettextCatalog.GetString("_Open URL..."), urlMarker); ainfo.AddSeparator(); } } } } } }
protected override void Update(CommandArrayInfo info) { var repo = Repository; if (repo == null) { return; } var wob = IdeApp.ProjectOperations.CurrentSelectedItem as IWorkspaceObject; if (wob == null) { return; } if (((wob is WorkspaceItem) && ((WorkspaceItem)wob).ParentWorkspace == null) || (wob.BaseDirectory.CanonicalPath == repo.RootPath.CanonicalPath)) { string currentBranch = repo.GetCurrentBranch(); foreach (Branch branch in repo.GetBranches()) { CommandInfo ci = info.Add(branch.FriendlyName, branch.FriendlyName); if (branch.FriendlyName == currentBranch) { ci.Checked = true; } } } }
protected void OnUpdateDebugTest(CommandArrayInfo info) { var debugModeSet = Runtime.ProcessService.GetDebugExecutionMode(); if (debugModeSet == null) { return; } UnitTest test = GetSelectedTest(); if (test == null) { return; } foreach (var mode in debugModeSet.ExecutionModes) { if (test.CanRun(mode.ExecutionHandler)) { info.Add(GettextCatalog.GetString("Debug Test ({0})", mode.Name), mode.Id); } } if (info.Count == 1) { info [0].Text = GettextCatalog.GetString("Debug Test"); } }
protected override void Update(CommandArrayInfo info) { base.Update(info); project = IdeApp.ProjectOperations.CurrentSelectedProject as DotNetProject; if (!ProjectSupportsFolderPublishing(project)) { return; } if (!project.GetPublishProfilesDirectory().Exists) { return; } var profiles = project.GetPublishProfiles(); foreach (var profile in profiles.OrderBy(x => x.Name)) { if (profile.WebPublishMethod == "FileSystem") { info.Add(GettextCatalog.GetString("Publish to {0} - {1}", profile.Name, profile.WebPublishMethod), new PublishCommandItem(project, profile)); } } }
protected override void Update(CommandArrayInfo info) { var windows = IdeApp.CommandService.TopLevelWindowStack.ToArray(); // enumerate only once if (windows.Length <= 1) { return; } int i = 0; foreach (Gtk.Window window in windows) { //Create CommandInfo object CommandInfo commandInfo = new CommandInfo(); commandInfo.Text = window.Title.Replace("_", "__").Replace("-", "\u2013").Replace(" \u2013 " + BrandingService.ApplicationName, ""); if (window.HasToplevelFocus) { commandInfo.Checked = true; } commandInfo.Description = GettextCatalog.GetString("Activate window '{0}'", commandInfo.Text); //Add menu item info.Add(commandInfo, window); i++; } }
protected override void Update(CommandArrayInfo info) { var repo = Repository; if (repo == null) { return; } var wob = IdeApp.ProjectOperations.CurrentSelectedItem as WorkspaceObject; if (wob == null) { return; } if (((wob is WorkspaceItem) && ((WorkspaceItem)wob).ParentWorkspace == null) || (wob.BaseDirectory.CanonicalPath == repo.RootPath.CanonicalPath)) { string currentBranch = GitRepository.DefaultNoBranchName; var getBranch = repo.GetCurrentBranchAsync(); if (getBranch.Wait(250)) { currentBranch = getBranch.Result; } foreach (var branch in repo.GetLocalBranchNamesAsync().Result) { CommandInfo ci = info.Add(branch, branch); if (branch == currentBranch) { ci.Checked = true; } } } }
protected override void Update(CommandArrayInfo info) { var files = IdeServices.DesktopService.RecentFiles.GetFiles(); if (files.Count == 0) { return; } int i = 0; var descFormat = GettextCatalog.GetString("Open {0}"); foreach (var ri in files) { string commandText = ri.DisplayName.Replace("_", "__"); if (!Platform.IsMac) { string acceleratorKeyPrefix = i < 10 ? "_" + ((i + 1) % 10).ToString() + " " : ""; commandText = acceleratorKeyPrefix + commandText; } var cmd = new CommandInfo(commandText) { Description = string.Format(descFormat, ri.FileName) }; /* Gdk.Pixbuf icon = IdeServices.DesktopService.GetIconForFile (ri.FileName, IconSize.Menu); #pragma warning disable 618 * if (icon != null) * cmd.Icon = ImageService.GetStockId (icon, IconSize.Menu); #pragma warning restore 618*/ info.Add(cmd, ri.FileName); i++; } }
static void AddCommand( CommandArrayInfo info, string label, bool enabled = false, object dataItem = null) { info.Add(CreateCommandInfo(label, enabled), dataItem); }
protected override void Update(CommandArrayInfo info) { for (int i = 0; i < IdeApp.Workbench.Pads.Count; i++) { Pad pad = IdeApp.Workbench.Pads[i]; CommandInfo ci = new CommandInfo(pad.Title); ci.Icon = pad.Icon; ci.UseMarkup = true; ci.Description = GettextCatalog.GetString("Show {0}", pad.Title); ci.Checked = pad.Visible; ActionCommand cmd = IdeApp.CommandService.GetActionCommand("Pad|" + pad.Id); if (cmd != null) { ci.AccelKey = cmd.AccelKey; } CommandArrayInfo list = info; if (pad.Categories != null) { for (int j = 0; j < pad.Categories.Length; j++) { bool found = false; for (int k = list.Count - 1; k >= 0; k--) { if (list[k].Text == pad.Categories[j] && list[k] is CommandInfoSet) { list = ((CommandInfoSet)list[k]).CommandInfos; found = true; break; } } if (!found) { CommandInfoSet set = new CommandInfoSet(); set.Text = pad.Categories[j]; set.Description = GettextCatalog.GetString("Show {0}", set.Text); list.Add(set); list = set.CommandInfos; } } } for (int j = list.Count - 1; j >= 0; j--) { if (!(list[j] is CommandInfoSet)) { list.Insert(j + 1, ci, pad); pad = null; break; } } if (pad != null) { list.Insert(0, ci, pad); } } }