diff --git a/OneMore/AddInCommands.cs b/OneMore/AddInCommands.cs index ab6755271b..0ae8d82d4d 100644 --- a/OneMore/AddInCommands.cs +++ b/OneMore/AddInCommands.cs @@ -607,6 +607,11 @@ public async Task NavigatorCmd(IRibbonControl control) => await factory.Run(); + [Command("ribNextUnreadPageButton_Label", Keys.None, "ribSearchMenu")] + public async Task NextUnreadPageCmd(IRibbonControl control) + => await factory.Run(); + + [Command("ribNewStyleButton_Label", Keys.None)] public async Task NewStyleCmd(IRibbonControl control) => await factory.Run(); @@ -673,6 +678,11 @@ public async Task PreviewMarkdownCmd(IRibbonControl control) => await factory.Run(); + [Command("ribPreviousUnreadPageButton_Label", Keys.None, "ribSearchMenu")] + public async Task PreviousUnreadPageCmd(IRibbonControl control) + => await factory.Run(); + + [Command("ribPronunciateButton_Label", Keys.None, "ribEditMenu")] public async Task PronunciateCmd(IRibbonControl control) => await factory.Run(); diff --git a/OneMore/Commands/Navigator/NextUnreadPageCommand.cs b/OneMore/Commands/Navigator/NextUnreadPageCommand.cs new file mode 100644 index 0000000000..55a24c9b76 --- /dev/null +++ b/OneMore/Commands/Navigator/NextUnreadPageCommand.cs @@ -0,0 +1,108 @@ +//************************************************************************************************ +// Copyright © 2024 Steven M Cohn. All rights reserved. +//************************************************************************************************ + +namespace River.OneMoreAddIn.Commands +{ + using System.Linq; + using System.Threading.Tasks; + using System.Xml.Linq; + using Resx = Properties.Resources; + + + #region Wrapper + internal class PreviousUnreadPageCommand : NextUnreadPageCommand + { + public PreviousUnreadPageCommand() : base() { } + public override Task Execute(params object[] args) + { + return base.Execute(false); + } + } + #endregion Wrapper + + + /// + /// Navigate to the next or previous unread page if any. + /// + internal class NextUnreadPageCommand : Command + { + public NextUnreadPageCommand() + { + } + + + public override async Task Execute(params object[] args) + { + var forward = args.Length == 0 || (bool)args[0]; + + await using var one = new OneNote(); + var notebooks = await one.GetNotebooks(); + var ns = notebooks.GetNamespaceOfPrefix(OneNote.Prefix); + + var books = notebooks.Elements(ns + "Notebook"); + if (!forward) + { + books = books.Reverse(); + } + + // load and scan one notebook at a time in case any are huge... + + XElement next = null; + foreach (var book in books) + { + var notebook = await one.GetNotebook( + book.Attribute("ID").Value, OneNote.Scope.Pages); + + // create a new root with a flat list of pages so ElementsAfter/BeforeSelf + // can be used to easily scan... + + var pages = new XElement(ns + "pages", + notebook.Descendants(ns + "Page").Where(e => + e.Attribute("isCurrentlyViewed") is not null || + e.Attribute("isUnread") is not null) + ); + + if (!pages.HasElements) + { + // must not be current notebook and has no unread pages + continue; + } + + if (notebook.Attribute("isCurrentlyViewed") is not null) + { + // find the anchor point + var current = pages.Elements() + .First(e => e.Attribute("isCurrentlyViewed") is not null); + + // find next unread in desired direction + next = forward + ? current.ElementsAfterSelf() + .FirstOrDefault(e => e.Attribute("isUnread") is not null) + : current.ElementsBeforeSelf() + .FirstOrDefault(e => e.Attribute("isUnread") is not null); + } + else + { + // in other notebook, no current page, so blindly grab the first unread found + next = forward + ? pages.Elements().First() + : pages.Elements().Last(); + } + + if (next is not null) + { + break; + } + } + + if (next is null) + { + ShowInfo(Resx.NextUnreadPageCommand_nomore); + return; + } + + await one.NavigateTo(next.Attribute("ID").Value); + } + } +} diff --git a/OneMore/OneMore.csproj b/OneMore/OneMore.csproj index f138d9c360..dbba083e34 100644 --- a/OneMore/OneMore.csproj +++ b/OneMore/OneMore.csproj @@ -148,6 +148,7 @@ + diff --git a/OneMore/Properties/Resources.Designer.cs b/OneMore/Properties/Resources.Designer.cs index de05662b80..8c200f3584 100644 --- a/OneMore/Properties/Resources.Designer.cs +++ b/OneMore/Properties/Resources.Designer.cs @@ -5149,6 +5149,15 @@ internal static string NetwordConnectionUnavailable { } } + /// + /// Looks up a localized string similar to No unread pages found in that direction. + /// + internal static string NextUnreadPageCommand_nomore { + get { + return ResourceManager.GetString("NextUnreadPageCommand_nomore", resourceCulture); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -8929,6 +8938,24 @@ internal static string ribNewStyleButton_Screentip { } } + /// + /// Looks up a localized string similar to Next Unread Page. + /// + internal static string ribNextUnreadPageButton_Label { + get { + return ResourceManager.GetString("ribNextUnreadPageButton_Label", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move to the next unread page. + /// + internal static string ribNextUnreadPageButton_Screentip { + get { + return ResourceManager.GetString("ribNextUnreadPageButton_Screentip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Disable spell check for entire page (F4). /// @@ -9208,6 +9235,24 @@ internal static string ribPreviewMarkdownButton_Screentip { } } + /// + /// Looks up a localized string similar to Previous Unread Page. + /// + internal static string ribPreviousUnreadPageButton_Label { + get { + return ResourceManager.GetString("ribPreviousUnreadPageButton_Label", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move to the previous unread page. + /// + internal static string ribPreviousUnreadPageButton_Screentip { + get { + return ResourceManager.GetString("ribPreviousUnreadPageButton_Screentip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Insert Pronunciation. /// diff --git a/OneMore/Properties/Resources.ar-SA.resx b/OneMore/Properties/Resources.ar-SA.resx index 959853a1a7..cfc8469e1f 100644 --- a/OneMore/Properties/Resources.ar-SA.resx +++ b/OneMore/Properties/Resources.ar-SA.resx @@ -1878,6 +1878,10 @@ اتصال الشبكة غير متوفر error + + لم يتم العثور على صفحات غير مقروءة في هذا الاتجاه + message + صفحة الترقيم {0} progress status dialog @@ -3511,6 +3515,14 @@ ISO-code then comma then language name قم بإنشاء نمط جديد من التحديد الحالي ribbon styles + + الصفحة التالية غير المقروءة + ribbon search + + + الانتقال إلى الصفحة التالية غير المقروءة + ribbon search + تعطيل التدقيق الإملائي للصفحة بأكملها (F4) Ribbon OneMore menu item, no spell check on this page @@ -3642,6 +3654,14 @@ ISO-code then comma then language name معاينة الصفحة أو النص المحدد كتخفيض ribbon edit + + الصفحة السابقة غير المقروءة + ribbon search + + + الانتقال إلى الصفحة غير المقروءة السابقة + ribbon search + أدخل النطق Ribbon OneMore menu item diff --git a/OneMore/Properties/Resources.de-DE.resx b/OneMore/Properties/Resources.de-DE.resx index 9d659386c8..bbbea23046 100644 --- a/OneMore/Properties/Resources.de-DE.resx +++ b/OneMore/Properties/Resources.de-DE.resx @@ -1876,6 +1876,10 @@ Benutzerdefinierte Überschrift 3 Netzwerkverbindung ist nicht verfügbar error + + In dieser Richtung wurden keine ungelesenen Seiten gefunden + message + Nummerierungsseite {0} progress status dialog @@ -3511,6 +3515,14 @@ Nach der letzten Gruppe Erstellt einen neuen Stil aus der aktuellen Auswahl ribbon styles + + Nächste ungelesene Seite + ribbon search + + + Gehen Sie zur nächsten ungelesenen Seite + ribbon search + Rechtschreibprüfung für ganze Seite deaktivieren (F4) Ribbon OneMore menu item, no spell check on this page @@ -3634,6 +3646,14 @@ Nach der letzten Gruppe Vorschau der Seite oder des ausgewählten Texts als Markdown ribbon edit + + Vorherige ungelesene Seite + ribbon search + + + Zur vorherigen ungelesenen Seite wechseln + ribbon search + Aussprache einfügen Ribbon OneMore menu item diff --git a/OneMore/Properties/Resources.es-ES.resx b/OneMore/Properties/Resources.es-ES.resx index 77fccd3d40..59436273c1 100644 --- a/OneMore/Properties/Resources.es-ES.resx +++ b/OneMore/Properties/Resources.es-ES.resx @@ -1878,6 +1878,10 @@ Título personalizado 3 La conexión de red no está disponible error + + No se encontraron páginas no leídas en esa dirección. + message + Página de numeración {0} progress status dialog @@ -3511,6 +3515,14 @@ Después del último grupo Crear un nuevo estilo a partir de la selección actual ribbon styles + + Siguiente página no leída + ribbon search + + + Pasar a la siguiente página no leída + ribbon search + Desactivar el corrector ortográfico para toda la página (F4) Ribbon OneMore menu item, no spell check on this page @@ -3642,6 +3654,14 @@ Después del último grupo Vista previa de la página o texto seleccionado como rebaja ribbon edit + + Página anterior no leída + ribbon search + + + Ir a la página anterior no leída + ribbon search + Insertar pronunciación Ribbon OneMore menu item diff --git a/OneMore/Properties/Resources.fr-FR.resx b/OneMore/Properties/Resources.fr-FR.resx index bc27f63023..3a750427c6 100644 --- a/OneMore/Properties/Resources.fr-FR.resx +++ b/OneMore/Properties/Resources.fr-FR.resx @@ -1878,6 +1878,10 @@ Titre personnalisé 3 La connexion réseau n'est pas disponible error + + Aucune page non lue trouvée dans cette direction + message + Page de numérotation {0} progress status dialog @@ -3510,6 +3514,14 @@ Après le dernier groupe Créer un nouveau style à partir de la sélection actuelle ribbon styles + + Page suivante non lue + ribbon search + + + Passer à la page suivante non lue + ribbon search + Désactiver la vérification orthographique pour toute la page (F4) Ribbon OneMore menu item, no spell check on this page @@ -3641,6 +3653,14 @@ Après le dernier groupe Aperçu de la page ou du texte sélectionné sous forme de démarque ribbon edit + + Page précédente non lue + ribbon search + + + Passer à la page précédente non lue + ribbon search + Insérer la prononciation Ribbon OneMore menu item diff --git a/OneMore/Properties/Resources.he-IL.resx b/OneMore/Properties/Resources.he-IL.resx index eb99162956..dc5b0d9c0d 100644 --- a/OneMore/Properties/Resources.he-IL.resx +++ b/OneMore/Properties/Resources.he-IL.resx @@ -1887,6 +1887,10 @@ Total Row Font חיבור רשת אינו זמין error + + לא נמצאו דפים שלא נקראו בכיוון זה + message + דף מספור {0} progress status dialog @@ -3530,6 +3534,14 @@ ISO-code then comma then language name צור סגנון חדש מהבחירה הנוכחית ribbon styles + + העמוד הבא שלא נקרא + ribbon search + + + עבור לדף הבא שלא נקרא + ribbon search + השבת את בדיקת האיות עבור כל העמוד (F4) Ribbon OneMore menu item, no spell check on this page @@ -3653,6 +3665,14 @@ ISO-code then comma then language name תצוגה מקדימה של דף או טקסט שנבחר כסימון ribbon edit + + הדף הקודם שלא נקרא + ribbon search + + + עבור לדף הקודם שלא נקרא + ribbon search + הכנס הגייה Ribbon OneMore menu item diff --git a/OneMore/Properties/Resources.nl-NL.resx b/OneMore/Properties/Resources.nl-NL.resx index bf30325958..9964017d1e 100644 --- a/OneMore/Properties/Resources.nl-NL.resx +++ b/OneMore/Properties/Resources.nl-NL.resx @@ -1879,6 +1879,10 @@ Aangepaste kop 3 Netwerkverbinding is niet beschikbaar error + + Geen ongelezen pagina's gevonden in die richting + message + Nummeringspagina {0} progress status dialog @@ -3511,6 +3515,14 @@ Na de laatste groep Maak een nieuwe stijl van de huidige selectie ribbon styles + + Volgende ongelezen pagina + ribbon search + + + Ga naar de volgende ongelezen pagina + ribbon search + Spellingcontrole voor hele pagina uitschakelen (F4) Ribbon OneMore menu item, no spell check on this page @@ -3642,6 +3654,14 @@ Na de laatste groep Bekijk een voorbeeld van de pagina of geselecteerde tekst als markdown ribbon edit + + Vorige ongelezen pagina + ribbon search + + + Naar de vorige ongelezen pagina gaan + ribbon search + Uitspraak invoegen Ribbon OneMore menu item diff --git a/OneMore/Properties/Resources.pl-PL.resx b/OneMore/Properties/Resources.pl-PL.resx index 8eff2a06a4..aabea8136d 100644 --- a/OneMore/Properties/Resources.pl-PL.resx +++ b/OneMore/Properties/Resources.pl-PL.resx @@ -1887,6 +1887,10 @@ Nagłówek niestandardowy 3 Połączenie sieciowe nie jest dostępne error + + Nie znaleziono nieprzeczytanych stron w tym kierunku + message + Numeracja strony {0} progress status dialog @@ -3524,6 +3528,14 @@ Po ostatniej grupie Utwórz nowy styl z bieżącego wyboru ribbon styles + + Następna nieprzeczytana strona + ribbon search + + + Przejdź do następnej nieprzeczytanej strony + ribbon search + Wyłącz czek czaru dla całej strony (F4) Ribbon OneMore menu item, no spell check on this page @@ -3655,6 +3667,14 @@ Po ostatniej grupie Podgląd strony lub zaznaczony tekst jako przecena ribbon edit + + Poprzednia nieprzeczytana strona + ribbon search + + + Przejdź do poprzedniej nieprzeczytanej strony + ribbon search + Wstaw wymowę Ribbon OneMore menu item diff --git a/OneMore/Properties/Resources.pt-BR.resx b/OneMore/Properties/Resources.pt-BR.resx index c83a8b1d10..229e222545 100644 --- a/OneMore/Properties/Resources.pt-BR.resx +++ b/OneMore/Properties/Resources.pt-BR.resx @@ -1879,6 +1879,10 @@ Título personalizado 3 A conexão de rede não está disponível error + + Nenhuma página não lida encontrada nessa direção + message + Página de numeração {0} progress status dialog @@ -3511,6 +3515,14 @@ Depois do último grupo Criar um novo estilo a partir da seleção atual ribbon styles + + Próxima página não lida + ribbon search + + + Ir para a próxima página não lida + ribbon search + Desativar verificação ortográfica para a página inteira (F4) Ribbon OneMore menu item, no spell check on this page @@ -3642,6 +3654,14 @@ Depois do último grupo Visualizar página ou texto selecionado como marcação ribbon edit + + Página anterior não lida + ribbon search + + + Mover para a página não lida anterior + ribbon search + Inserir pronúncia Ribbon OneMore menu item diff --git a/OneMore/Properties/Resources.resx b/OneMore/Properties/Resources.resx index aaac534889..f8a18fcf1a 100644 --- a/OneMore/Properties/Resources.resx +++ b/OneMore/Properties/Resources.resx @@ -1891,6 +1891,10 @@ Custom Heading 3 Network connection is not available error + + No unread pages found in that direction + message + Numbering page {0} progress status dialog @@ -3550,6 +3554,14 @@ After last group Create a new style from the current selection ribbon styles + + Next Unread Page + ribbon search + + + Move to the next unread page + ribbon search + Disable spell check for entire page (F4) OBSOLETE? @@ -3674,6 +3686,14 @@ After last group Preview page or selected text as markdown ribbon edit + + Previous Unread Page + ribbon search + + + Move to the previous unread page + ribbon search + Insert Pronunciation ribbon edit diff --git a/OneMore/Properties/Resources.zh-CN.resx b/OneMore/Properties/Resources.zh-CN.resx index 4fde7dc796..8c2b5ddc6f 100644 --- a/OneMore/Properties/Resources.zh-CN.resx +++ b/OneMore/Properties/Resources.zh-CN.resx @@ -1877,6 +1877,10 @@ OneNote 文件 (*.one) 网络连接不可用 error + + 在该方向没有找到未读页面 + message + 编号页{0} progress status dialog @@ -3512,6 +3516,14 @@ ISO-code then comma then language name 从当前选择创建新样式 ribbon styles + + 下一个未读页 + ribbon search + + + 移至下一个未读页面 + ribbon search + 禁用整个页面的拼写检查 (F4) Ribbon OneMore menu item, no spell check on this page @@ -3635,6 +3647,14 @@ ISO-code then comma then language name 以 Markdown 形式预览页面或所选文本 ribbon edit + + 上一页未读页 + ribbon search + + + 移至上一个未读页面 + ribbon search + 插入发音 Ribbon OneMore menu item diff --git a/OneMore/Ribbon/Ribbon.xml b/OneMore/Ribbon/Ribbon.xml index dd9aeb025a..9b7bb45a55 100644 --- a/OneMore/Ribbon/Ribbon.xml +++ b/OneMore/Ribbon/Ribbon.xml @@ -807,6 +807,18 @@ getLabel="GetRibbonLabel" getScreentip="GetRibbonScreentip" onAction="RemoveTagBankCmd"/> +