From 464312c026d8b35f8a36c9783c1fd62fa3c743ea Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 6 Mar 2024 10:49:14 -0500 Subject: [PATCH] Fix index selected pages command (#1320) #1318 --- OneMore/Commands/Tagging/HashtagCommand.cs | 17 ++++++++------ OneMore/Commands/Tagging/HashtagDialog.cs | 26 +++++++++++----------- OneMore/Commands/Tagging/HashtagService.cs | 2 +- OneMore/Commands/Tagging/TaggedCommand.cs | 19 +++++++++------- OneMore/Commands/Tagging/TaggedDialog.cs | 4 ++-- OneMore/Properties/Resources.Designer.cs | 9 ++++++++ OneMore/Properties/Resources.ar-SA.resx | 4 ++++ OneMore/Properties/Resources.de-DE.resx | 4 ++++ OneMore/Properties/Resources.es-ES.resx | 4 ++++ OneMore/Properties/Resources.fr-FR.resx | 4 ++++ OneMore/Properties/Resources.he-IL.resx | 4 ++++ OneMore/Properties/Resources.nl-NL.resx | 4 ++++ OneMore/Properties/Resources.pl-PL.resx | 4 ++++ OneMore/Properties/Resources.pt-BR.resx | 4 ++++ OneMore/Properties/Resources.resx | 4 ++++ OneMore/Properties/Resources.zh-CN.resx | 4 ++++ 16 files changed, 86 insertions(+), 31 deletions(-) diff --git a/OneMore/Commands/Tagging/HashtagCommand.cs b/OneMore/Commands/Tagging/HashtagCommand.cs index 69db8b202b..a3a1e35e57 100644 --- a/OneMore/Commands/Tagging/HashtagCommand.cs +++ b/OneMore/Commands/Tagging/HashtagCommand.cs @@ -39,7 +39,7 @@ public override async Task Execute(params object[] args) dialog = new HashtagDialog(); dialog.FormClosed += Dialog_FormClosed; - await dialog.RunModeless((sender, e) => + await dialog.RunModeless(async (sender, e) => { var d = sender as HashtagDialog; if (d.DialogResult == DialogResult.OK) @@ -47,12 +47,15 @@ await dialog.RunModeless((sender, e) => command = d.Command; pageIds = d.SelectedPages.ToList(); - var desc = command == HashtagDialog.Commands.Copy - ? Resx.SearchQF_DescriptionCopy - : Resx.SearchQF_DescriptionMove; + var msg = command switch + { + HashtagDialog.Commands.Copy => Resx.SearchQF_DescriptionCopy, + HashtagDialog.Commands.Move => Resx.SearchQF_DescriptionMove, + _ => Resx.SearchQF_DescriptionIndex + }; - using var one = new OneNote(); - one.SelectLocation(Resx.SearchQF_Title, desc, OneNote.Scope.Sections, Callback); + await using var one = new OneNote(); + one.SelectLocation(Resx.SearchQF_Title, msg, OneNote.Scope.Sections, Callback); } }, 20); @@ -80,7 +83,7 @@ private async Task Callback(string sectionId) try { - using var one = new OneNote(); + await using var one = new OneNote(); var service = new SearchServices(one, sectionId); switch (command) diff --git a/OneMore/Commands/Tagging/HashtagDialog.cs b/OneMore/Commands/Tagging/HashtagDialog.cs index 54f7134f36..3ddbc8d02e 100644 --- a/OneMore/Commands/Tagging/HashtagDialog.cs +++ b/OneMore/Commands/Tagging/HashtagDialog.cs @@ -22,6 +22,7 @@ internal partial class HashtagDialog : MoreForm private readonly MoreAutoCompleteList palette; private readonly bool experimental; + private readonly List selections; public enum Commands @@ -55,6 +56,8 @@ public HashtagDialog() } + selections = new List(); + palette = new MoreAutoCompleteList { FreeText = true, @@ -78,19 +81,7 @@ public HashtagDialog() public Commands Command { get; private set; } - public IEnumerable SelectedPages - { - get - { - for (var i = 0; i < contextPanel.Controls.Count; i++) - { - if (contextPanel.Controls[i] is HashtagContextControl item && item.IsChecked) - { - yield return item.PageID; - } - } - } - } + public IEnumerable SelectedPages => selections; private void ShowScanTimes() @@ -225,6 +216,11 @@ private void Control_Checked(object sender, EventArgs e) if (!enabled) { + if (selections.Contains(control.PageID)) + { + selections.Remove(control.PageID); + } + for (int i = 0; i < contextPanel.Controls.Count; i++) { if (contextPanel.Controls[i] is HashtagContextControl item && item.IsChecked) @@ -234,6 +230,10 @@ private void Control_Checked(object sender, EventArgs e) } } } + else if (!selections.Contains(control.PageID)) + { + selections.Add(control.PageID); + } indexButton.Enabled = moveButton.Enabled = copyButton.Enabled = enabled; } diff --git a/OneMore/Commands/Tagging/HashtagService.cs b/OneMore/Commands/Tagging/HashtagService.cs index a8e2255ee8..38d6af60d4 100644 --- a/OneMore/Commands/Tagging/HashtagService.cs +++ b/OneMore/Commands/Tagging/HashtagService.cs @@ -92,7 +92,7 @@ public void Startup() thread.SetApartmentState(ApartmentState.STA); thread.IsBackground = true; - thread.Priority = ThreadPriority.Lowest; + thread.Priority = forcedRebuild ? ThreadPriority.Normal : ThreadPriority.Lowest; thread.Start(); } diff --git a/OneMore/Commands/Tagging/TaggedCommand.cs b/OneMore/Commands/Tagging/TaggedCommand.cs index ad7c7d0b86..2652c46ddf 100644 --- a/OneMore/Commands/Tagging/TaggedCommand.cs +++ b/OneMore/Commands/Tagging/TaggedCommand.cs @@ -1,5 +1,5 @@ //************************************************************************************************ -// Copyright © 2020 Steven M Cohn. All rights reserved. +// Copyright © 2020 Steven M Cohn. All rights reserved. //************************************************************************************************ namespace River.OneMoreAddIn.Commands @@ -8,7 +8,7 @@ namespace River.OneMoreAddIn.Commands using System.Collections.Generic; using System.Threading.Tasks; using System.Windows.Forms; - using Resx = River.OneMoreAddIn.Properties.Resources; + using Resx = Properties.Resources; internal class TaggedCommand : Command @@ -26,7 +26,7 @@ public override async Task Execute(params object[] args) { var dialog = new TaggedDialog(); - await dialog.RunModeless((sender, e) => + await dialog.RunModeless(async (sender, e) => { var d = sender as TaggedDialog; if (d.DialogResult == DialogResult.OK) @@ -34,12 +34,15 @@ await dialog.RunModeless((sender, e) => command = d.Command; pageIds = d.SelectedPages; - var desc = command == TaggedDialog.Commands.Copy - ? Resx.SearchQF_DescriptionCopy - : Resx.SearchQF_DescriptionMove; + var msg = command switch + { + TaggedDialog.Commands.Copy => Resx.SearchQF_DescriptionCopy, + TaggedDialog.Commands.Move => Resx.SearchQF_DescriptionMove, + _ => Resx.SearchQF_DescriptionIndex + }; - using var one = new OneNote(); - one.SelectLocation(Resx.SearchQF_Title, desc, OneNote.Scope.Sections, Callback); + await using var one = new OneNote(); + one.SelectLocation(Resx.SearchQF_Title, msg, OneNote.Scope.Sections, Callback); } }, 20); diff --git a/OneMore/Commands/Tagging/TaggedDialog.cs b/OneMore/Commands/Tagging/TaggedDialog.cs index f530fb742d..acfb80d809 100644 --- a/OneMore/Commands/Tagging/TaggedDialog.cs +++ b/OneMore/Commands/Tagging/TaggedDialog.cs @@ -1,5 +1,5 @@ //************************************************************************************************ -// Copyright © 2020 Steven M Cohn. All rights reserved. +// Copyright © 2020 Steven M Cohn. All rights reserved. //************************************************************************************************ namespace River.OneMoreAddIn.Commands @@ -12,7 +12,7 @@ namespace River.OneMoreAddIn.Commands using System.Text.RegularExpressions; using System.Windows.Forms; using System.Xml.Linq; - using Resx = River.OneMoreAddIn.Properties.Resources; + using Resx = Properties.Resources; internal partial class TaggedDialog : MoreForm diff --git a/OneMore/Properties/Resources.Designer.cs b/OneMore/Properties/Resources.Designer.cs index 064bc107c9..f45dd192a1 100644 --- a/OneMore/Properties/Resources.Designer.cs +++ b/OneMore/Properties/Resources.Designer.cs @@ -10334,6 +10334,15 @@ internal static string SearchQF_DescriptionCopy { } } + /// + /// Looks up a localized string similar to Pick the location to create the index page. + /// + internal static string SearchQF_DescriptionIndex { + get { + return ResourceManager.GetString("SearchQF_DescriptionIndex", resourceCulture); + } + } + /// /// Looks up a localized string similar to Pick the location where selected pages should be moved. /// diff --git a/OneMore/Properties/Resources.ar-SA.resx b/OneMore/Properties/Resources.ar-SA.resx index e2a085120d..c22a7c53e3 100644 --- a/OneMore/Properties/Resources.ar-SA.resx +++ b/OneMore/Properties/Resources.ar-SA.resx @@ -4138,6 +4138,10 @@ ISO-code then comma then language name اختر الموقع حيث يجب نسخ الصفحات المحددة QuickFiling description + + اختر الموقع لإنشاء صفحة الفهرس + QuickFiling description + اختر الموقع حيث يجب نقل الصفحات المحددة QuickFiling description diff --git a/OneMore/Properties/Resources.de-DE.resx b/OneMore/Properties/Resources.de-DE.resx index d705a445ca..54d17621e7 100644 --- a/OneMore/Properties/Resources.de-DE.resx +++ b/OneMore/Properties/Resources.de-DE.resx @@ -4131,6 +4131,10 @@ Suchmaschinen werden im Seit-Kontextmenü mit der rechten Maustaste angezeigt.Wähle den Ort aus, an den ausgewählte Seiten kopiert werden sollen QuickFiling description + + Wählen Sie den Ort aus, um die Indexseite zu erstellen + QuickFiling description + Wähle den Ort aus, an den ausgewählte Seiten verschoben werden sollen QuickFiling description diff --git a/OneMore/Properties/Resources.es-ES.resx b/OneMore/Properties/Resources.es-ES.resx index 0f65f96e3e..89ef2bbb81 100644 --- a/OneMore/Properties/Resources.es-ES.resx +++ b/OneMore/Properties/Resources.es-ES.resx @@ -4138,6 +4138,10 @@ Los motores de búsqueda aparecerán en el menú contextual de la página, haga Elija la ubicación donde se deben copiar las páginas seleccionadas QuickFiling description + + Elija la ubicación para crear la página de índice + QuickFiling description + Elija la ubicación donde se deben mover las páginas seleccionadas QuickFiling description diff --git a/OneMore/Properties/Resources.fr-FR.resx b/OneMore/Properties/Resources.fr-FR.resx index 458ecf63ec..0ec13e89d6 100644 --- a/OneMore/Properties/Resources.fr-FR.resx +++ b/OneMore/Properties/Resources.fr-FR.resx @@ -4136,6 +4136,10 @@ Les moteurs de recherche apparaîtront dans le menu du contexte de la page, cliq Choisissez l'emplacement où les pages sélectionnées doivent être copiées QuickFiling description + + Choisissez l'emplacement pour créer la page d'index + QuickFiling description + Choisissez l'emplacement où les pages sélectionnées doivent être déplacées QuickFiling description diff --git a/OneMore/Properties/Resources.he-IL.resx b/OneMore/Properties/Resources.he-IL.resx index aa98b6aa8b..188d7f8772 100644 --- a/OneMore/Properties/Resources.he-IL.resx +++ b/OneMore/Properties/Resources.he-IL.resx @@ -4149,6 +4149,10 @@ ISO-code then comma then language name בחר את המיקום בו יש להעתיק דפים שנבחרו QuickFiling description + + בחר את המיקום כדי ליצור את דף האינדקס + QuickFiling description + בחר את המיקום בו יש להעביר דפים שנבחרו QuickFiling description diff --git a/OneMore/Properties/Resources.nl-NL.resx b/OneMore/Properties/Resources.nl-NL.resx index bc447adf87..91a41aa3ff 100644 --- a/OneMore/Properties/Resources.nl-NL.resx +++ b/OneMore/Properties/Resources.nl-NL.resx @@ -4138,6 +4138,10 @@ Zoekmachines verschijnen in het pagina Pagina contextmenu, klik met de rechtermu Kies de locatie waar geselecteerde pagina's moeten worden gekopieerd QuickFiling description + + Kies de locatie om de indexpagina te maken + QuickFiling description + Kies de locatie waar geselecteerde pagina's moeten worden verplaatst QuickFiling description diff --git a/OneMore/Properties/Resources.pl-PL.resx b/OneMore/Properties/Resources.pl-PL.resx index 9afa4d00ba..60c542f61a 100644 --- a/OneMore/Properties/Resources.pl-PL.resx +++ b/OneMore/Properties/Resources.pl-PL.resx @@ -4151,6 +4151,10 @@ Wyszukiwarki pojawią się w menu kontekstowym strony, kliknij prawym przyciskie Wybierz lokalizację, w której należy skopiować wybrane strony QuickFiling description + + Wybierz lokalizację, aby utworzyć stronę indeksu + QuickFiling description + Wybierz lokalizację, w której należy przenieść wybrane strony QuickFiling description diff --git a/OneMore/Properties/Resources.pt-BR.resx b/OneMore/Properties/Resources.pt-BR.resx index ed7f5e8a36..2efe0180ea 100644 --- a/OneMore/Properties/Resources.pt-BR.resx +++ b/OneMore/Properties/Resources.pt-BR.resx @@ -4138,6 +4138,10 @@ Os mecanismos de pesquisa aparecerão no menu de contexto da página, clique com Escolha o local onde as páginas selecionadas devem ser copiadas QuickFiling description + + Escolha o local para criar a página de índice + QuickFiling description + Escolha o local para onde as páginas selecionadas devem ser movidas QuickFiling description diff --git a/OneMore/Properties/Resources.resx b/OneMore/Properties/Resources.resx index 786881738a..9a924cce43 100644 --- a/OneMore/Properties/Resources.resx +++ b/OneMore/Properties/Resources.resx @@ -4172,6 +4172,10 @@ Search engines will appear in the page context menu, right-click. Pick the location where selected pages should be copied QuickFiling description + + Pick the location to create the index page + QuickFiling description + Pick the location where selected pages should be moved QuickFiling description diff --git a/OneMore/Properties/Resources.zh-CN.resx b/OneMore/Properties/Resources.zh-CN.resx index a82b392e3c..3c8452f577 100644 --- a/OneMore/Properties/Resources.zh-CN.resx +++ b/OneMore/Properties/Resources.zh-CN.resx @@ -4131,6 +4131,10 @@ ISO-code then comma then language name 选择应该复制所选页面的位置 QuickFiling description + + 选择创建索引页的位置 + QuickFiling description + 选择应该移动选定页面的位置 QuickFiling description