Skip to content

Commit

Permalink
Fix index selected pages command (stevencohn#1320)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevencohn authored and weissm committed Mar 10, 2024
1 parent d368387 commit 3423d93
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 31 deletions.
17 changes: 10 additions & 7 deletions OneMore/Commands/Tagging/HashtagCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,23 @@ 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)
{
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);
Expand Down Expand Up @@ -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)
Expand Down
26 changes: 13 additions & 13 deletions OneMore/Commands/Tagging/HashtagDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal partial class HashtagDialog : MoreForm

private readonly MoreAutoCompleteList palette;
private readonly bool experimental;
private readonly List<string> selections;


public enum Commands
Expand Down Expand Up @@ -55,6 +56,8 @@ public HashtagDialog()

}

selections = new List<string>();

palette = new MoreAutoCompleteList
{
FreeText = true,
Expand All @@ -78,19 +81,7 @@ public HashtagDialog()
public Commands Command { get; private set; }


public IEnumerable<string> 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<string> SelectedPages => selections;


private void ShowScanTimes()
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion OneMore/Commands/Tagging/HashtagService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
19 changes: 11 additions & 8 deletions OneMore/Commands/Tagging/TaggedCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//************************************************************************************************
// Copyright © 2020 Steven M Cohn. All rights reserved.
// Copyright © 2020 Steven M Cohn. All rights reserved.
//************************************************************************************************

namespace River.OneMoreAddIn.Commands
Expand All @@ -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
Expand All @@ -26,20 +26,23 @@ 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)
{
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);
Expand Down
4 changes: 2 additions & 2 deletions OneMore/Commands/Tagging/TaggedDialog.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//************************************************************************************************
// Copyright © 2020 Steven M Cohn. All rights reserved.
// Copyright © 2020 Steven M Cohn. All rights reserved.
//************************************************************************************************

namespace River.OneMoreAddIn.Commands
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions OneMore/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions OneMore/Properties/Resources.ar-SA.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4138,6 +4138,10 @@ ISO-code then comma then language name</comment>
<value>اختر الموقع حيث يجب نسخ الصفحات المحددة</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionIndex" xml:space="preserve">
<value>اختر الموقع لإنشاء صفحة الفهرس</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionMove" xml:space="preserve">
<value>اختر الموقع حيث يجب نقل الصفحات المحددة</value>
<comment>QuickFiling description</comment>
Expand Down
4 changes: 4 additions & 0 deletions OneMore/Properties/Resources.de-DE.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4131,6 +4131,10 @@ Suchmaschinen werden im Seit-Kontextmenü mit der rechten Maustaste angezeigt.</
<value>Wähle den Ort aus, an den ausgewählte Seiten kopiert werden sollen</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionIndex" xml:space="preserve">
<value>Wählen Sie den Ort aus, um die Indexseite zu erstellen</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionMove" xml:space="preserve">
<value>Wähle den Ort aus, an den ausgewählte Seiten verschoben werden sollen</value>
<comment>QuickFiling description</comment>
Expand Down
4 changes: 4 additions & 0 deletions OneMore/Properties/Resources.es-ES.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4138,6 +4138,10 @@ Los motores de búsqueda aparecerán en el menú contextual de la página, haga
<value>Elija la ubicación donde se deben copiar las páginas seleccionadas</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionIndex" xml:space="preserve">
<value>Elija la ubicación para crear la página de índice</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionMove" xml:space="preserve">
<value>Elija la ubicación donde se deben mover las páginas seleccionadas</value>
<comment>QuickFiling description</comment>
Expand Down
4 changes: 4 additions & 0 deletions OneMore/Properties/Resources.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4136,6 +4136,10 @@ Les moteurs de recherche apparaîtront dans le menu du contexte de la page, cliq
<value>Choisissez l'emplacement où les pages sélectionnées doivent être copiées</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionIndex" xml:space="preserve">
<value>Choisissez l'emplacement pour créer la page d'index</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionMove" xml:space="preserve">
<value>Choisissez l'emplacement où les pages sélectionnées doivent être déplacées</value>
<comment>QuickFiling description</comment>
Expand Down
4 changes: 4 additions & 0 deletions OneMore/Properties/Resources.he-IL.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4149,6 +4149,10 @@ ISO-code then comma then language name</comment>
<value>בחר את המיקום בו יש להעתיק דפים שנבחרו</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionIndex" xml:space="preserve">
<value>בחר את המיקום כדי ליצור את דף האינדקס</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionMove" xml:space="preserve">
<value>בחר את המיקום בו יש להעביר דפים שנבחרו</value>
<comment>QuickFiling description</comment>
Expand Down
4 changes: 4 additions & 0 deletions OneMore/Properties/Resources.nl-NL.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4138,6 +4138,10 @@ Zoekmachines verschijnen in het pagina Pagina contextmenu, klik met de rechtermu
<value>Kies de locatie waar geselecteerde pagina's moeten worden gekopieerd</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionIndex" xml:space="preserve">
<value>Kies de locatie om de indexpagina te maken</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionMove" xml:space="preserve">
<value>Kies de locatie waar geselecteerde pagina's moeten worden verplaatst</value>
<comment>QuickFiling description</comment>
Expand Down
4 changes: 4 additions & 0 deletions OneMore/Properties/Resources.pl-PL.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4151,6 +4151,10 @@ Wyszukiwarki pojawią się w menu kontekstowym strony, kliknij prawym przyciskie
<value>Wybierz lokalizację, w której należy skopiować wybrane strony</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionIndex" xml:space="preserve">
<value>Wybierz lokalizację, aby utworzyć stronę indeksu</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionMove" xml:space="preserve">
<value>Wybierz lokalizację, w której należy przenieść wybrane strony</value>
<comment>QuickFiling description</comment>
Expand Down
4 changes: 4 additions & 0 deletions OneMore/Properties/Resources.pt-BR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4138,6 +4138,10 @@ Os mecanismos de pesquisa aparecerão no menu de contexto da página, clique com
<value>Escolha o local onde as páginas selecionadas devem ser copiadas</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionIndex" xml:space="preserve">
<value>Escolha o local para criar a página de índice</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionMove" xml:space="preserve">
<value>Escolha o local para onde as páginas selecionadas devem ser movidas</value>
<comment>QuickFiling description</comment>
Expand Down
4 changes: 4 additions & 0 deletions OneMore/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4180,6 +4180,10 @@ Search engines will appear in the page context menu, right-click.</value>
<value>Pick the location where selected pages should be copied</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionIndex" xml:space="preserve">
<value>Pick the location to create the index page</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionMove" xml:space="preserve">
<value>Pick the location where selected pages should be moved</value>
<comment>QuickFiling description</comment>
Expand Down
4 changes: 4 additions & 0 deletions OneMore/Properties/Resources.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4131,6 +4131,10 @@ ISO-code then comma then language name</comment>
<value>选择应该复制所选页面的位置</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionIndex" xml:space="preserve">
<value>选择创建索引页的位置</value>
<comment>QuickFiling description</comment>
</data>
<data name="SearchQF_DescriptionMove" xml:space="preserve">
<value>选择应该移动选定页面的位置</value>
<comment>QuickFiling description</comment>
Expand Down

0 comments on commit 3423d93

Please sign in to comment.