public override async Task Execute(params object[] args) { if (args.Length > 0 && args[0] is string refresh && refresh == "refresh") { synopses = args.Any(a => a as string == "synopsis"); unindexed = args.Any(a => a as string == "unindexed"); refreshing = Refresh(); } if (!refreshing) { using (var dialog = new LinkDialog()) { if (dialog.ShowDialog(owner) != System.Windows.Forms.DialogResult.OK) { return; } scope = dialog.Scope; synopses = dialog.Synopsis; unindexed = dialog.Unindexed; } } var progressDialog = new UI.ProgressDialog(Execute); await progressDialog.RunModeless(); }
public override async Task Execute(params object[] args) { using (one = new OneNote(out parentPage, out var ns, OneNote.PageDetail.Selection)) { var candidates = GetHyperlinks(parentPage); if (!candidates.Any()) { UIHelper.ShowMessage(Resx.CrawlWebCommand_NoHyperlinks); return; } using (var dialog = new CrawlWebPageDialog(candidates)) { if (dialog.ShowDialog(owner) != DialogResult.OK) { return; } selections = dialog.GetSelectedHyperlinks(); } // reverse so we create subpages in correct order selections.Reverse(); importer = new ImportWebCommand(); importer.SetLogger(logger); var progress = new UI.ProgressDialog(DownloadSelectedSubpages); progress.SetMaximum(selections.Count); await progress.RunModeless(); } }
public override async Task Execute(params object[] args) { using (var dialog = new MapDialog()) { if (dialog.ShowDialog(owner) != System.Windows.Forms.DialogResult.OK) { return; } scope = dialog.Scope; fullCatalog = dialog.FullCatalog; } var progressDialog = new UI.ProgressDialog(Execute); await progressDialog.RunModeless(); }
public override async Task Execute(params object[] args) { using (var dialog = new RefreshPageLinksDialog()) { if (dialog.ShowDialog(owner) != System.Windows.Forms.DialogResult.OK) { return; } scope = dialog.Scope; } using (var one = new OneNote(out var page, out _)) { // cleaned page title title = Unstamp(page.Title); // page's hyperlink section-id + page-id var uri = one.GetHyperlink(page.PageId, string.Empty); var match = Regex.Match(uri, "section-id={[0-9A-F-]+}&page-id={[0-9A-F-]+}&"); if (match.Success) { // ampersands aren't escaped in hyperlinks but they will be in XML keys = match.Groups[0].Value.Replace("&", "&"); } else { logger.WriteLine($"error finding section/page IDs in page hyperlink"); return; } } var progressDialog = new UI.ProgressDialog(Execute); await progressDialog.RunModeless((s, a) => { if (updates > 0) { UIHelper.ShowInfo(string.Format(Resx.RefreshPageLinksCommand_updated, updates)); } else { UIHelper.ShowInfo(Resx.RefreshPageLinksCommand_none); } }); }
public override async Task Execute(params object[] args) { var scope = args[0] as string; using (one = new OneNote()) { bookScope = scope == "notebook"; hierarchy = bookScope ? one.GetNotebook(one.CurrentNotebookId, OneNote.Scope.Pages) : one.GetSection(one.CurrentSectionId); var ns = one.GetNamespace(hierarchy); totalCount = hierarchy.Descendants(ns + "Page").Count(); if (totalCount == 0) { UIHelper.ShowMessage(Resx.ArchiveCommand_noPages); return; } var topName = hierarchy.Attribute("name").Value; zipPath = await SingleThreaded.Invoke(() => { // OpenFileDialog must run in STA thread return(ChooseLocation(topName)); }); if (zipPath == null) { return; } var progressDialog = new UI.ProgressDialog(Execute); await progressDialog.RunModeless(); } }