diff --git a/OneMore/Commands/Page/ArrangeContainersCommand.cs b/OneMore/Commands/Page/ArrangeContainersCommand.cs index 7225f3f09f..3c850fa0b1 100644 --- a/OneMore/Commands/Page/ArrangeContainersCommand.cs +++ b/OneMore/Commands/Page/ArrangeContainersCommand.cs @@ -11,6 +11,7 @@ namespace River.OneMoreAddIn.Commands using System.Linq; using System.Threading.Tasks; using System.Xml.Linq; + using Resx = Properties.Resources; /// @@ -35,26 +36,34 @@ public ArrangeContainersCommand() public override async Task Execute(params object[] args) { + using var one = new OneNote(out page, out ns); + + if (!page.Root.Elements(ns + "Outline").Any()) + { + UIHelper.ShowInfo(Resx.ArrangeContainersCommand_noContainers); + return; + } + using var dialog = new ArrangeContainersDialog(); if (dialog.ShowDialog(owner) != System.Windows.Forms.DialogResult.OK) { return; } - using var one = new OneNote(out page, out ns); - FindTopMargin(); - if (dialog.Vertical) + var updated = dialog.Vertical + ? ArrangeVertical(dialog.PageWidth) + : ArrangeFlow(dialog.Columns, dialog.PageWidth); + + if (updated) { - ArrangeVertical(dialog.PageWidth); + await one.Update(page); } else { - ArrangeFlow(dialog.Columns, dialog.PageWidth); + UIHelper.ShowInfo(Resx.ArrangeContainersCommand_noContainers); } - - await one.Update(page); } @@ -79,10 +88,15 @@ private void FindTopMargin() } - private void ArrangeVertical(int pageWidth) + private bool ArrangeVertical(int pageWidth) { var containers = CollectContainers(page, ns); + if (!containers.Any()) + { + return false; + } + // find the topmost container position var yoffset = Math.Min( topMargin, @@ -106,13 +120,20 @@ private void ArrangeVertical(int pageWidth) var height = size.GetAttributeDouble("height"); yoffset += height + BottomMargin; } + + return true; } - private void ArrangeFlow(int columns, int pageWidth) + private bool ArrangeFlow(int columns, int pageWidth) { var containers = CollectContainers(page, ns); + if (!containers.Any()) + { + return false; + } + var xoffset = LeftMargin; // find the topmost container position @@ -161,6 +182,8 @@ private void ArrangeFlow(int columns, int pageWidth) xoffset += Math.Max(width, colwidth) + RightMargin; col++; } + + return true; } diff --git a/OneMore/Commands/Tagging/HashtagScanner.cs b/OneMore/Commands/Tagging/HashtagScanner.cs index 549ea1f005..372b11f14f 100644 --- a/OneMore/Commands/Tagging/HashtagScanner.cs +++ b/OneMore/Commands/Tagging/HashtagScanner.cs @@ -184,6 +184,9 @@ public void Dispose() dirtyPages++; } } + + // throttle the workload to give breathing room to OneNote UI + await Task.Delay(100); } provider.DeletePhantoms(pids, sectionID, sectionPath); diff --git a/OneMore/Properties/Resources.Designer.cs b/OneMore/Properties/Resources.Designer.cs index f00b011e53..1310d74c8b 100644 --- a/OneMore/Properties/Resources.Designer.cs +++ b/OneMore/Properties/Resources.Designer.cs @@ -493,6 +493,15 @@ internal static string ArchiveCommand_OpenFileTitle { } } + /// + /// Looks up a localized string similar to No containers found on this page. + /// + internal static string ArrangeContainersCommand_noContainers { + get { + return ResourceManager.GetString("ArrangeContainersCommand_noContainers", resourceCulture); + } + } + /// /// Looks up a localized string similar to Columns. /// diff --git a/OneMore/Properties/Resources.ar-SA.resx b/OneMore/Properties/Resources.ar-SA.resx index 7f919402d8..b3d78bbd3f 100644 --- a/OneMore/Properties/Resources.ar-SA.resx +++ b/OneMore/Properties/Resources.ar-SA.resx @@ -288,6 +288,10 @@ أرشفة الموقع archive dialog title + + لم يتم العثور على حاويات في هذه الصفحة + message + ترتيب الحاويات dialog title diff --git a/OneMore/Properties/Resources.de-DE.resx b/OneMore/Properties/Resources.de-DE.resx index 6b4814b8a6..4ba0fa9a1d 100644 --- a/OneMore/Properties/Resources.de-DE.resx +++ b/OneMore/Properties/Resources.de-DE.resx @@ -285,6 +285,10 @@ Archivstandort archive dialog title + + Auf dieser Seite wurden keine Container gefunden + message + Container anordnen dialog title diff --git a/OneMore/Properties/Resources.es-ES.resx b/OneMore/Properties/Resources.es-ES.resx index 5914baf0eb..adab0321c9 100644 --- a/OneMore/Properties/Resources.es-ES.resx +++ b/OneMore/Properties/Resources.es-ES.resx @@ -288,6 +288,10 @@ OneNote se cerrará automáticamente Ubicación del archivo archive dialog title + + No se encontraron contenedores en esta página. + message + Organizar contenedores dialog title diff --git a/OneMore/Properties/Resources.fr-FR.resx b/OneMore/Properties/Resources.fr-FR.resx index 7b4bc33646..41aab0a29d 100644 --- a/OneMore/Properties/Resources.fr-FR.resx +++ b/OneMore/Properties/Resources.fr-FR.resx @@ -285,6 +285,10 @@ Emplacement des archives archive dialog title + + Aucun conteneur trouvé sur cette page + message + Organiser les conteneurs dialog title diff --git a/OneMore/Properties/Resources.he-IL.resx b/OneMore/Properties/Resources.he-IL.resx index 3e1a2fa3ba..2c9a5a4406 100644 --- a/OneMore/Properties/Resources.he-IL.resx +++ b/OneMore/Properties/Resources.he-IL.resx @@ -299,6 +299,10 @@ OneNote ייסגר אוטומטית מיקום ארכיון archive dialog title + + לא נמצאו מיכלים בדף זה + message + מסדרים מיכלים dialog title diff --git a/OneMore/Properties/Resources.nl-NL.resx b/OneMore/Properties/Resources.nl-NL.resx index c70a00140f..bc616d5f75 100644 --- a/OneMore/Properties/Resources.nl-NL.resx +++ b/OneMore/Properties/Resources.nl-NL.resx @@ -289,6 +289,10 @@ OneNote wordt automatisch gesloten Archieflocatie archive dialog title + + Er zijn geen containers gevonden op deze pagina + message + Containers schikken dialog title diff --git a/OneMore/Properties/Resources.pl-PL.resx b/OneMore/Properties/Resources.pl-PL.resx index 3e6ac7838f..d749b02637 100644 --- a/OneMore/Properties/Resources.pl-PL.resx +++ b/OneMore/Properties/Resources.pl-PL.resx @@ -297,6 +297,10 @@ OneNote zamknie się automatycznie Lokalizacja archiwum. archive dialog title + + Na tej stronie nie znaleziono kontenerów + message + Ułóż pojemniki dialog title diff --git a/OneMore/Properties/Resources.pt-BR.resx b/OneMore/Properties/Resources.pt-BR.resx index cdf19c7d6a..fb0734c55b 100644 --- a/OneMore/Properties/Resources.pt-BR.resx +++ b/OneMore/Properties/Resources.pt-BR.resx @@ -289,6 +289,10 @@ OneNote fechará automaticamente Localização do arquivo archive dialog title + + Nenhum contêiner encontrado nesta página + message + Organizar recipientes dialog title diff --git a/OneMore/Properties/Resources.resx b/OneMore/Properties/Resources.resx index 4786260420..0db704702e 100644 --- a/OneMore/Properties/Resources.resx +++ b/OneMore/Properties/Resources.resx @@ -299,6 +299,10 @@ OneNote will close automatically Archive Location archive dialog title + + No containers found on this page + message + Arrange Containers dialog title diff --git a/OneMore/Properties/Resources.zh-CN.resx b/OneMore/Properties/Resources.zh-CN.resx index 19989b8efa..3b4a802b55 100644 --- a/OneMore/Properties/Resources.zh-CN.resx +++ b/OneMore/Properties/Resources.zh-CN.resx @@ -289,6 +289,10 @@ OneNote 将自动关闭 档案位置 archive dialog title + + 该页面未找到容器 + message + 排列容器 dialog title