From daf6971ac6e25f375405f38eafb5ea5b66ae2f4b Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Mon, 23 Dec 2024 16:13:09 +0000 Subject: [PATCH 01/13] Add Odotocodot.OneNote.Linq package reference --- Directory.Packages.props | 5 +++-- .../Microsoft.PowerToys.Run.Plugin.OneNote.csproj | 3 ++- src/modules/launcher/PowerLauncher/PowerLauncher.csproj | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index fe027f856adf..46fa48ac7e8d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -29,7 +29,7 @@ - + @@ -60,6 +60,7 @@ + @@ -98,4 +99,4 @@ - + \ No newline at end of file diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj index 4cc88d06e631..bcbcb52c7a86 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj @@ -17,7 +17,7 @@ 8981 - + false @@ -41,6 +41,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj index 07852dc804c0..d12895f18798 100644 --- a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj +++ b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj @@ -1,6 +1,6 @@  - + @@ -51,8 +51,9 @@ + - runtime + runtime From f23a0a6d0777c3189d863c57a21368588f338b44 Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Mon, 23 Dec 2024 16:25:32 +0000 Subject: [PATCH 02/13] Pull files from old branch --- .../Components/IconProvider.cs | 204 +++++++ .../Components/Keywords.cs | 19 + .../Components/OneNoteItemExtensions.cs | 49 ++ .../Components/OneNoteSettings.cs | 112 ++++ .../Components/ResultCreator.cs | 538 ++++++++++++++++++ .../Components/SearchManager.cs | 293 ++++++++++ .../Main.cs | 174 +++--- 7 files changed, 1305 insertions(+), 84 deletions(-) create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/IconProvider.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/Keywords.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteItemExtensions.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteSettings.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/IconProvider.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/IconProvider.cs new file mode 100644 index 000000000000..cd36a5eec56c --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/IconProvider.cs @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Concurrent; +using System.Diagnostics.CodeAnalysis; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Runtime.InteropServices; +using System.Windows.Media.Imaging; +using ManagedCommon; +using Odotocodot.OneNote.Linq; +using Wox.Infrastructure.Image; +using Wox.Plugin; +using Wox.Plugin.Logger; + +namespace Microsoft.PowerToys.Run.Plugin.OneNote.Components +{ + public class IconProvider + { + private readonly PluginInitContext _context; + private readonly OneNoteSettings _settings; + private readonly string _imagesDirectory; + private readonly string _generatedImagesDirectory; + private readonly ConcurrentDictionary _imageCache = new(); + + private bool _deleteColoredIconsOnCleanup; + + private string _powerToysTheme; + private string _pluginTheme; + + internal string NewPage => $"Images/page_new.{_pluginTheme}.png"; + + internal string NewSection => $"Images/section_new.{_pluginTheme}.png"; + + internal string NewSectionGroup => $"Images/section_group_new.{_pluginTheme}.png"; + + internal string NewNotebook => $"Images/notebook_new.{_pluginTheme}.png"; + + internal string Page => $"Images/page.{_pluginTheme}.png"; + + internal string Recent => $"Images/page_recent.{_pluginTheme}.png"; + + internal string Sync => $"Images/sync.{_pluginTheme}.png"; + + internal string Search => $"Images/search.{_pluginTheme}.png"; + + internal string NotebookExplorer => $"Images/notebook_explorer.{_pluginTheme}.png"; + + internal string Warning => $"Images/warning.{_powerToysTheme}.png"; + + internal string QuickNote => NewPage; + + internal IconProvider(PluginInitContext context, OneNoteSettings settings) + { + _settings = settings; + _context = context; + _settings.ColoredIconsSettingChanged += OnColoredIconsSettingChanged; + _context.API.ThemeChanged += OnThemeChanged; + + _imagesDirectory = $"{_context.CurrentPluginMetadata.PluginDirectory}/Images/"; + _generatedImagesDirectory = $"{_context.CurrentPluginMetadata.PluginDirectory}/Images/Generated/"; + + if (!Directory.Exists(_generatedImagesDirectory)) + { + Directory.CreateDirectory(_generatedImagesDirectory); + } + + foreach (var imagePath in Directory.EnumerateFiles(_generatedImagesDirectory)) + { + _imageCache.TryAdd(Path.GetFileNameWithoutExtension(imagePath), Path2Bitmap(imagePath)); + } + + UpdatePowerToysTheme(_context.API.GetCurrentTheme()); + } + + private void OnColoredIconsSettingChanged() + { + _deleteColoredIconsOnCleanup = !_settings.ColoredIcons; + UpdatePluginTheme(); + } + + private void OnThemeChanged(Theme oldTheme, Theme newTheme) => UpdatePowerToysTheme(newTheme); + + [MemberNotNull(nameof(_powerToysTheme))] + [MemberNotNull(nameof(_pluginTheme))] + private void UpdatePowerToysTheme(Theme theme) + { + _powerToysTheme = theme == Theme.Light || theme == Theme.HighContrastWhite ? "light" : "dark"; + UpdatePluginTheme(); + } + + [MemberNotNull(nameof(_pluginTheme))] + private void UpdatePluginTheme() => _pluginTheme = _settings.ColoredIcons ? "color" : _powerToysTheme; + + private BitmapSource GetColoredIcon(string itemType, Color itemColor) + { + return _imageCache.GetOrAdd($"{itemType}.{itemColor.ToArgb()}", key => + { + var color = itemColor; + using var bitmap = new Bitmap($"{_imagesDirectory}{itemType}.dark.png"); + BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, bitmap.PixelFormat); + + int bytesPerPixel = Image.GetPixelFormatSize(bitmap.PixelFormat) / 8; + byte[] pixels = new byte[bitmapData.Stride * bitmap.Height]; + IntPtr pointer = bitmapData.Scan0; + Marshal.Copy(pointer, pixels, 0, pixels.Length); + int bytesWidth = bitmapData.Width * bytesPerPixel; + + for (int j = 0; j < bitmapData.Height; j++) + { + int line = j * bitmapData.Stride; + for (int i = 0; i < bytesWidth; i += bytesPerPixel) + { + pixels[line + i] = color.B; + pixels[line + i + 1] = color.G; + pixels[line + i + 2] = color.R; + } + } + + Marshal.Copy(pixels, 0, pointer, pixels.Length); + bitmap.UnlockBits(bitmapData); + + var filePath = $"{_generatedImagesDirectory}{key}.png"; + bitmap.Save(filePath, ImageFormat.Png); + return Path2Bitmap(filePath); + }); + } + + private BitmapSource Path2Bitmap(string path) => WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize, Constant.ThumbnailSize, ThumbnailOptions.ThumbnailOnly); + + internal System.Windows.Media.ImageSource GetIcon(IOneNoteItem item) + { + string key; + switch (item) + { + case OneNoteNotebook notebook: + if (!_settings.ColoredIcons || notebook.Color is null) + { + key = $"{nameof(notebook)}.{_powerToysTheme}"; + break; + } + else + { + return GetColoredIcon(nameof(notebook), notebook.Color.Value); + } + + case OneNoteSectionGroup sectionGroup: + key = $"{(sectionGroup.IsRecycleBin ? $"recycle_bin" : $"section_group")}.{_pluginTheme}"; + break; + + case OneNoteSection section: + if (!_settings.ColoredIcons || section.Color is null) + { + key = $"{nameof(section)}.{_powerToysTheme}"; + break; + } + else + { + return GetColoredIcon(nameof(section), section.Color.Value); + } + + case OneNotePage: + key = Path.GetFileNameWithoutExtension(Page); + break; + + default: + throw new NotImplementedException(); + } + + return _imageCache.GetOrAdd(key, key => Path2Bitmap($"{_imagesDirectory}{key}.png")); + } + + internal void Cleanup() + { + _imageCache.Clear(); + if (_deleteColoredIconsOnCleanup) + { + foreach (var file in new DirectoryInfo(_generatedImagesDirectory).EnumerateFiles()) + { + try + { + file.Delete(); + } + catch (Exception ex) when (ex is DirectoryNotFoundException || ex is IOException) + { + Log.Error($"Failed to delete icon at \"{file}\"", GetType()); + } + } + } + + if (_settings != null) + { + _settings.ColoredIconsSettingChanged -= OnColoredIconsSettingChanged; + } + + if (_context != null && _context.API != null) + { + _context.API.ThemeChanged -= OnThemeChanged; + } + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/Keywords.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/Keywords.cs new file mode 100644 index 000000000000..9f9d169988fd --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/Keywords.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Microsoft.PowerToys.Run.Plugin.OneNote.Components +{ + public class Keywords + { + internal const string NotebookExplorerSeparator = "\\"; + + internal const string NotebookExplorer = $"nb:{NotebookExplorerSeparator}"; + + internal const string RecentPages = "rp:"; + + internal const string ScopedSearch = ">"; + + internal const string TitleSearch = "*"; + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteItemExtensions.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteItemExtensions.cs new file mode 100644 index 000000000000..714a08af8bef --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteItemExtensions.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics; +using System.Runtime.InteropServices; +using Odotocodot.OneNote.Linq; +using Windows.Win32; +using Windows.Win32.Foundation; +using Windows.Win32.UI.WindowsAndMessaging; + +namespace Microsoft.PowerToys.Run.Plugin.OneNote.Components +{ + internal static class OneNoteItemExtensions + { + internal static bool OpenItemInOneNote(this IOneNoteItem item) + { + try + { + item.OpenInOneNote(); + ShowOneNote(); + return true; + } + catch (COMException) + { + // The page, section or even notebook may no longer exist, ignore and do nothing. + return false; + } + } + + /// + /// Brings OneNote to the foreground and restores it if minimized. + /// + private static void ShowOneNote() + { + using var process = Process.GetProcessesByName("onenote").FirstOrDefault(); + if (process?.MainWindowHandle != null) + { + HWND handle = (HWND)process.MainWindowHandle; + if (PInvoke.IsIconic(handle)) + { + PInvoke.ShowWindow(handle, SHOW_WINDOW_CMD.SW_RESTORE); + } + + PInvoke.SetForegroundWindow(handle); + } + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteSettings.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteSettings.cs new file mode 100644 index 000000000000..c2ff7bb8e92f --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteSettings.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Windows.Controls; +using Microsoft.PowerToys.Settings.UI.Library; +using Wox.Plugin; + +namespace Microsoft.PowerToys.Run.Plugin.OneNote.Components +{ + public class OneNoteSettings : ISettingProvider + { + private bool coloredIcons; + + internal bool ShowUnreadItems { get; private set; } + + internal bool ShowEncryptedSections { get; private set; } + + internal bool ShowRecycleBins { get; private set; } + + // A timeout value is required as there currently no way to know if the Run window is visible. + internal double ComObjectTimeout { get; private set; } + + internal bool ColoredIcons + { + get => coloredIcons; + private set + { + coloredIcons = value; + ColoredIconsSettingChanged?.Invoke(); + } + } + + internal event Action? ColoredIconsSettingChanged; + + public IEnumerable AdditionalOptions => new List() + { + new PluginAdditionalOption() + { + Key = nameof(ShowUnreadItems), + PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Checkbox, + DisplayLabel = string.Empty, + DisplayDescription = string.Empty, + Value = true, + }, + new PluginAdditionalOption() + { + Key = nameof(ShowEncryptedSections), + PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Checkbox, + DisplayLabel = string.Empty, + DisplayDescription = string.Empty, + Value = true, + }, + new PluginAdditionalOption() + { + Key = nameof(ShowRecycleBins), + PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Checkbox, + DisplayLabel = string.Empty, + DisplayDescription = string.Empty, + Value = true, + }, + new PluginAdditionalOption() + { + Key = nameof(ComObjectTimeout), + PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Numberbox, + DisplayLabel = "Test", + DisplayDescription = "Test", + NumberValue = 10000, + NumberBoxMin = 1000, + NumberBoxMax = 120000, + NumberBoxSmallChange = 1000, + NumberBoxLargeChange = 50000, + }, + new PluginAdditionalOption() + { + Key = nameof(ColoredIcons), + PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Checkbox, + DisplayLabel = string.Empty, + DisplayDescription = string.Empty, + Value = true, + }, + }; + + public Control CreateSettingPanel() + { + throw new NotImplementedException(); + } + + public void UpdateSettings(PowerLauncherPluginSettings? settings) + { + if (settings?.AdditionalOptions == null) + { + return; + } + + ShowUnreadItems = GetBoolSettingOrDefault(settings, nameof(ShowUnreadItems)); + ShowEncryptedSections = GetBoolSettingOrDefault(settings, nameof(ShowEncryptedSections)); + ShowRecycleBins = GetBoolSettingOrDefault(settings, nameof(ShowRecycleBins)); + + var comObjectTimeout = settings.AdditionalOptions.FirstOrDefault(x => x.Key == nameof(ComObjectTimeout))?.NumberValue; + ComObjectTimeout = comObjectTimeout ?? AdditionalOptions.First(x => x.Key == nameof(ComObjectTimeout)).NumberValue; + + ColoredIcons = GetBoolSettingOrDefault(settings, nameof(ColoredIcons)); + } + + private bool GetBoolSettingOrDefault(PowerLauncherPluginSettings settings, string settingName) + { + var value = settings.AdditionalOptions.FirstOrDefault(x => x.Key == settingName)?.Value; + return value ?? AdditionalOptions.First(x => x.Key == settingName).Value; + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs new file mode 100644 index 000000000000..f6b7e2190207 --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs @@ -0,0 +1,538 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics; +using System.Reflection; +using System.Windows.Input; +using Odotocodot.OneNote.Linq; +using Wox.Infrastructure; +using Wox.Plugin; +using Wox.Plugin.Logger; + +namespace Microsoft.PowerToys.Run.Plugin.OneNote.Components +{ + public class ResultCreator + { + private readonly PluginInitContext _context; + private readonly OneNoteSettings _settings; + private readonly IconProvider _iconProvider; + + private const string PathSeparator = " > "; + private static readonly string _oldSeparator = OneNoteApplication.RelativePathSeparator.ToString(); + + internal ResultCreator(PluginInitContext context, OneNoteSettings settings, IconProvider iconProvider) + { + _settings = settings; + _context = context; + _iconProvider = iconProvider; + } + + private static string GetNicePath(IOneNoteItem item, string separator = PathSeparator) => item.RelativePath.Replace(_oldSeparator, separator); + + private string GetTitle(IOneNoteItem item, List? highlightData) + { + string title = item.Name; + if (item.IsUnread && _settings.ShowUnreadItems) + { + string unread = "\u2022 "; + title = title.Insert(0, unread); + + if (highlightData != null) + { + for (int i = 0; i < highlightData.Count; i++) + { + highlightData[i] += unread.Length; + } + } + } + + return title; + } + + private string GetQueryTextDisplay(IOneNoteItem item) => $"{Keywords.NotebookExplorer}{GetNicePath(item, Keywords.NotebookExplorerSeparator)}{Keywords.NotebookExplorerSeparator}"; + + private static string GetLastEdited(TimeSpan diff) + { + string lastEdited = "Last edited "; + if (PluralCheck(diff.TotalDays, "day", ref lastEdited) + || PluralCheck(diff.TotalHours, "hour", ref lastEdited) + || PluralCheck(diff.TotalMinutes, "min", ref lastEdited) + || PluralCheck(diff.TotalSeconds, "sec", ref lastEdited)) + { + return lastEdited; + } + else + { + return lastEdited += "Now."; + } + + static bool PluralCheck(double totalTime, string timeType, ref string lastEdited) + { + var roundedTime = (int)Math.Round(totalTime); + if (roundedTime > 0) + { + string plural = roundedTime == 1 ? string.Empty : "s"; + lastEdited += $"{roundedTime} {timeType}{plural} ago."; + return true; + } + else + { + return false; + } + } + } + + internal List EmptyQuery(Query query) + { + if (_context.CurrentPluginMetadata.IsGlobal && !query.RawUserQuery.StartsWith(query.ActionKeyword, StringComparison.Ordinal)) + { + return new List(); + } + + return new List + { + new Result + { + Title = "Search OneNote pages", + QueryTextDisplay = string.Empty, + IcoPath = _iconProvider.Search, + Score = 5000, + }, + new Result + { + Title = "View notebook explorer", + SubTitle = $"Type \"{Keywords.NotebookExplorer}\" or select this option to search by notebook structure ", + QueryTextDisplay = Keywords.NotebookExplorer, + IcoPath = _iconProvider.NotebookExplorer, + Score = 2000, + Action = ResultAction(() => + { + _context.API.ChangeQuery($"{_context.CurrentPluginMetadata.ActionKeyword} {Keywords.NotebookExplorer}", true); + return false; + }), + }, + new Result + { + Title = "See recent pages", + SubTitle = $"Type \"{Keywords.RecentPages}\" or select this option to see recently modified pages", + QueryTextDisplay = Keywords.RecentPages, + IcoPath = _iconProvider.Recent, + Score = -1000, + Action = ResultAction(() => + { + _context.API.ChangeQuery($"{_context.CurrentPluginMetadata.ActionKeyword} {Keywords.RecentPages}", true); + return false; + }), + }, + new Result + { + Title = "New quick note", + IcoPath = _iconProvider.QuickNote, + Score = -4000, + Action = ResultAction(() => + { + OneNoteApplication.CreateQuickNote(true); + return true; + }), + }, + new Result + { + Title = "Open and sync notebooks", + IcoPath = _iconProvider.Sync, + Score = int.MinValue, + Action = ResultAction(() => + { + foreach (var notebook in OneNoteApplication.GetNotebooks()) + { + notebook.Sync(); + } + + OneNoteApplication.GetNotebooks() + .GetPages() + .Where(i => !i.IsInRecycleBin) + .OrderByDescending(pg => pg.LastModified) + .First() + .OpenItemInOneNote(); + return true; + }), + }, + }; + } + + internal Result CreateOneNoteItemResult(IOneNoteItem item, bool actionIsAutoComplete, List? highlightData = null, int score = 0) + { + string title = GetTitle(item, highlightData); + string toolTip = string.Empty; + string subTitle = GetNicePath(item); + string queryTextDisplay = GetQueryTextDisplay(item); + + switch (item) + { + case OneNoteNotebook notebook: + toolTip = + $"Last Modified:\t{notebook.LastModified:F}\n" + + $"Sections:\t\t{notebook.Sections.Count()}\n" + + $"Sections Groups:\t{notebook.SectionGroups.Count()}"; + + subTitle = string.Empty; + break; + case OneNoteSectionGroup sectionGroup: + toolTip = + $"Path:\t\t{subTitle}\n" + + $"Last Modified:\t{sectionGroup.LastModified:F}\n" + + $"Sections:\t\t{sectionGroup.Sections.Count()}\n" + + $"Sections Groups:\t{sectionGroup.SectionGroups.Count()}"; + + break; + case OneNoteSection section: + if (section.Encrypted) + { + // potentially replace with glyphs if supported + title += $" [Encrypted] {(section.Locked ? "[Locked]" : "[Unlocked]")}"; + } + + toolTip = + $"Path:\t\t{subTitle}\n" + + $"Last Modified:\t{section.LastModified}\n" + + $"Pages:\t\t{section.Pages.Count()}"; + + break; + case OneNotePage page: + queryTextDisplay = !actionIsAutoComplete ? string.Empty : queryTextDisplay[..^1]; + + actionIsAutoComplete = false; + + subTitle = subTitle[..^(page.Name.Length + PathSeparator.Length)]; + toolTip = + $"Path:\t\t {subTitle} \n" + + $"Created:\t\t{page.Created:F}\n" + + $"Last Modified:\t{page.LastModified:F}"; + break; + } + + return new Result + { + Title = title, + ToolTipData = new ToolTipData(item.Name, toolTip), + TitleHighlightData = highlightData, + QueryTextDisplay = queryTextDisplay, + SubTitle = subTitle, + Score = score, + Icon = () => _iconProvider.GetIcon(item), + ContextData = item, + Action = ResultAction(() => + { + if (actionIsAutoComplete) + { + _context.API.ChangeQuery($"{_context.CurrentPluginMetadata.ActionKeyword} {queryTextDisplay}", true); + return false; + } + + item.Sync(); + item.OpenItemInOneNote(); + return true; + }), + }; + } + + internal Result CreatePageResult(OneNotePage page, string? query) + { + return CreateOneNoteItemResult(page, false, string.IsNullOrWhiteSpace(query) ? null : StringMatcher.FuzzySearch(query, page.Name).MatchData); + } + + internal Result CreateRecentPageResult(OneNotePage page) + { + var result = CreateOneNoteItemResult(page, false, null); + result.SubTitle = $"{GetLastEdited(DateTime.Now - page.LastModified)}\t{result.SubTitle}"; + result.IcoPath = _iconProvider.Page; + return result; + } + + internal Result CreateNewPageResult(string newPageName, OneNoteSection section) + { + newPageName = newPageName.Trim(); + return new Result + { + Title = $"Create page: \"{newPageName}\"", + SubTitle = $"Path: {GetNicePath(section)}{PathSeparator}{newPageName}", + QueryTextDisplay = $"{GetQueryTextDisplay}{newPageName}", + IcoPath = _iconProvider.NewPage, + Action = ResultAction(() => + { + OneNoteApplication.CreatePage(section, newPageName, true); + return true; + }), + }; + } + + internal Result CreateNewSectionResult(string newSectionName, IOneNoteItem parent) + { + newSectionName = newSectionName.Trim(); + bool validTitle = OneNoteApplication.IsSectionNameValid(newSectionName); + + return new Result + { + Title = $"Create section: \"{newSectionName}\"", + SubTitle = validTitle + ? $"Path: {GetNicePath(parent)}{PathSeparator}{newSectionName}" + : $"Section names cannot contain: {string.Join(' ', OneNoteApplication.InvalidSectionChars)}", + QueryTextDisplay = $"{GetQueryTextDisplay}{newSectionName}", + IcoPath = _iconProvider.NewSection, + Action = ResultAction(() => + { + if (!validTitle) + { + return false; + } + + switch (parent) + { + case OneNoteNotebook notebook: + OneNoteApplication.CreateSection(notebook, newSectionName, true); + break; + case OneNoteSectionGroup sectionGroup: + OneNoteApplication.CreateSection(sectionGroup, newSectionName, true); + break; + default: + break; + } + + _context.API.ChangeQuery(_context.CurrentPluginMetadata.ActionKeyword, true); + return true; + }), + }; + } + + internal Result CreateNewSectionGroupResult(string newSectionGroupName, IOneNoteItem parent) + { + newSectionGroupName = newSectionGroupName.Trim(); + bool validTitle = OneNoteApplication.IsSectionGroupNameValid(newSectionGroupName); + + return new Result + { + Title = $"Create section group: \"{newSectionGroupName}\"", + SubTitle = validTitle + ? $"Path: {GetNicePath(parent)}{PathSeparator}{newSectionGroupName}" + : $"Section group names cannot contain: {string.Join(' ', OneNoteApplication.InvalidSectionGroupChars)}", + QueryTextDisplay = $"{GetQueryTextDisplay}{newSectionGroupName}", + IcoPath = _iconProvider.NewSectionGroup, + Action = ResultAction(() => + { + if (!validTitle) + { + return false; + } + + switch (parent) + { + case OneNoteNotebook notebook: + OneNoteApplication.CreateSectionGroup(notebook, newSectionGroupName, true); + break; + case OneNoteSectionGroup sectionGroup: + OneNoteApplication.CreateSectionGroup(sectionGroup, newSectionGroupName, true); + break; + default: + break; + } + + _context.API.ChangeQuery(_context.CurrentPluginMetadata.ActionKeyword, true); + return true; + }), + }; + } + + internal Result CreateNewNotebookResult(string newNotebookName) + { + newNotebookName = newNotebookName.Trim(); + bool validTitle = OneNoteApplication.IsNotebookNameValid(newNotebookName); + + return new Result + { + Title = $"Create notebook: \"{newNotebookName}\"", + SubTitle = validTitle + ? $"Location: {OneNoteApplication.GetDefaultNotebookLocation()}" + : $"Notebook names cannot contain: {string.Join(' ', OneNoteApplication.InvalidNotebookChars)}", + QueryTextDisplay = $"{GetQueryTextDisplay}{newNotebookName}", + IcoPath = _iconProvider.NewNotebook, + Action = ResultAction(() => + { + if (!validTitle) + { + return false; + } + + OneNoteApplication.CreateNotebook(newNotebookName, true); + _context.API.ChangeQuery(_context.CurrentPluginMetadata.ActionKeyword, true); + return true; + }), + }; + } + + internal List LoadContextMenu(Result selectedResult) + { + var results = new List(); + if (selectedResult.ContextData is IOneNoteItem item) + { + results.Add(new ContextMenuResult + { + PluginName = Assembly.GetExecutingAssembly().GetName().Name, + Title = "Open and sync", + Glyph = "\xE8A7", + FontFamily = "Segoe MDL2 Assets", + AcceleratorKey = Key.Enter, + AcceleratorModifiers = ModifierKeys.Shift, + Action = ResultAction(() => + { + item.Sync(); + item.OpenItemInOneNote(); + return true; + }), + }); + + if (item is not OneNotePage) + { + results.Add(new ContextMenuResult + { + PluginName = Assembly.GetExecutingAssembly().GetName().Name, + Title = "Open in notebook explorer", + Glyph = "\xEC50", + FontFamily = "Segoe MDL2 Assets", + AcceleratorKey = Key.Enter, + AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift, + Action = ResultAction(() => + { + _context.API.ChangeQuery(selectedResult.QueryTextDisplay, true); + return false; + }), + }); + } + } + + if (selectedResult.ContextData is string url) + { + results.Add(new ContextMenuResult + { + PluginName = Assembly.GetExecutingAssembly().GetName().Name, + Title = "Visit the Microsoft Store", + Glyph = "\xE8A7", + FontFamily = "Segoe MDL2 Assets", + AcceleratorKey = Key.Enter, + AcceleratorModifiers = ModifierKeys.Shift, + Action = ResultAction(() => + { + try + { + Process.Start(url); + } + catch (Exception ex) + { + Log.Exception(ex.Message, ex, GetType()); + } + + return true; + }), + }); + } + + return results; + } + + internal List NoItemsInCollection(IOneNoteItem? parent, List results) + { + // parent can be null if the collection only contains notebooks. + switch (parent) + { + case OneNoteNotebook: + case OneNoteSectionGroup: + // Can create section/section group + results.Add(NoItemsInCollectionResult("section", _iconProvider.NewSection, "(unencrypted) section")); + results.Add(NoItemsInCollectionResult("section group", _iconProvider.NewSectionGroup)); + break; + case OneNoteSection section: + // Can create page + if (!section.Locked) + { + results.Add(NoItemsInCollectionResult("page", _iconProvider.NewPage)); + } + + break; + default: + break; + } + + return results; + + static Result NoItemsInCollectionResult(string title, string iconPath, string? subTitle = null) + { + return new Result + { + Title = $"Create {title}: \"\"", + SubTitle = $"No {subTitle ?? title}s found. Type a valid title to create one", + IcoPath = iconPath, + }; + } + } + + // TODO Localize + internal List NoMatchesFound(bool show) + { + return show + ? SingleResult( + "No matches found", + "Try searching something else, or syncing your notebooks.", + _iconProvider.Search) + : new List(); + } + + internal List InvalidQuery(bool show) + { + return show + ? SingleResult( + "Invalid query", + "The first character of the search must be a letter or a digit", + _iconProvider.Warning) + : new List(); + } + + internal List OneNoteNotInstalled() + { + var results = SingleResult( + "OneNote is not installed", + "Please install OneNote to use this plugin", + _iconProvider.Warning); + + results[0].ContextData = "https://apps.microsoft.com/store/detail/XPFFZHVGQWWLHB?ocid=pdpshare"; + return results; + } + + internal static List SingleResult(string title, string? subTitle, string iconPath) + { + return new List + { + new Result + { + Title = title, + SubTitle = subTitle, + IcoPath = iconPath, + }, + }; + } + + internal static Func ResultAction(Func func) + { + return _ => + { + bool result = func(); + + // Closing the Run window, so can release the COM Object + if (result) + { + Task.Run(OneNoteApplication.ReleaseComObject); + } + + return result; + }; + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs new file mode 100644 index 000000000000..e7b99409015b --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs @@ -0,0 +1,293 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Odotocodot.OneNote.Linq; +using Wox.Infrastructure; +using Wox.Plugin; + +namespace Microsoft.PowerToys.Run.Plugin.OneNote.Components +{ + public class SearchManager + { + private readonly PluginInitContext _context; + private readonly OneNoteSettings _settings; + private readonly IconProvider _iconProvider; + private readonly ResultCreator _resultCreator; + private readonly NotebookExplorer _notebookExplorer; + + // If the plugin is in global mode and does not start with the action keyword, do not show single results like invalid query. + private bool showSingleResults = true; + + internal SearchManager(PluginInitContext context, OneNoteSettings settings, IconProvider iconProvider, ResultCreator resultCreator) + { + _context = context; + _settings = settings; + _resultCreator = resultCreator; + _iconProvider = iconProvider; + _notebookExplorer = new NotebookExplorer(this, resultCreator, iconProvider); + } + + internal List Query(Query query) + { + if (_context.CurrentPluginMetadata.IsGlobal) + { + showSingleResults = query.RawUserQuery.StartsWith(_context.CurrentPluginMetadata.ActionKeyword, StringComparison.Ordinal); + } + + return query.Search switch + { + string s when s.StartsWith(Keywords.RecentPages, StringComparison.Ordinal) + => RecentPages(s), + + string s when s.StartsWith(Keywords.NotebookExplorer, StringComparison.Ordinal) + => _notebookExplorer.Query(query), + + string s when s.StartsWith(Keywords.TitleSearch, StringComparison.Ordinal) + => TitleSearch(s, null, OneNoteApplication.GetNotebooks()), + + _ => DefaultSearch(query.Search), + }; + } + + private List DefaultSearch(string query) + { + // Check for invalid start of query i.e. symbols + if (!char.IsLetterOrDigit(query[0])) + { + return _resultCreator.InvalidQuery(showSingleResults); + } + + var results = OneNoteApplication.FindPages(query) + .Select(pg => _resultCreator.CreatePageResult(pg, query)); + + return results.Any() ? results.ToList() : _resultCreator.NoMatchesFound(showSingleResults); + } + + private List TitleSearch(string query, IOneNoteItem? parent, IEnumerable currentCollection) + { + if (query.Length == Keywords.TitleSearch.Length && parent == null) + { + return ResultCreator.SingleResult($"Now searching by title.", null, _iconProvider.Search); + } + + List? highlightData = null; + int score = 0; + + var currentSearch = query[Keywords.TitleSearch.Length..]; + + var results = currentCollection.Traverse(item => SettingsCheck(item) && FuzzySearch(item.Name, currentSearch, out highlightData, out score)) + .Select(item => _resultCreator.CreateOneNoteItemResult(item, false, highlightData, score)) + .ToList(); + + return results.Count != 0 ? results : _resultCreator.NoMatchesFound(showSingleResults); + } + + private List RecentPages(string query) + { + int count = 10; // TODO: Ideally this should match PowerToysRunSettings.MaxResultsToShow +/* var settingsUtils = new SettingsUtils(); + var generalSettings = settingsUtils.GetSettings();*/ + if (query.Length > Keywords.RecentPages.Length && int.TryParse(query[Keywords.RecentPages.Length..], out int userChosenCount)) + { + count = userChosenCount; + } + + return OneNoteApplication.GetNotebooks() + .GetPages() + .Where(SettingsCheck) + .OrderByDescending(pg => pg.LastModified) + .Take(count) + .Select(_resultCreator.CreateRecentPageResult) + .ToList(); + } + + private bool FuzzySearch(string itemName, string search, out List highlightData, out int score) + { + var matchResult = StringMatcher.FuzzySearch(search, itemName); + highlightData = matchResult.MatchData; + score = matchResult.Score; + return matchResult.IsSearchPrecisionScoreMet(); + } + + private bool SettingsCheck(IOneNoteItem item) + { + bool success = true; + if (!_settings.ShowEncryptedSections && item is OneNoteSection section) + { + success = !section.Encrypted; + } + + if (!_settings.ShowRecycleBins && item.IsInRecycleBin()) + { + success = false; + } + + return success; + } + + private sealed class NotebookExplorer + { + private readonly SearchManager _searchManager; + private readonly ResultCreator _resultCreator; + private readonly IconProvider _iconProvider; + + internal NotebookExplorer(SearchManager searchManager, ResultCreator resultCreator, IconProvider iconProvider) + { + _searchManager = searchManager; + _resultCreator = resultCreator; + _iconProvider = iconProvider; + } + + internal List Query(Query query) + { + var results = new List(); + + string fullSearch = query.Search[(query.Search.IndexOf(Keywords.NotebookExplorer, StringComparison.Ordinal) + Keywords.NotebookExplorer.Length)..]; + + IOneNoteItem? parent = null; + IEnumerable collection = OneNoteApplication.GetNotebooks(); + + string[] searches = fullSearch.Split(Keywords.NotebookExplorerSeparator, StringSplitOptions.None); + + for (int i = -1; i < searches.Length - 1; i++) + { + if (i < 0) + { + continue; + } + + parent = collection.FirstOrDefault(item => item.Name.Equals(searches[i], StringComparison.Ordinal)); + if (parent == null) + { + return results; + } + + collection = parent.Children; + } + + string lastSearch = searches[^1]; + + results = lastSearch switch + { + // Empty search so show all in collection + string search when string.IsNullOrWhiteSpace(search) + => EmptySearch(parent, collection), + + // Search by title + string search when search.StartsWith(Keywords.TitleSearch, StringComparison.Ordinal) && parent is not OneNotePage + => _searchManager.TitleSearch(search, parent, collection), + + // Scoped search + string search when search.StartsWith(Keywords.ScopedSearch, StringComparison.Ordinal) && (parent is OneNoteNotebook || parent is OneNoteSectionGroup) + => ScopedSearch(search, parent), + + // Default search + _ => Explorer(lastSearch, parent, collection), + }; + + if (parent != null) + { + var result = _resultCreator.CreateOneNoteItemResult(parent, false, score: 4000); + result.Title = $"Open \"{parent.Name}\" in OneNote"; + result.SubTitle = lastSearch switch + { + string search when search.StartsWith(Keywords.TitleSearch, StringComparison.Ordinal) + => $"Now search by title in \"{parent.Name}\"", + + string search when search.StartsWith(Keywords.ScopedSearch, StringComparison.Ordinal) + => $"Now searching all pages in \"{parent.Name}\"", + + _ => $"Use \'{Keywords.ScopedSearch}\' to search this item. Use \'{Keywords.TitleSearch}\' to search by title in this item", + }; + + results.Add(result); + } + + return results; + } + + private List EmptySearch(IOneNoteItem? parent, IEnumerable collection) + { + List results = collection.Where(_searchManager.SettingsCheck) + .Select(item => _resultCreator.CreateOneNoteItemResult(item, true)) + .ToList(); + + return results.Count == 0 ? _resultCreator.NoItemsInCollection(parent, results) : results; + } + + private List ScopedSearch(string query, IOneNoteItem parent) + { + if (query.Length == Keywords.ScopedSearch.Length) + { + return _resultCreator.NoMatchesFound(_searchManager.showSingleResults); + } + + if (!char.IsLetterOrDigit(query[Keywords.ScopedSearch.Length])) + { + return _resultCreator.InvalidQuery(_searchManager.showSingleResults); + } + + string currentSearch = query[Keywords.TitleSearch.Length..]; + var results = new List(); + + results = OneNoteApplication.FindPages(currentSearch, parent) + .Select(pg => _resultCreator.CreatePageResult(pg, currentSearch)) + .ToList(); + + if (results.Count == 0) + { + results = _resultCreator.NoMatchesFound(_searchManager.showSingleResults); + } + + return results; + } + + private List Explorer(string search, IOneNoteItem? parent, IEnumerable collection) + { + List? highlightData = null; + int score = 0; + + var results = collection.Where(_searchManager.SettingsCheck) + .Where(item => _searchManager.FuzzySearch(item.Name, search, out highlightData, out score)) + .Select(item => _resultCreator.CreateOneNoteItemResult(item, true, highlightData, score)) + .ToList(); + + AddCreateNewOneNoteItemResults(search, parent, results); + return results; + } + + private void AddCreateNewOneNoteItemResults(string newItemName, IOneNoteItem? parent, List results) + { + if (!results.Any(result => string.Equals(newItemName.Trim(), result.Title, StringComparison.OrdinalIgnoreCase))) + { + if (parent?.IsInRecycleBin() == true) + { + return; + } + + switch (parent) + { + case null: + results.Add(_resultCreator.CreateNewNotebookResult(newItemName)); + break; + case OneNoteNotebook: + case OneNoteSectionGroup: + results.Add(_resultCreator.CreateNewSectionResult(newItemName, parent)); + results.Add(_resultCreator.CreateNewSectionGroupResult(newItemName, parent)); + break; + case OneNoteSection section: + if (!section.Locked) + { + results.Add(_resultCreator.CreateNewPageResult(newItemName, section)); + } + + break; + default: + break; + } + } + } + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Main.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Main.cs index 129350f51c7f..25fdb639e85a 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Main.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Main.cs @@ -2,53 +2,42 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; - -using LazyCache; -using ManagedCommon; +using System.Windows.Controls; +using Microsoft.PowerToys.Run.Plugin.OneNote.Components; using Microsoft.PowerToys.Run.Plugin.OneNote.Properties; -using ScipBe.Common.Office.OneNote; -using Windows.Win32; -using Windows.Win32.Foundation; -using Windows.Win32.UI.WindowsAndMessaging; +using Microsoft.PowerToys.Settings.UI.Library; +using Microsoft.PowerToys.Settings.UI.Library.Utilities; +using Odotocodot.OneNote.Linq; using Wox.Plugin; +using Timer = System.Timers.Timer; namespace Microsoft.PowerToys.Run.Plugin.OneNote { /// /// A power launcher plugin to search across time zones. /// - public class Main : IPlugin, IDelayedExecutionPlugin, IPluginI18n + public class Main : IPlugin, IDelayedExecutionPlugin, IPluginI18n, ISettingProvider, IContextMenu, IDisposable { + private readonly Timer _comObjectTimeout = new(); + + private readonly OneNoteSettings _settings = new(); + /// /// A value indicating if the OneNote interop library was able to successfully initialize. /// private bool _oneNoteInstalled; - /// - /// LazyCache CachingService instance to speed up repeated queries. - /// - private CachingService? _cache; - /// /// The initial context for this plugin (contains API and meta-data) /// private PluginInitContext? _context; - /// - /// The path to the icon for each result - /// - private string _iconPath; + private SearchManager? _searchManager; + private IconProvider? _iconProvider; + private ResultCreator? _resultCreator; - /// - /// Initializes a new instance of the class. - /// - public Main() - { - UpdateIconPath(Theme.Light); - } + private bool _disposed; /// /// Gets the localized name. @@ -65,6 +54,8 @@ public Main() /// public static string PluginID => "0778F0C264114FEC8A3DF59447CF0A74"; + public IEnumerable AdditionalOptions => _settings.AdditionalOptions; + /// /// Initialize the plugin with the given /// @@ -72,14 +63,11 @@ public Main() public void Init(PluginInitContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); - try { - _ = OneNoteProvider.PageItems.Any(); - _oneNoteInstalled = true; - - _cache = new CachingService(); - _cache.DefaultCachePolicy.DefaultCacheDurationSeconds = (int)TimeSpan.FromDays(1).TotalSeconds; + OneNoteApplication.InitComObject(); + _oneNoteInstalled = OneNoteApplication.HasComObject; + OneNoteApplication.ReleaseComObject(); } catch (COMException) { @@ -87,8 +75,13 @@ public void Init(PluginInitContext context) _oneNoteInstalled = false; } - _context.API.ThemeChanged += OnThemeChanged; - UpdateIconPath(_context.API.GetCurrentTheme()); + _comObjectTimeout.Elapsed += ComObjectTimer_Elapsed; + _comObjectTimeout.AutoReset = false; + _comObjectTimeout.Enabled = false; + + _iconProvider = new IconProvider(_context, _settings); + _resultCreator = new ResultCreator(_context, _settings, _iconProvider); + _searchManager = new SearchManager(_context, _settings, _iconProvider, _resultCreator); } /// @@ -98,14 +91,29 @@ public void Init(PluginInitContext context) /// A filtered list, can be empty when nothing was found public List Query(Query query) { - if (!_oneNoteInstalled || query is null || string.IsNullOrWhiteSpace(query.Search) || _cache is null) + if (_resultCreator is null) + { + return new List(); + } + + if (!_oneNoteInstalled) + { + return _resultCreator.OneNoteNotInstalled(); + } + + if (string.IsNullOrWhiteSpace(query.Search)) { - return new List(0); + return _resultCreator.EmptyQuery(query); } - // If there's cached results for this query, return immediately, otherwise wait for delayedExecution. - var results = _cache.Get>(query.Search); - return results ?? Query(query, false); + // If a COM Object has been acquired results return faster + if (OneNoteApplication.HasComObject) + { + ResetTimeout(); + return _searchManager is null ? new List() : _searchManager.Query(query); + } + + return new List(); } /// @@ -116,29 +124,28 @@ public List Query(Query query) /// A filtered list, can be empty when nothing was found public List Query(Query query, bool delayedExecution) { - if (!delayedExecution || !_oneNoteInstalled || query is null || string.IsNullOrWhiteSpace(query.Search) || _cache is null) + if (_resultCreator is null) { - return new List(0); + return new List(); } - // Get results from cache if they already exist for this query, otherwise query OneNote. Results will be cached for 1 day. - var results = _cache.GetOrAdd(query.Search, () => + if (!_oneNoteInstalled) { - var pages = OneNoteProvider.FindPages(query.Search); + return _resultCreator.OneNoteNotInstalled(); + } - return pages.Select(p => new Result - { - IcoPath = _iconPath, - Title = p.Name, - QueryTextDisplay = p.Name, - SubTitle = @$"{p.Notebook.Name}\{p.Section.Name}", - Action = (_) => OpenPageInOneNote(p), - ContextData = p, - ToolTipData = new ToolTipData(Name, @$"{p.Notebook.Name}\{p.Section.Name}\{p.Name}"), - }).ToList(); - }); - - return results; + if (string.IsNullOrWhiteSpace(query.Search)) + { + return _resultCreator.EmptyQuery(query); + } + + if (OneNoteApplication.HasComObject) + { + return new List(); + } + + ResetTimeout(); + return _searchManager is null ? new List() : _searchManager.Query(query); } /// @@ -153,48 +160,47 @@ public List Query(Query query, bool delayedExecution) /// A translated plugin description. public string GetTranslatedPluginDescription() => Resources.PluginDescription; - private void OnThemeChanged(Theme currentTheme, Theme newTheme) + private void ComObjectTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e) { - UpdateIconPath(newTheme); + OneNoteApplication.ReleaseComObject(); } - [MemberNotNull(nameof(_iconPath))] - private void UpdateIconPath(Theme theme) + private void ResetTimeout() { - _iconPath = theme == Theme.Light || theme == Theme.HighContrastWhite ? "Images/oneNote.light.png" : "Images/oneNote.dark.png"; + _comObjectTimeout.Interval = _settings.ComObjectTimeout; + _comObjectTimeout.Enabled = true; } - private bool OpenPageInOneNote(IOneNoteExtPage page) + public List LoadContextMenus(Result selectedResult) { - try - { - page.OpenInOneNote(); - ShowOneNote(); - return true; - } - catch (COMException) - { - // The page, section or even notebook may no longer exist, ignore and do nothing. - return false; - } + return _resultCreator is null ? new List() : _resultCreator.LoadContextMenu(selectedResult); } - /// - /// Brings OneNote to the foreground and restores it if minimized. - /// - private void ShowOneNote() + public Control CreateSettingPanel() => throw new NotImplementedException(); + + public void UpdateSettings(PowerLauncherPluginSettings settings) => _settings.UpdateSettings(settings); + + protected virtual void Dispose(bool disposing) { - using var process = Process.GetProcessesByName("onenote").FirstOrDefault(); - if (process?.MainWindowHandle != null) + if (!_disposed) { - HWND handle = (HWND)process.MainWindowHandle; - if (PInvoke.IsIconic(handle)) + if (disposing) { - PInvoke.ShowWindow(handle, SHOW_WINDOW_CMD.SW_RESTORE); + _iconProvider?.Cleanup(); + _comObjectTimeout?.Dispose(); + OneNoteApplication.ReleaseComObject(); } - PInvoke.SetForegroundWindow(handle); + _disposed = true; } } + + public void Dispose() + { + // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method + Dispose(disposing: true); + GC.SuppressFinalize(this); + } } } + From 8ac7ff83ad0cb36df6931bf2051c4cde3138af04 Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Mon, 23 Dec 2024 17:14:34 +0000 Subject: [PATCH 03/13] Add plugin icons --- .../Images/notebook.color.png | Bin 0 -> 663 bytes .../Images/notebook.dark.png | Bin 0 -> 452 bytes .../Images/notebook.light.png | Bin 0 -> 498 bytes .../Images/notebook_explorer.color.png | Bin 0 -> 1603 bytes .../Images/notebook_explorer.dark.png | Bin 0 -> 830 bytes .../Images/notebook_explorer.light.png | Bin 0 -> 924 bytes .../Images/notebook_new.color.png | Bin 0 -> 882 bytes .../Images/notebook_new.dark.png | Bin 0 -> 524 bytes .../Images/notebook_new.light.png | Bin 0 -> 558 bytes .../Images/page.color.png | Bin 0 -> 759 bytes .../Images/page.dark.png | Bin 0 -> 426 bytes .../Images/page.light.png | Bin 0 -> 458 bytes .../Images/page_new.color.png | Bin 0 -> 972 bytes .../Images/page_new.dark.png | Bin 0 -> 565 bytes .../Images/page_new.light.png | Bin 0 -> 625 bytes .../Images/page_recent.color.png | Bin 0 -> 2087 bytes .../Images/page_recent.dark.png | Bin 0 -> 1095 bytes .../Images/page_recent.light.png | Bin 0 -> 1138 bytes .../Images/recycle_bin.color.png | Bin 0 -> 1603 bytes .../Images/recycle_bin.dark.png | Bin 0 -> 1003 bytes .../Images/recycle_bin.light.png | Bin 0 -> 1111 bytes .../Images/search.color.png | Bin 0 -> 1933 bytes .../Images/search.dark.png | Bin 0 -> 811 bytes .../Images/search.light.png | Bin 0 -> 885 bytes .../Images/section.color.png | Bin 0 -> 679 bytes .../Images/section.dark.png | Bin 0 -> 408 bytes .../Images/section.light.png | Bin 0 -> 433 bytes .../Images/section_group.color.png | Bin 0 -> 1084 bytes .../Images/section_group.dark.png | Bin 0 -> 642 bytes .../Images/section_group.light.png | Bin 0 -> 677 bytes .../Images/section_group_new.color.png | Bin 0 -> 1294 bytes .../Images/section_group_new.dark.png | Bin 0 -> 660 bytes .../Images/section_group_new.light.png | Bin 0 -> 731 bytes .../Images/section_new.color.png | Bin 0 -> 784 bytes .../Images/section_new.dark.png | Bin 0 -> 547 bytes .../Images/section_new.light.png | Bin 0 -> 640 bytes .../Images/sync.color.png | Bin 0 -> 1835 bytes .../Images/sync.dark.png | Bin 0 -> 826 bytes .../Images/sync.light.png | Bin 0 -> 984 bytes .../Images/warning.dark.png | Bin 0 -> 1557 bytes .../Images/warning.light.png | Bin 0 -> 1462 bytes ...Microsoft.PowerToys.Run.Plugin.OneNote.csproj | 5 +---- 42 files changed, 1 insertion(+), 4 deletions(-) create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook_explorer.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook_explorer.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook_explorer.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook_new.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook_new.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook_new.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page_new.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page_new.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page_new.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page_recent.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page_recent.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page_recent.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/recycle_bin.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/recycle_bin.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/recycle_bin.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/search.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/search.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/search.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group_new.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group_new.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group_new.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_new.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_new.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_new.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/sync.color.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/sync.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/sync.light.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/warning.dark.png create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/warning.light.png diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook.color.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook.color.png new file mode 100644 index 0000000000000000000000000000000000000000..41c09e09b43018c41c1b03d8725bbab022075a4d GIT binary patch literal 663 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=EX7WqAsj$Z!;#X#z`*3^>Eakt zG3V{({P*eglUw^dIT-k^x0$XBl0M>V zuuh4U?KkhN_^EzXyv@PqKIhL7l$d`!`Fhmd)yEmt*%>Z8ytUz2_zP``tv*2qQn?eH zrl0?JXXpQQAB`Ot`c`i#{r8O9ky&srmu?w@9M`E84h!5DZsl``z2MsImXWBEx$xw{ z$us`)7|nE6``mKh-9^@EQ{WATO9=(S3u2e+F5+Z98^q4=!*j!x2!>lsw^H_T8C1;Q z`Kf4W?b`^a7fSI_f1?X-uqpm{rp7(fT4Cjfs?>E=d1a*_FO#r_X!sT6T!xd3VgXd3?F*f7_KC zH?14a-IKBH&ga^3=E;MXC*Nu%x@XmV@^-)c=lkhL3=NL&x7#O$H~s``Mi3(3GB@1* z`_7zW!O7kuSN^j6WWL5I*08O?3@6cAEA{5MebXy0X@?t|_SCYhVP3<$h4sk>K8{5j zWF0o|6P?>w3N%3G8lz(bJ4bX(9>?5IWekDsoYI2KwM=54CZ6iO_xj-D1@W6Llm2Ps zPBuUCLm=w4-{cfwhj;%O1)j95`lGbv#@csR9~U<5=BYb>K;P3i(T(R#u#oQE>fIJx cwHM=grY_PccYgL0n9>+LUHx3vIVCg!00mqoPyhe` literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook.dark.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook.dark.png new file mode 100644 index 0000000000000000000000000000000000000000..243267b0a9e038b14474f76f8280db9ad2b649ea GIT binary patch literal 452 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=EX7WqAsj$Z!;#X#z`$7T>Eakt zG3V`UUoU1y0k`-j^?*f=M_Q#7XUCk@-uaz@?T@2PLowgc4ucBT*q)mlFH6kt{`Fl` z6|j5WhhK}+mT?;y7_h%qKpV4&JCThL?ry4O<}t|<$w zyT}^oQ>Xu<-zQ1TH#@qgAvg9Dla6kQLq`4FuM9qSm>g{wwl+xdD?FYhx*?(B#FiDT zA7*Uc84=_kdE7L0TfxMKI~8~6JvWsoJ+#VU-SYix&NKKQIOtwzc%b`Qc7a$%gFTCL z1%u@EIilNdoUJ@7?{AxUmub3b>%R>w?~HBCMeI4>an}j;9ApmQUh$FP3RBh@_Jl;S z519rnt$ZJv1335{bQc_hOG4ZN5;~;w;Bo>7w=9UnqUJSY$u#B{4cgqB51h*^xa+Y* z_5DWf0cyEfFMRp@U^`o^Zv z87C**T)p}ImHe{vF=^%BbbAO+=bat%w$nd7X3V-7=eKa@?&;eC6Vj#yn``JUIwt=4#k^^9^X01T*G`de#*NTmwPV2NM!JI^>bP0l+XkKS8CPs literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook_explorer.color.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook_explorer.color.png new file mode 100644 index 0000000000000000000000000000000000000000..50b77c223c775bda58636490535e0d3b11b821fc GIT binary patch literal 1603 zcmV-J2E6%+P)ve37jdjRayH#W}{MiOLGQtLeN(@XRCYmr~ ze1maAOiUC(jW0AAZ;Xk97ivH=!aGBWiP;A&vVb`+3$Y$yQepX81?KNEGHxD1fxa}7D7b?5;mB!mAcez z2&8fxG0qSO7bYjU*3C!FUNsLfWY5mQa>`?uKqyZsDOr?+NvTFk>R8DYASxGyBF}F) zVjWiU;6zs=`%Z$N5we13->4aJG22@-Ohy+muvgV=Vhdo_Fc-aKRWsnTk%gYR*ybgG zK#U;G5d<*U8N$0~d;t=PK#c%9%&D8sToKSXs|x_gC&5{%xdP~&fZj^`DnOtvBEy$W zoljrOWI~D5-RfBh4jo`nUEHLiv`0YLK)bR94**S_mTSDh@KL7Yrd@!Ihsy^unMg8P zcWCjgOvjw{bHH2y^iDu;&G>r(_kb`}(X^gR^!Hgm0_F;!cLI7V?E=_ahbl9fNHRLN z%kxa8W2Qd>Sm+1Ghu-BG%tcWbKj>d$WH^-RxMHJOXdT7siEoPo00!Lmg*|gufk$hu z0D32&w|D^9zoe_axAz9T_k0M2LJ-exp`k1_lc!Fc=sQgrJ!(G*&XTQQ0Hcvd*`iV` zt6qYV1x4Bus>rZ^NmsprqYHljxG@rmKudT65RODJGUmr^_W;ag3z45cFZpa$C&766 z$0ii_a~wxs5K)0VS#98>pAZ4zPz2X+-cFq;!{PwEmTmax_T9lDt+ZS(}kZ` z#AC~zT5M=t_Q(U*G*=?fUXQaKS8%TLdK^4WUzzA6K3(|tkG~9aZHZ#=g5o@EZ(j>@ zO$ls!>~Zk9Py#-kVgK%t7i94N+Pyg6c>{rwAV36@bv|C%TL)8RApoG^?J5lSkK=U5 z<+%8Ii%%7P?T%-$v~iIb;MY%k@XzsE@(Hhd5RT(cv>a?iLrWC^VC&vhaM+v}cKN5p z*H>Jsvwc&{IseCjzIb>@6Q1o8JDlB8_k8QV)j0(ZOf7|zg)gZrgt2f(nDIM*7>si`r}7O0EBn7 zMNWRPQFQe5-B*Q=`g{6(qF+SW5@CC(2Y~8zB zwC_1~QwE<4Mc`7su{qPxD>^r{RN;;GwF%+hJNgnT>Pi6sfzcrT{P~(3UVr|nr7)6% zCkT^RtTwf+Ky9-X4x1Cszy3r1f;>F8p$zLkLs6?FTj56rW7$IzSi=1?4fmv83CmD;w6*R;19iZ77s=qqUV?sbP)DpH6bt>#Lyi-E}wM4-8&q2 z&dcLxfnP=Z5nK<~*rxP0P{=so>Xmk2&PV?g;B+~dMa>xk6hb6@~O`vJhrg;yN` zf{`BZxzHBlXF5DnISv;K56CAbt>JTF7T~ADJ8VLSXH(nq83M0-9G-wN07bEPbq<>o z4x2MUrzmsqdA!tL&`TUZzpLHSY5`9KSjwg5s&*p97Z(EeEdc>}a@xZicn)ipRci#D zq!{en0na;^A_#4?niqrT`K%24rB(~Jzqk<#P0C-aWJU@8`V4kr*e!nHY;W_r8DNn+ zs)e4i$=zp!+)Y1KC_c?5J|V)0&ZuVbgozPOso97Hco+_U1|aMI1E8V$nUOwMGZG81 z`KZ}D8Ad&UP7vTza>{WH5zxiLe8c)5D^(vr_#Z1~NaM$Bk)Qwo002ovPDHLkV1feh B_=o@i literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook_explorer.dark.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook_explorer.dark.png new file mode 100644 index 0000000000000000000000000000000000000000..ccf8eaeb4dd6f59df6967b7d18f517bdcd130c8a GIT binary patch literal 830 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-R~! y$&)7)m!y$gR3c=oK1T8hTZ9)4dnyi%$o~grK|Ch4b4}F%00009vw#%J$SZ=D2f-Wn8t$?p@kjD}qMydInX44FE?piV=d3 zt410Cf*O@bv0XLLt5by}lf6kcN08hYk{c(?G9ro)vZ0DKzzPPp0W@St3z39@wyHJ& zFbBb^#x+1%fHbye0S1pVdoHvOZ<^5|Xf>~T;=5qrIta&f)NeZjvL5a$SLXqseYj!9 z>+zh`RljWm4i5zqI)s#>HN54WuDYv!3~&vQ79dT7ATEtfV2QXl z8=S3=VzfnVs#^=|zidXw!!roJ-wnV)v%uZvi`qL6084cVOq{q~P%dtOoq2w(EY%gh z)Dky98rJ}60n)ezNDGk0@w>r)P3+^JKP0a@16D84#2^T5s{||sh z<};KzuNrK0js%lGve?hyM+_|LRHm6v42)COd!Qq{L%AQn0Jwhr*=UtfE&u=k07*qo IM6N<$f=~^EMgRZ+ literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook_new.dark.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/notebook_new.dark.png new file mode 100644 index 0000000000000000000000000000000000000000..044399eb07e845543bc710d82f06cf3462973855 GIT binary patch literal 524 zcmV+n0`vWeP)$t422)L4$u*lO*%?9>j?D*X*cKwu_s76LHfhaU7Jfl zq6P`0?~Xq{u%F(65nux|1mGRO5x}L^T(!X2-Tj;8fa`R$+kHOY^0N9uSLf?A?GahCmcIKwE$|Za_wxPs~Y1s8sgL zGm9ZjGpVGQ2T+F2E75v6(;zFuDnPDIp9W)eZ@`nbfC@y1toHzI0Tu9wt{DZ9NYkH0ou3$+5)s`!2s?KRQAr1_Ce;FJ5cni9g7z7 z0O=0YH6B(wUk%n$VU_L;*zyoyz1zC)0Tv8M&GS;kc|uF`{C}a_=Ud1FYM(UyiPypq zP{j?<7NAY{25dPIN)Z6>0bTci3t*!M)I4dTdl$7c!NVhAD?_+*!ek*6Op&`I#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*)5^Djq{Yd)<;p9q~qU}?s@*)^k|O$ zzl=p}r(_z!A27vO%b(}|WA?OR^9KXLdudCmWcm+u$Q<1BTm1o$y7O!K>}DxNCk6p! z7fyzt77s>;4gp<;l0E@LhLRouQ-+c*0ZWFG4gp(+9GOIZ#)QKh)tn5Bb!O)`njP5i zC`wUz4ey67pQ?P7ujD+uWvRFQ=$gdBmfeS3t{?g_X=nB`iAM1U%s>7--sxUfcJYnX zV)l%qZ>-)|N4cml-(WJ6JRr8=B*V4_U$zabIYte-37-Qb^li1@%)7(b`ccfkdEw9R z)(Th^PG-zuoLwWIzkA3a*nd~D@{epMIG`M|(u@O1TaS?83{1OTQ7rv?B3 literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page.light.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page.light.png new file mode 100644 index 0000000000000000000000000000000000000000..d1e4c3914e8a53c276667c55ead923a9c06e55e3 GIT binary patch literal 458 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=EX7WqAsj$Z!;#X#z`)q(>Eakt zG3V{9gMo()L|DHYi#Tvjc_0+TRN}y?sVeKh-om$_dCCMnq3{no3LYFdab(&jogdXx zlh>Nf>U_%Sqwq5B(&{CX*PZ`7B|dnc*!zedR!SbXq{a75E!pNa;rs3T9#U5<4xK&n zBevVK-rGf{f!Bb^UsuV8b;D(=L$8<}Zga%4G?WSM;$+BGDiLLP<^DpC;Y#m?RE8De z3vV+7s5@O}OsH&m$9$l4o<#cQ2Ra`NlGi;;Z|{y2NH8znS0yNRV)Y?gze#P^1e3H5 z$S^i^bS(YOaP9zi0Yjg7T^U2!{n)ysw~VU-xIU=Yu}+)7c!w#^s3H1*FIxfkj*|>| zjOLODbRRt1W)e}=_D}l>p9b$W3*L2e>-RHbs#0U#!Fnf!VSB^u8uJw< zY~6tfsX1I90t1g6t7j_Z8U95xatb1l=cV^Ea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ttb1t_J-~{{tj=*!`XAi*rc`VmxT|g0h0^Y?cki!sQ9e_1MfOP=Y z3<1^wSTh7z2Vl(*U>!gNe}KIU0PN>`lknC8B`8n}?45JZkz?(Er_1ZBi=h(a3h)IV zJD#tP fok{Y-bJ-h>|G6Yx$um$th*puGQI_=Ken%@yB@e;h?1bkUmmKL4>?>e8_ zSwx<2!@O4*Bx6T6WmkBYI?1)@?bMqj{mT{1e*#-CmrFd$xGnqyOc?^K1F&WYunxeQ z4==!54faye$aLvRv~DD3J+9@Lz#agL#bQtiW-(Zk`Fo_7h9QcoT4F zsTkUd7vL9XlZU`d@Vzh&NO%|mtOKy7c>yVT!kXo@c>zS`2^Z^pG|lG$B^axKhmRm& z@->D8B>&yqAisT$ApxsSY&XON-1% literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page_recent.color.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/page_recent.color.png new file mode 100644 index 0000000000000000000000000000000000000000..ed53432cc9b6a451519f9baad3865e198a97f280 GIT binary patch literal 2087 zcmV+?2-x?DP)2#)Tv>Ds6RmYk5C7Mp!$)q;uByG%S(&;oGbYpbVPAg!nuK`hGj4!Kcd5N%ZfN{YE z!~yj5!|vXFzq>0e_s%rW%))ZcbDn#D|9#GR&OOX(h+^$8+P(+8B+!%qT3KfS8Z=QN z#@>JFV#l#H?cc18c8^oBS#q7HUbHh!9Z#fzSXMiMVL2CWJtEep?;=#&;@@ zO}hy48KAIv;oX@4R{MZ)XT|i2pl$*D;N9=Q;^;TNU2$~UL{PT?LGWHddhPwjKb0Su z77^4fKp1#$Td%#(_|`Otpl$&ozkLr(29&n{djV9j z4;Xfha;?YCSJ#J_oSX#j-p}tu2;3VSPqW*{;}ou6xCbME%>{crt^%PELkLu0rAfHZ2kQ#UO5kd1yyqZ7;{bFFb{I2#fIHHL@e;0 zH`$5{5G(xRAI_)x=L^Xz$qpN(xUPVw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W?QPlGpdEot{G z0Ja(8uQvt`sDA331$^Etf&d(6>|aU=;0-r^g}a*{vnl{$AppaG?ZuP;4&C@DFg9!m zVOhbhxJ^d;0R93lIGbf=ta{_(baE>)6+jsBw2I?40RX)1Y<6k|cp5?|`2n^|>}y`d zVcQh|@GJ0uvzu=K!Z470cH@Jpui*#H0l literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/recycle_bin.color.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/recycle_bin.color.png new file mode 100644 index 0000000000000000000000000000000000000000..b79e0a85b372e41ccc019c66268e0e7f657ffc0f GIT binary patch literal 1603 zcmV-J2E6%+P)g+S!^2Dkzn2Xx z^7XJkTQ)G6Tt_0Kp{P;YbqhHi3ppLrsjc6a`W1{t+Yt(wg&6$4VEVoEc{h^-ao7dy z1rWqnlp4&NJ7MzaIwq1Ep016jD~P8n7>~AL?0CB`9z+n`CqbPO&p9AlHZVH3>e=|6 zm`HA5bZ!;dviFzaWQ(l_h&svJ&)OqZ&~f!asiwR41OyC)WyFFKP92io#CcIOkSZ8R zWGYBxH2h&PHdWZf=>1hpov&HVG9l_~?gf~cna+Ru*=1J`Dr!be<9h-E#-r`H)UVXM zu0s|O3krw@CEPf%<^JD1SwpGv|9y%Y#nlHTSA4cHGc#i=fMc3ldbXSg@B#0GM(0+M zDr}m@&V^;%I{lvOtX|X%+?-#-!;I#*jw1>FIe0Acq1_~l6?Zi_k=&>6AI!s|vx5lis$jY^l0P@&n2cz|l9I3W#kKH3PFRDyFd;C)~$;qrkGknI&O& zgpXHrQ`YYZ2)5b2DPY*(7y^VMPZ=>_b=RS=%*m`aE*(~I>X3&5#0D%6VCDeU1FV@p z7W79x6cDQFe?Rb*0}Nr4DS*`j>iPES0hSGpY-Le=wW-^8aJA6r)w%VApqtVziUW5?Su z9&O`ZZ-uqu9O!lylV=-ez7AoJd>@FXE2fH5RS1T{&J`yQccuV5DmEHL&A{!&HPaYR zxy{3!9Rk$wd^~R5B15XT_`kilUiJ2`46s9qQp3Lh@ZkZy0RdloI1|{3ujb2$r_Hf{ zTi<*IJkE)FyI4E)_QXcMX0bG72w-zUfOa;U7 zRm@rpal&l6g3ggELn^*Vl&Vg2Z_bx7kzB`6 zSi!lljDc?9P2Z3$8%Py4v5?b|$W&^615g!$Z_fl=^%_P!1P~0Gry{=s1KkpSyx55^ ze<~sMx4Bi$mJLj&HmZ)$nD;y=V(NnX!&Sjx_cF{oiej7V91sc!xHsJC`;(Tc5R4sf z$GzcBPhBPtcjjGlx!*kR0^`v(+#l(3eYCAA1S9n? zP}B@OUfKErydCd55erHP1q7T6%ghRo6NSNJk@s1Pc$@h=d-AN`qUEmsJfKYR8` zZ@BNJKU%wo-f-W`Plku B<>&wa literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/recycle_bin.dark.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/recycle_bin.dark.png new file mode 100644 index 0000000000000000000000000000000000000000..080cee64d2ead4847b850a1e2c49ec64c0c88aee GIT binary patch literal 1003 zcmVK%{E&O*ad!dzpIgOQBbLpsJq`A;4ARS?BL6w zlbB;O!fLB61XeJ!?Iy!%i_Zbe0*Z_Ur!77QJPG(5&W0{k4d8;eKnVh%zRS?`ZpotBuOyHWI&h>2yLUA5W^fH@HwKdBCUj_ zjdt%!PYhOth`#giL(Bubd}Pby-vjR~LJCPjU@AxB=IyhJ3?Z;72P4<4@9GY6FqY(i zl#sPyGL3eR*BsFP*KB<#0#QKL^yE5-D+S8|J6N_f@R1HmHD*5GwlJC%(Xb zp0F3eLy4{QKm~-Da3!WaWQ(e%>)S^clY-Nv^p>UXOPf4yfe*N6kD4~7YwnAvP1j$0 z-cz(gKjtcKwp*()BVhGBXGv^7phMsA6r+y=?r87jRS9xc$D?l&%?9levSpC1&k1qM z)@{;D>RKX58Y7xK$Iwge<6Im6DcaGpL!K-5=VYu-Y0|#N7^EeJNteP?*$>1(OFBs% z@R;rk{ew-}3>Cv;4grzQk2wTHI>#&(vo0(KfXKF(9Pp*5B4ePKu5;Sh8heg+(FKu} ZqQ75iRZ4Mpa8CdL002ovPDHLkV1i+N&ZYnW literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/recycle_bin.light.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/recycle_bin.light.png new file mode 100644 index 0000000000000000000000000000000000000000..b032988d4b72bd0eee69a9896fd49b6e81e03e75 GIT binary patch literal 1111 zcmV-d1gQIoP)f}@q?Crk2f5`Hr~JC?1drzbuAc@l8Pk(|Ov&Hy~iDbvGB zMB2h-#6fbGkR-PSx;DTmwMCn2gzoG253_CPaXqE(v!Rb(5A|Em|=Z< zxe$>@nahd8(<+||mi5UktW;SsO1V5NSk}Yb2FUILB9e7#EnVLIo?KH^FCsUjQCYrqZXNJg)b{tXN6s{cBUz1z(fL@=gv(>gpV_>@0EkkD%2$R)i4O$a_Qbi2a8sMitJ9E&S z9GykTIiu2j6tbF7{+tV;KQN=WtKdffM=)`HEi(WoHg8dK8elFW*SZ_Y0|0voGWV>E z%|LQr*<~9~-nByvCHs*&Cdtdy0~U@_6@a&yWEUle0ahZiaMFtVZZ3ulpxF;J-3R_# z&Tb3AIt&>=Glw?LbLz!~_b~&8LSC>AIb6WCaGgQsWCRZuX_m9+K><#wvZUfw~;OH)h$JVF$N&X6OK3+?8vIEj8P<2+EFBQK(gcfd>k<1fRf}( znfTo~1fH}=_wt@9`=bIYlKx7vYexAyd_X7Y^v0Y3#jSZk(2W-oJAcjWs zk=6jW>Aui4Zpvn;7`NF4R65^g7f|V}UMgl?SWJL+85}bPd>*OGCMcsTO-%1JafMcr dQ<@-*n!jwsXo==Vr-1+f002ovPDHLkV1oFV{(b-e literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/search.color.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/search.color.png new file mode 100644 index 0000000000000000000000000000000000000000..a8c3c76d28793360392f8c4e2b55194abdccb8f4 GIT binary patch literal 1933 zcmV;82Xgp{P)Nkl$eQXnD9LK-c_Ih1y%Z6-e6?V~e(U$78M!}5A9~&W#sSqGY z)I=xX%OAcZCjOy`7!`HkOZZ0;zBU_+xiiDVOQcjv zFW-hT8naYo<%m>K(FdFDgtTVOXFDk>HQQrSbGJSB+H>;c+o{399jS{Kmm!mx(RU?- z0a&)|Z*l3;uik5Dcz>qHE@}XKPM`ij=;?Va6N#AB*q>;(C(|C!=O3JGH7Ti0?kKLrioqr-=P z7yA2G=KG9sxj=ip&^w(Ff$OiV?0r5>$8peib-~czpZAzoJf6VrO`BFt=BZ!->^gMl zT#Dm7N}Xm|l=*zn*VNn;bSh0hFaVR^4>}y4aO^Ah+|#*xb`6@^NAAbAoA7g+1 zxk9O18XIA%ub&a=j;$M-AYDT4vFO`BAQ z7XifU>oK}{^R>&PtZd!gkGyjH_L>UaIXla3Q`Eu3aa~kh< z1nqWf4xiKF%a`L)V?4o8HN$nzY{DgBOdmNiNw5s7XcU(3Bqc+ ztSqH|4=|f!^0vhD^8#K3z$kh^(rk{Ye;G8HLPVS6<^{Y6Uw>{~0iOk64+aUZ@$&L^)dLVIYOh4oH-xb<=*D|NG2yE?4zz3zAw$#9Q`BD71K8Qr z6bH+Ou~Iow+;RM&<_k04Zd<<0Jke9PDaK( zY7)Tv4Gp`*s;Z=1Gx_~R8wXr|KjAM{Rdw}9L&GjWyJvz@rn>r|T%f~Ylm!9>hrcTj zK$T*)=%1RJuW;=KRlBFcyPBI{&Nv*zJ%P2O159sk!Qhwn^`TBNOB7+*;UCtneKptC zbY5VruI_2kWFoX%fBFfAp&`xT7Yz+z#gQY#u~Q}!IJf&5xu$6VyH~Dkr>acE@JnSf zxUH=X=Dt47;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launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/search.light.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/search.light.png new file mode 100644 index 0000000000000000000000000000000000000000..c64d7cd7688ec26777d0f2ef5351190638759115 GIT binary patch literal 885 zcmV-*1B(2KP)%-7=_PRZK6>c3n+|4LS;pz(GW-oAF@()VXdW@7;PYd7-Fd0LPH{dL0TwC1eBnK$z!oYvU$C;?9R@+v%Ab`HkX~b&pGeR zFn900kvd2~Nzxrj_a)tvbXU?fbJ($@ZAo7xeTkx|(oT;q0>*(4z$wk^6nGDe=bfWz z0i(cniqJ{g21fJFb*_M6U?aoeR_nlUBVHo!uvWlhNv|bcNjT)Eq)ka%lJ+I-#h;SY zFKHnDoRaiF($$21P9!~zqUc>V&NC3OT<5B-0W&H3oQcm((vm}z<^{Y;FjxU5Gw6RZ z?kl9{S!8I%+=~Qb3l6M>1lF^xS&bT+3z+#0%sMh>V}{k77cW>#0DY$2$#+1XM*+G@9tAiu?S2PFT3Ihg9tAis?EwcyT3Ig#9tGGn?M}V}c0CI4 z-L$717-?m_Sg);;VRzdCI~ zWXuy7QJr?GRmBZ>z8^a!wu9%CSPTuV2V9Iv(Hi*Y0Q_Q1i^m2AsV+v;D$j+HL*Rxt z+ZySlrLjj|%z9=*3nXW1=i=y6)~rU%)C+&6b}Wy-%py;-h8hW9E3XX_%k|E8c^3j@ zNpAvQ%}e^LUfv>8=gOCBjv1o5k;zLNz))L*HyYj?-#gpnnhkHx9jCh4G0jHF6W}d* zZj@{#yy>Sz^@r3V@Ci5y^m!D2w-_H=a*EZk=}f|RrHb%H_#%7}z6f80?{O93i||GG zB770P2;bu>!e7+zO5P!+R;pQIftHvm{=w0!Wp6TlI4 z01o{-L%y7TQ7ok$cPMScooexNcU**SiC>)%qug{Rk7~rv1i-?@)v`$BMBoUHkpMt& z^VO?q*8r^4KgYdD9M|`Bh0JEb8>J3l;Xd#-|p^s+NCRQUNemZ`Zuf|Kb5907>F&BDpzYY$+80B+GfI@Y|6R02~AM1_7-M z(6CjJ5&*AZt0ENu-h2jl>j2DWfOP<&2ABunjkiJb84zkf0AL(|4<|wM074touvJlL zgBqshGa!5qu$}>-281?fJp-&4!B7JN0OJ6{7O-9f!#TkE76>&U0I&|gdKd7a3mDIU z0Dx=*7}4-fTUtMjy~7>>P|&eubNxa@x(u_h;bo3f})9Jq8&X+OL=2Un;QWAnmXJXMxp0K`YulcHy*7u9%uPpnds*6nIluBmnXISe*^rl^>6Y`hR6T_ N002ovPDHLkV1k#;C$sEakt zG3V`UML*|20S0ypWSUze@A$nb_i{eY>#^V*N^_EuzV>}m9V zFmb(ieVz1SjvWl|BKLne#$v&6uEDx)Tgg|(zDCIn559MYOF!t^uOFM+Abm%`oJq!A#H7~f z^Tf3NWxp~$<-D^#W>R5s^Z2gIH`V=fD}MDYKOd?*vG##R)(`3LU*CNG#kb=IFsKR literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section.light.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section.light.png new file mode 100644 index 0000000000000000000000000000000000000000..f2939d998a200b5517521a35bdacd923f539eb0b GIT binary patch literal 433 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=EX7WqAsj$Z!;#X#z`&T{>Eakt zG3V{D$^O3GzFbDQ_1}U%PKLvrePw2g9x4q49 zAo=X!^I8lWR@MGk!B8#e?5(+a!Op9lTpKuMMbFhs%D7VccGtRH`B!*n@Jb#K+i;R$ zTZ1p#2G$&-2Hk|oj5&<6c@ns9q%cGuP-DKqWJaozMNE5G&#v_gX?PB?ly8=`{Ees2 zKiR(dbjXEYIDRH)rLG-|=(J@@aoy(JA7uaSFcTMaV6QAJGBVg_^*hVjtoh;7m(jPq h87>GvtGECF literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group.color.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group.color.png new file mode 100644 index 0000000000000000000000000000000000000000..96586e9967cd887dd63e588f87adc9c30fb81228 GIT binary patch literal 1084 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=EX7WqAsj$Z!;#X#z`*?3)5S5Q zV$R#yd-J11C63K6z8es=JRx2@XkK2Um6`yq@pS&c_iYs+8CveZ4SX$uH&J;NNc(EIVJv-2Z$`ZGFS%**d>% z-dCPmTx~m-{f2wp2_JW{OTmVHX;pf{J1f8QPgC=MJn`#SPUYT5JomUie#x;|FokU* z+X6<1iBf-8JU=BKH%t0s$&SS_7oSXE3pHJ0@ayLBK!4x9buDv!mv4((yz64dhu%nk zUIv*PhiBGw2HOZkL|$AGvMQ~k@0xBwhLFSDjTLj4>Xp{647#{tim9dyYwrJb9K2GC zyc@r6TD@|SiP=KO75CdinxB>4k~&aRmE|yT@zu@gQU|Q#UUysw{$2C=-6aPGFLiBA zUJZZV4Qo%X_2}_vzmAe!b$l>;?M9wT@F|d0BZE+<&rE>#6gOud%PHzHSZp zdo_PH_im?15wm0KnJ+MW-TrF#v3dWPh3e0{1qMke@FrYv`Mjxwqcv3g=v6t9>$`ft zy|kI*e1D_skvpzm%GAFni5_e=_C0^1is_whz1<6oFPu{sFmlbx=*qr(A~i{4jU4mT zv)f+3^?UT@_WlLuV~;c*P&=+9{g^@Mv~j%S#pN#lva{Fx`6gHNQsVT5qvh`($Gl0O zwoJ5#$zw_SV+OrKwsg7LhMI2{r_Vh2ZU5-WM|B6rb=51*B-gHh50`NhxiU>@1Fvu{^V#Ec=6`O*!BCA=O~7M#H{;R)Z{ip>YiKJ7WNKjtQ% z57UpS)?1WM?EkXk+n(;Vne1%gshNG&Up#*3Z=0yT@^g-_^#|UB73np62W-+a(p6f| zeF&a5@&5F4i637|P6K-7FDKv5va(YvO_-T`n}6%FqK-hxnk`lE|vB>8~0hAJ@;x& z`?FgfTl|8<=N{F&8mS;@V{y4%?T_-^hl!>!Y#SI761RUcX|U#Eakt zG3V`ULvI;Ji8lGO@;BUEJT^{E{h%I`E}5IVX@c64&IIiv@e6)3Hbz9=m{C#|H&^ZY z67D-f9+Dv&%#YqX^mNYdxi@FtEuZ+l@nucfy~?{gv+Q3?&)K%C%&gJo!pk0>3g#Hb z{>`B!4{{jt8}p0L?VdJs@&~COOn1()uDWh9@iWtn`Ihyv=jMyBb0)G|FfZ#fP%Sud zIec@kF_T|oJYRZYsUKerL!E`$erCHsS)*%}tTN2^W&Pf>?s)g&k=4Wh^6Smcc|Wi% z*n8;Z)&{}T?_d1UQkon4fT<#*ph{bTInTyiM@gpPJSX4WJq*`lOV=7*+UZmAA%#_h zaki-7IY;*Pe4T{5n;GIyaXeQz@N()h`Sm}ix?1dKo|BS)V3s?h;`bGGao7Dgw9mgN zW}Rmm)?n2jrR^Z=&?~xtZ^1FH0QP`n))mYvHZomdyb{6qiXm$aLn#B9%9c0$Zg_rG z-gaBzDF$^(J60d2dExw)TMFygEKYvVd|>mSva+RE@WGdJEc@RVEuVN!!G3!Ct9f-_ z?|d*g)Y!=9bERiR-22^azTF<_1(Y@-k zAUj9zisY3WcZ|wbr2X@9pP+elO~Skbl7_ literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group.light.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group.light.png new file mode 100644 index 0000000000000000000000000000000000000000..4abcbb7460fc08c7a83d7e27e557dfd8a9fa670d GIT binary patch literal 677 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=EX7WqAsj$Z!;#X#z`zva>Eakt zG3V{1q@xBbEF+4Me=lRG0HK% z-?>2Q;7&dpHoH6v|Dbb1ECuowOkpw4Oj?;^Smm~z({KM={Kj%Svu?xn1D6DsvGHxI zpEdEE+y|~7?+X4Ub}jUNAo<~H;X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OK!)@*|T>KEJ*M4cg z``zk6?N`7R^p|7v0N?@HKFb}{9zaY?mvcE!?tu0HbYlge+kkGY0CXGBjTL}y1G>>3 zKn0xTTy8RVKzjf$&=4GCdZ@b;OhTky%^lSKpP-AHaRlGujhEhE^Y!O1e8H;s!;x3A zo|_$()_w)(MkN40w`j#f>i^?qxEJRit}F#A0bJ)6t#I%UJ`Ox)hf(v$+F55YF0y8}d@atgcl z|A?K2pJnFaPZBr%*=MsI72B2d^_5CZELpI6hL&4q(!F_QX_@)$?i5a4y<~cWq`uOD zzNencyESI^HTb`8n%Z#ZXkOc#0*Pofrp90F&u*J5PEB*w+)6xp~+l=m}EY0fH*#erA zo$f46R_iR*Xq^T8jvYfyD8i=v7U&QiNdRL2#@1?{25>e{(;=2M1)8VxG(wCnYu0L> zCd$`n#TWkA_&R*{365sK7dAflGQiTrsMolE|4k*$zYH(4Sq$>U=>Px#07*qoM6N<$ Ef;2l^EdT%j literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group_new.dark.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group_new.dark.png new file mode 100644 index 0000000000000000000000000000000000000000..727503860a37f89f95c6b6698808a6a0703979f7 GIT binary patch literal 660 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=EX7WqAsj$Z!;#X#z`*3~>Eakt zG3V{0A%@kR-B46Twncsu`{dx7sN1(h zd-h5CrYZPWRbABDDBP&)d*ACy%3{VkhW(As_is6wMDAphYrK2n!UZ$8S$7{rYV2gG zW4hfjlWzyJ%I0S~Qr#P(ALOTeu>G*wd`@t(oWq)XeYctCn=guyy3DZ7A~yf=HL1)q zOc@Q+k1$3n_hvGzEWIw7>BF2M+Pu|m)>S48e;$RY=RA_T(v-7$OjfUL*xbTkQfl&L zdi3JNqCQR44{KL4R!DzX#`Ylhz-+08?Tq~@xPddFZE zE|%>G_gQvw!Nol1(`?3#f;@@z@bh&v%+pc5m*{L$;=W8XmZ7s$1lOi8W9hf2Qx4%kS`E1=y mk!y-!zjGC(io2}s{_{C9uyJpFm{Jc+W(=OLelF{r5}E+Hvmdws literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group_new.light.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_group_new.light.png new file mode 100644 index 0000000000000000000000000000000000000000..ef4059ba5434280062c4b449981c95c31a5aea9b GIT binary patch literal 731 zcmV<10wn#3P)v_{K6o!vj0JDL!LD--hzy^2&x&drJH)xpvm>^*SvVq+R z5+->0VXHNc6CEd(j@w7?za;+7<+Byb7l|YUD1c&#nrL*zd;)&(Otl0}RDch_J+SAP zZ6eJ+W{+dVtbuPpJyJ{q+yZ4}&3~k5x&%H0e@5~jfIDCvS(DZP#>d-`uk`+iB5KkZ z0NikTy!ELPX@bnvcmZsbIjck(6>}M&9d}J4jhZ={uO{TH5^2$3$P{|U|oPU z*#PSTtjPvg7hp{`z`6iyvH{iwSd$H~F2I_XV8Cw?S-Airvg)>-#7np(wsOujnpm{Y z5bLq{C-W#lV8}2|z9$$U8(>|4HRcA;J^GFq-&1$F%Kq=>e}dYWS`@htBJ$p! zS=e!LkcE+a|QDuaLHc2249=cyM!TNN;bf{ z0Bf=V)&*FT4X`f28gm0k_+Ec+()H-SGdDm)jxJDQ(B-)AKJNVY<}*QUOf8Dse??@y zq>G{NiSj&($S>(NFQPjF4kGeanZ&>JIGbh(_XKz0O`ha5%Szzi_+&O0DS{3YiupiU9*NO4_x3V`F|#yS{I130zRqZKpYU>)D(|d25NOOqUqYB2yezgQma#-N<`F~YGxevloV^078 N002ovPDHLkV1jFd_U4e$0XAjvwINmQ1YZA7y zG;m?;7yTXCY8@d5eZw_x98*!*A?SKrM%+|FZSiEo;v%=I`A<_S-p^Dw-r0U;ufq|| zr&;OS#a3&steM0m*Rs8Qb+Y}w$(hE|0@4kP0gAzMBDkv8oZxt%Ghbu=O6h0Y7&j+6 zEqWc?uwj0rm)c>u?IIMe-vOF=auNF|&>lCgzbX(!VOjvxIS zn6_|VIL38B&p}$-VK+nW8iuz_TQ*`746HYOcKlq1r2b|8i#_iXv(!Fr|9?$;!MC?> z-#owW_({2*ea$lY1(Nq)KffYku}#Rt{u5Kw$G-~8mp46gk83aqYbay96~TCmHDmET z_BTD#HdZ~Y+aEkvKlpY18&R9zEMKi3xc-XE5P#pCK7WDU0#l)kdGb@H{BGEV>84Uf zW%lLmmUq?xWg8CdKJHN?8p-i4P5jEfr*;~f(r%tKulxFV|Lr2XsL%IXcc*^0+ip;7 zdf~?H;BV%g?Gp#n5=%}&1Kb^ne-{?#^Y7{#a}o` zmvAHqA4q%uEVE(8{1;&>j?8X7W~u)F8U>OSfOKc9q&cQPBcs8|L}GI#ZgG3R!KKqHi7fzESj*Q7YRVX6ZV$TA9fQ z8MhzMu2;8}WcFM8df!CV;$7FjF5z9#p!#_7xoZvkURMXP>2S=i31eGx;z)yWx8q9g zd9J^uV%AS(44a-^u=n{w_A|Xn4N(oV@Dq1d)3wfV$!gG?UvC5-Ei@98VEteALsWK_JF|s9)gcnO?dw~x$uDO z!&ffP?dCHZKWMaSyufN`z3$~YaqGEje#}`V&b?4hbJ_ay^^EVny;oUUk+l#Q>kOW* KelF{r5}E*tD&^e( literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_new.light.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/section_new.light.png new file mode 100644 index 0000000000000000000000000000000000000000..4e172bf693c6d99659800df9b14cf78e160bf4b9 GIT binary patch literal 640 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=EX7WqAsj$Z!;#X#z`$hg>Eakt zG3V{wBH)Lw{*h5v#0|HxgXt;{vd?;6DIK0Uf7&a{Cc zuiPQWBji-JnLKE$7^+~L2FT2ZOz6rjLC~6 z9*8|yhL=bSVJo@fV}3>Td!^s(#abOIo2Gu*x@y((DU*+XVEHq(B(PNB+wU^gc zRh-CYwCp$es&3xk`^q%ko~7t@L+<^R*LxE=T7q~AxC@LUnS(yJob+pAKXFR9YU0i_ ze@{lf>bqc)|BI=j<%${KciBDR{H7@IaqoM9wcEDc2P$4E!hDD64uZJB`=F(o z@t#WT`L~9<87FPxo>`mmYe#n7y4#Px`E2NJn7%OFv-?}>3z>Nh!5?*AZokK(?>WEO zs(R`d)fI15?wB4d{jT}kaSG#i$G3cbPwqdxK1r`XH~mcNNA0VV&jmht!nylerS+BQ zw0DiUX-ik6PMxG~a&=y4v2V`F)%;hYGo~GI_E!$NxlAH$>CR~T#;*;H_JOml%a2cI z{d(-=ZMBBx9b4O&YtsMMY%G0kE%|1i{J1{an^L HB{Ts5H?SlN literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/sync.color.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/sync.color.png new file mode 100644 index 0000000000000000000000000000000000000000..e09b7a6a5a5d6c31ec76336632d8c5bef1d76130 GIT binary patch literal 1835 zcmV+`2h{k9P)j&Lr|+WL4Bxdln+z_A=N=ttq7?j)DKnTD1a;^0)&@}*lZji5{?rJwozEG9oyJW zY$pz0+ovCPcV-{<%&ghJF^NAXnTC1M4U=9ifltzjtK+_ z9w^3A<}jBL#AF;z&k({#fq-M@_LoZs&3b4m+a4b%kxbiep?)X zKL4d)%i=09I~E;aw*huT1$cT@>&Eu>|1tQ@2vbv2XtO)Gp{#EvhbB(=Q$j+swM($G zE*liU=~O9NQOK=pR*|2VlX`|G$as2H>&6U+d^A3O#W^!GLn_G&Fg-KF<*{)t`1>d= zT25BhP1db7O@i?lAG>DQ?r=Edk0O#CZER}DhtG(>^wbQWcV0-GQIg>R9$9Ge;p2+~ zL#g6r8LEinBtpLA_B>W^T|tF=1zEXH047EQ^mUAI?kzvP9ha~|9$+#MNI5~D?;+wrLzvS{-KrJ|5OztzAL6T&25+-@aYT!JobxHDGLH*$p)j^6x$0 zfv5QkCPo8M39sv9KLWhI|5Iuj*YdzqRRCn?X0rR0`{M?UPN?=moomiFG*@fnuZ;yb zyyJcPIxZPz`>UgqoM>w2?3+GzAA5kTTqoJNnNb6#6L|<#g0bZ9-Lszjl}iBYP5(Mb<^ix$k+m=E6YG5bSSn@aJIC1~-7ER#2109yg18l0RpweArIAA1s`{{>n zh9bjq-9u$s=wIr&il_Mt%SDb=Xyntt18QuAx7xizYxEqpPF@5~AMK{o)32S?KlOu1 z^63x*YHWF15fQ@OCkHH(2RPl*6+Aa<`J8^_0o2&qKAijjdOJoEs_lc#@#Jr=E=EHA zIz9cmY#KO0jWk0<_{tmcdTkQO1N`dM2Q`(yDgKw<$A13tbwKlu_Y(?xGx7y4{oY|> zbW-n=9{l6$fMk*vgtDpvZ7~1YkvRRSM(^M^hV5!B`Dc9fh8<2cwexmUyCw1hY^c?r zWqj%Bi+66yVLXaf2P85lt&%S+U&dYaYqWme|8&MgmbLLx2{k_KjS-tOjF!5e|E)&r z*Xg;)kZ+tw@(U9K#$%{f=H$mM-L&lWTE6mO@;6r(YdVhYYa^C?8U#RiKLCub$L9J< zvhtj??D2B-^0y)BP@fp`*}0kg?1gGJJgm?C4-TE9=j@P8>GwvAS4_rH=OPb5gIo81 zLi=$a4KGwv5VIi~ImaV0+%wLxKezGO@e79J(;*9}u|>{_ruNWr=$r^$o__wajQMR?0h zMsvWo)6>5P7W_8=DMXLrls}jWX%5)_a_L}TnvH@S7Z^#cZ7Ic&K&vvXZr=Kja?=+O Z{ttnB=2@O!N2dS)002ovPDHLkV1k;Wg5>}J literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/sync.dark.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/sync.dark.png new file mode 100644 index 0000000000000000000000000000000000000000..30d68e57d252623db0fff8eaa69897dbb01040ed GIT binary patch literal 826 zcmV-A1I7G_P)Px%^hrcPRCt{2o86JxFcgJ9GITxP#C^+)3yFI=~$)9W1F}dCBv7pEom@ z3dn=xS)s^|q{Unj`^?-2Wc}Q8(9e}*gN6bgffwL>r}knvC?cVNV+I7SWye?%b{RN* zZQF&CpP?0-hZeXK)WAbX#u-|%{}Hp0OrM7KA_MeIn#CA;Kp($)>;jBp2=rnSK-vLm zOadg7`H2oPW;e12)8=4^4Kvk{&U8Q}_}QX2U&=BV6k!d3R6nO>un(gb;Ip&?H$d-@ zoqB+@12@1l3HD(UAfb%J@tGR3^4JLLX=sNWDAQ&(k>I^xiUdP22_Wr&G)6DLJw<{i z^p)2RXp9}qGi6y}EEv-Fcp>+EQG`19-JJk?5Ah|i#UB?u0c+qJk-?fYQJ(9!oN_Wdz4Rv>;%|bjvqYFccg8>=Y+lfBQ8K;9A0^z zRSCphR5=UKzRaYqNWMhJ1h&29DnMbJ-Z<$E=_gOCNFT(=H^yP##8)Pgj}}03H`sRn zg3EvVmFtZCAV}^8Z2^4gsi?SIS$ZKUKsy8$PWt|X_14CMAvFiI#NG6p9=l7P3U{5_ z4*mYY-flC86QMz0fAQd}n;^q}J$g z)+VCRS7Pf9;;pc5Ae5y5Eg|0tajG5Y8Ae@dOA63p^}#k80)i*0PiI2}0Nop^1mYEe zlcz$a7sO(Yz7pH;zNfcsZ%8i_>PDe^LY+Y5RssxyKeh*F@Qa{Axc~qF07*qoM6N<$ Ef_L10AOHXW literal 0 HcmV?d00001 diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/sync.light.png b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Images/sync.light.png new file mode 100644 index 0000000000000000000000000000000000000000..39a3861624011aa0361e94a58479687f4d7e7a38 GIT binary patch literal 984 zcmV;}11J26P)Px&l1W5CRCt{2Tg!3VFc5v~$=yEW9_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Jep>Ym<>SZE`*Ky9_25jYd zK$HF_lvB@EU(^a96WD^Cd - - PreserveNewest - - + PreserveNewest From aa838915893e26d10db82d7035b9711ad42d76b6 Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Mon, 23 Dec 2024 17:27:25 +0000 Subject: [PATCH 04/13] Refactor classes --- .../Components/Keywords.cs | 2 +- .../Components/OneNoteSettings.cs | 5 +- .../Components/ResultCreator.cs | 6 +- .../SearchManager.NotebookExplorer.cs | 174 ++++++++++++++++++ .../Components/SearchManager.cs | 172 +---------------- .../Main.cs | 16 +- 6 files changed, 190 insertions(+), 185 deletions(-) create mode 100644 src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/Keywords.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/Keywords.cs index 9f9d169988fd..ba1a3f95888c 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/Keywords.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/Keywords.cs @@ -6,7 +6,7 @@ namespace Microsoft.PowerToys.Run.Plugin.OneNote.Components { public class Keywords { - internal const string NotebookExplorerSeparator = "\\"; + internal const string NotebookExplorerSeparator = @"\"; internal const string NotebookExplorer = $"nb:{NotebookExplorerSeparator}"; diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteSettings.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteSettings.cs index c2ff7bb8e92f..c53f197db19f 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteSettings.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteSettings.cs @@ -81,10 +81,7 @@ private set }, }; - public Control CreateSettingPanel() - { - throw new NotImplementedException(); - } + public Control CreateSettingPanel() => throw new NotImplementedException(); public void UpdateSettings(PowerLauncherPluginSettings? settings) { diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs index f6b7e2190207..d58313a13b1e 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs @@ -87,7 +87,7 @@ internal List EmptyQuery(Query query) { if (_context.CurrentPluginMetadata.IsGlobal && !query.RawUserQuery.StartsWith(query.ActionKeyword, StringComparison.Ordinal)) { - return new List(); + return []; } return new List @@ -482,7 +482,7 @@ internal List NoMatchesFound(bool show) "No matches found", "Try searching something else, or syncing your notebooks.", _iconProvider.Search) - : new List(); + : []; } internal List InvalidQuery(bool show) @@ -492,7 +492,7 @@ internal List InvalidQuery(bool show) "Invalid query", "The first character of the search must be a letter or a digit", _iconProvider.Warning) - : new List(); + : []; } internal List OneNoteNotInstalled() diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs new file mode 100644 index 000000000000..04b2f2645d4d --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Odotocodot.OneNote.Linq; +using Wox.Plugin; + +namespace Microsoft.PowerToys.Run.Plugin.OneNote.Components +{ + public partial class SearchManager + { + private sealed class NotebookExplorer + { + private readonly SearchManager _searchManager; + private readonly ResultCreator _resultCreator; + + internal NotebookExplorer(SearchManager searchManager, ResultCreator resultCreator) + { + _searchManager = searchManager; + _resultCreator = resultCreator; + } + + internal List Query(Query query) + { + var results = new List(); + + string fullSearch = query.Search[(query.Search.IndexOf(Keywords.NotebookExplorer, StringComparison.Ordinal) + Keywords.NotebookExplorer.Length)..]; + + IOneNoteItem? parent = null; + IEnumerable collection = OneNoteApplication.GetNotebooks(); + + string[] searches = fullSearch.Split(Keywords.NotebookExplorerSeparator, StringSplitOptions.None); + + for (int i = -1; i < searches.Length - 1; i++) + { + if (i < 0) + { + continue; + } + + parent = collection.FirstOrDefault(item => item.Name.Equals(searches[i], StringComparison.Ordinal)); + if (parent == null) + { + return results; + } + + collection = parent.Children; + } + + string lastSearch = searches[^1]; + + results = lastSearch switch + { + // Empty search so show all in collection + string search when string.IsNullOrWhiteSpace(search) + => EmptySearch(parent, collection), + + // Search by title + string search when search.StartsWith(Keywords.TitleSearch, StringComparison.Ordinal) && parent is not OneNotePage + => _searchManager.TitleSearch(search, parent, collection), + + // Scoped search + string search when search.StartsWith(Keywords.ScopedSearch, StringComparison.Ordinal) && (parent is OneNoteNotebook || parent is OneNoteSectionGroup) + => ScopedSearch(search, parent), + + // Default search + _ => Explorer(lastSearch, parent, collection), + }; + + if (parent != null) + { + var result = _resultCreator.CreateOneNoteItemResult(parent, false, score: 4000); + result.Title = $"Open \"{parent.Name}\" in OneNote"; + result.SubTitle = lastSearch switch + { + string search when search.StartsWith(Keywords.TitleSearch, StringComparison.Ordinal) + => $"Now search by title in \"{parent.Name}\"", + + string search when search.StartsWith(Keywords.ScopedSearch, StringComparison.Ordinal) + => $"Now searching all pages in \"{parent.Name}\"", + + _ => $"Use \'{Keywords.ScopedSearch}\' to search this item. Use \'{Keywords.TitleSearch}\' to search by title in this item", + }; + + results.Add(result); + } + + return results; + } + + private List EmptySearch(IOneNoteItem? parent, IEnumerable collection) + { + List results = collection.Where(_searchManager.SettingsCheck) + .Select(item => _resultCreator.CreateOneNoteItemResult(item, true)) + .ToList(); + + return results.Count == 0 ? _resultCreator.NoItemsInCollection(parent, results) : results; + } + + private List ScopedSearch(string query, IOneNoteItem parent) + { + if (query.Length == Keywords.ScopedSearch.Length) + { + return _resultCreator.NoMatchesFound(_searchManager.showSingleResults); + } + + if (!char.IsLetterOrDigit(query[Keywords.ScopedSearch.Length])) + { + return _resultCreator.InvalidQuery(_searchManager.showSingleResults); + } + + string currentSearch = query[Keywords.TitleSearch.Length..]; + var results = new List(); + + results = OneNoteApplication.FindPages(currentSearch, parent) + .Select(pg => _resultCreator.CreatePageResult(pg, currentSearch)) + .ToList(); + + if (results.Count == 0) + { + results = _resultCreator.NoMatchesFound(_searchManager.showSingleResults); + } + + return results; + } + + private List Explorer(string search, IOneNoteItem? parent, IEnumerable collection) + { + List? highlightData = null; + int score = 0; + + var results = collection.Where(_searchManager.SettingsCheck) + .Where(item => _searchManager.FuzzySearch(item.Name, search, out highlightData, out score)) + .Select(item => _resultCreator.CreateOneNoteItemResult(item, true, highlightData, score)) + .ToList(); + + AddCreateNewOneNoteItemResults(search, parent, results); + return results; + } + + private void AddCreateNewOneNoteItemResults(string newItemName, IOneNoteItem? parent, List results) + { + if (!results.Any(result => string.Equals(newItemName.Trim(), result.Title, StringComparison.OrdinalIgnoreCase))) + { + if (parent?.IsInRecycleBin() == true) + { + return; + } + + switch (parent) + { + case null: + results.Add(_resultCreator.CreateNewNotebookResult(newItemName)); + break; + case OneNoteNotebook: + case OneNoteSectionGroup: + results.Add(_resultCreator.CreateNewSectionResult(newItemName, parent)); + results.Add(_resultCreator.CreateNewSectionGroupResult(newItemName, parent)); + break; + case OneNoteSection section: + if (!section.Locked) + { + results.Add(_resultCreator.CreateNewPageResult(newItemName, section)); + } + + break; + default: + break; + } + } + } + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs index e7b99409015b..8e5cb650b906 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs @@ -8,7 +8,7 @@ namespace Microsoft.PowerToys.Run.Plugin.OneNote.Components { - public class SearchManager + public partial class SearchManager { private readonly PluginInitContext _context; private readonly OneNoteSettings _settings; @@ -25,7 +25,7 @@ internal SearchManager(PluginInitContext context, OneNoteSettings settings, Icon _settings = settings; _resultCreator = resultCreator; _iconProvider = iconProvider; - _notebookExplorer = new NotebookExplorer(this, resultCreator, iconProvider); + _notebookExplorer = new NotebookExplorer(this, resultCreator); } internal List Query(Query query) @@ -86,8 +86,8 @@ private List TitleSearch(string query, IOneNoteItem? parent, IEnumerable private List RecentPages(string query) { int count = 10; // TODO: Ideally this should match PowerToysRunSettings.MaxResultsToShow -/* var settingsUtils = new SettingsUtils(); - var generalSettings = settingsUtils.GetSettings();*/ + /* var settingsUtils = new SettingsUtils(); + var generalSettings = settingsUtils.GetSettings();*/ if (query.Length > Keywords.RecentPages.Length && int.TryParse(query[Keywords.RecentPages.Length..], out int userChosenCount)) { count = userChosenCount; @@ -125,169 +125,5 @@ private bool SettingsCheck(IOneNoteItem item) return success; } - - private sealed class NotebookExplorer - { - private readonly SearchManager _searchManager; - private readonly ResultCreator _resultCreator; - private readonly IconProvider _iconProvider; - - internal NotebookExplorer(SearchManager searchManager, ResultCreator resultCreator, IconProvider iconProvider) - { - _searchManager = searchManager; - _resultCreator = resultCreator; - _iconProvider = iconProvider; - } - - internal List Query(Query query) - { - var results = new List(); - - string fullSearch = query.Search[(query.Search.IndexOf(Keywords.NotebookExplorer, StringComparison.Ordinal) + Keywords.NotebookExplorer.Length)..]; - - IOneNoteItem? parent = null; - IEnumerable collection = OneNoteApplication.GetNotebooks(); - - string[] searches = fullSearch.Split(Keywords.NotebookExplorerSeparator, StringSplitOptions.None); - - for (int i = -1; i < searches.Length - 1; i++) - { - if (i < 0) - { - continue; - } - - parent = collection.FirstOrDefault(item => item.Name.Equals(searches[i], StringComparison.Ordinal)); - if (parent == null) - { - return results; - } - - collection = parent.Children; - } - - string lastSearch = searches[^1]; - - results = lastSearch switch - { - // Empty search so show all in collection - string search when string.IsNullOrWhiteSpace(search) - => EmptySearch(parent, collection), - - // Search by title - string search when search.StartsWith(Keywords.TitleSearch, StringComparison.Ordinal) && parent is not OneNotePage - => _searchManager.TitleSearch(search, parent, collection), - - // Scoped search - string search when search.StartsWith(Keywords.ScopedSearch, StringComparison.Ordinal) && (parent is OneNoteNotebook || parent is OneNoteSectionGroup) - => ScopedSearch(search, parent), - - // Default search - _ => Explorer(lastSearch, parent, collection), - }; - - if (parent != null) - { - var result = _resultCreator.CreateOneNoteItemResult(parent, false, score: 4000); - result.Title = $"Open \"{parent.Name}\" in OneNote"; - result.SubTitle = lastSearch switch - { - string search when search.StartsWith(Keywords.TitleSearch, StringComparison.Ordinal) - => $"Now search by title in \"{parent.Name}\"", - - string search when search.StartsWith(Keywords.ScopedSearch, StringComparison.Ordinal) - => $"Now searching all pages in \"{parent.Name}\"", - - _ => $"Use \'{Keywords.ScopedSearch}\' to search this item. Use \'{Keywords.TitleSearch}\' to search by title in this item", - }; - - results.Add(result); - } - - return results; - } - - private List EmptySearch(IOneNoteItem? parent, IEnumerable collection) - { - List results = collection.Where(_searchManager.SettingsCheck) - .Select(item => _resultCreator.CreateOneNoteItemResult(item, true)) - .ToList(); - - return results.Count == 0 ? _resultCreator.NoItemsInCollection(parent, results) : results; - } - - private List ScopedSearch(string query, IOneNoteItem parent) - { - if (query.Length == Keywords.ScopedSearch.Length) - { - return _resultCreator.NoMatchesFound(_searchManager.showSingleResults); - } - - if (!char.IsLetterOrDigit(query[Keywords.ScopedSearch.Length])) - { - return _resultCreator.InvalidQuery(_searchManager.showSingleResults); - } - - string currentSearch = query[Keywords.TitleSearch.Length..]; - var results = new List(); - - results = OneNoteApplication.FindPages(currentSearch, parent) - .Select(pg => _resultCreator.CreatePageResult(pg, currentSearch)) - .ToList(); - - if (results.Count == 0) - { - results = _resultCreator.NoMatchesFound(_searchManager.showSingleResults); - } - - return results; - } - - private List Explorer(string search, IOneNoteItem? parent, IEnumerable collection) - { - List? highlightData = null; - int score = 0; - - var results = collection.Where(_searchManager.SettingsCheck) - .Where(item => _searchManager.FuzzySearch(item.Name, search, out highlightData, out score)) - .Select(item => _resultCreator.CreateOneNoteItemResult(item, true, highlightData, score)) - .ToList(); - - AddCreateNewOneNoteItemResults(search, parent, results); - return results; - } - - private void AddCreateNewOneNoteItemResults(string newItemName, IOneNoteItem? parent, List results) - { - if (!results.Any(result => string.Equals(newItemName.Trim(), result.Title, StringComparison.OrdinalIgnoreCase))) - { - if (parent?.IsInRecycleBin() == true) - { - return; - } - - switch (parent) - { - case null: - results.Add(_resultCreator.CreateNewNotebookResult(newItemName)); - break; - case OneNoteNotebook: - case OneNoteSectionGroup: - results.Add(_resultCreator.CreateNewSectionResult(newItemName, parent)); - results.Add(_resultCreator.CreateNewSectionGroupResult(newItemName, parent)); - break; - case OneNoteSection section: - if (!section.Locked) - { - results.Add(_resultCreator.CreateNewPageResult(newItemName, section)); - } - - break; - default: - break; - } - } - } - } } } diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Main.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Main.cs index 25fdb639e85a..9c132d5858b2 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Main.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Main.cs @@ -7,7 +7,6 @@ using Microsoft.PowerToys.Run.Plugin.OneNote.Components; using Microsoft.PowerToys.Run.Plugin.OneNote.Properties; using Microsoft.PowerToys.Settings.UI.Library; -using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Odotocodot.OneNote.Linq; using Wox.Plugin; using Timer = System.Timers.Timer; @@ -93,7 +92,7 @@ public List Query(Query query) { if (_resultCreator is null) { - return new List(); + return []; } if (!_oneNoteInstalled) @@ -110,10 +109,10 @@ public List Query(Query query) if (OneNoteApplication.HasComObject) { ResetTimeout(); - return _searchManager is null ? new List() : _searchManager.Query(query); + return _searchManager is null ? [] : _searchManager.Query(query); } - return new List(); + return []; } /// @@ -126,7 +125,7 @@ public List Query(Query query, bool delayedExecution) { if (_resultCreator is null) { - return new List(); + return []; } if (!_oneNoteInstalled) @@ -141,11 +140,11 @@ public List Query(Query query, bool delayedExecution) if (OneNoteApplication.HasComObject) { - return new List(); + return []; } ResetTimeout(); - return _searchManager is null ? new List() : _searchManager.Query(query); + return _searchManager is null ? [] : _searchManager.Query(query); } /// @@ -173,7 +172,7 @@ private void ResetTimeout() public List LoadContextMenus(Result selectedResult) { - return _resultCreator is null ? new List() : _resultCreator.LoadContextMenu(selectedResult); + return _resultCreator is null ? [] : _resultCreator.LoadContextMenu(selectedResult); } public Control CreateSettingPanel() => throw new NotImplementedException(); @@ -203,4 +202,3 @@ public void Dispose() } } } - From 88570f45ab0672fba8f8d1bfd773f531b3ea0feb Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Mon, 23 Dec 2024 17:35:38 +0000 Subject: [PATCH 05/13] Remove unused package references Removed Interop.Microsoft.Office.Interop.OneNote Remove ScipBe.Common.Office.OneNote --- Directory.Packages.props | 4 +--- .../Microsoft.PowerToys.Run.Plugin.OneNote.csproj | 2 -- src/modules/launcher/PowerLauncher/PowerLauncher.csproj | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 46fa48ac7e8d..2912d5aa89c5 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -20,7 +20,6 @@ - @@ -47,7 +46,7 @@ + --> @@ -63,7 +62,6 @@ - diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj index d48d422994dd..fb334123963f 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj @@ -34,13 +34,11 @@ - all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj index d12895f18798..5ed713fe28e1 100644 --- a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj +++ b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj @@ -44,13 +44,11 @@ - - runtime From 6bf24a55fd921282d4c26b4ddc067f85d0e72d71 Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Mon, 30 Dec 2024 11:52:08 +0000 Subject: [PATCH 06/13] Move user facing strings to resources --- .../Components/OneNoteSettings.cs | 23 +- .../Components/ResultCreator.cs | 85 +++-- .../SearchManager.NotebookExplorer.cs | 15 +- .../Components/SearchManager.cs | 3 +- .../Properties/Resources.Designer.cs | 360 ++++++++++++++++++ .../Properties/Resources.resx | 128 +++++++ 6 files changed, 564 insertions(+), 50 deletions(-) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteSettings.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteSettings.cs index c53f197db19f..e3cabae64c02 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteSettings.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteSettings.cs @@ -2,7 +2,10 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Globalization; +using System.Text; using System.Windows.Controls; +using Microsoft.PowerToys.Run.Plugin.OneNote.Properties; using Microsoft.PowerToys.Settings.UI.Library; using Wox.Plugin; @@ -11,6 +14,8 @@ namespace Microsoft.PowerToys.Run.Plugin.OneNote.Components public class OneNoteSettings : ISettingProvider { private bool coloredIcons; + private static readonly CompositeFormat ShowEncryptedSectionsDescription = CompositeFormat.Parse(Resources.ShowEncryptedSectionsDescription); + private static readonly CompositeFormat ShowRecycleBinDescription = CompositeFormat.Parse(Resources.ShowRecycleBinDescription); internal bool ShowUnreadItems { get; private set; } @@ -39,32 +44,32 @@ private set { Key = nameof(ShowUnreadItems), PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Checkbox, - DisplayLabel = string.Empty, - DisplayDescription = string.Empty, + DisplayLabel = Resources.DisplayUnreadIcon, + DisplayDescription = Resources.DisplayUnreadIconDescription, Value = true, }, new PluginAdditionalOption() { Key = nameof(ShowEncryptedSections), PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Checkbox, - DisplayLabel = string.Empty, - DisplayDescription = string.Empty, + DisplayLabel = Resources.ShowEncryptedSections, + DisplayDescription = string.Format(CultureInfo.CurrentCulture, ShowEncryptedSectionsDescription, Keywords.NotebookExplorer), Value = true, }, new PluginAdditionalOption() { Key = nameof(ShowRecycleBins), PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Checkbox, - DisplayLabel = string.Empty, - DisplayDescription = string.Empty, + DisplayLabel = Resources.ShowRecycleBin, + DisplayDescription = string.Format(CultureInfo.CurrentCulture, ShowRecycleBinDescription, Keywords.NotebookExplorer), Value = true, }, new PluginAdditionalOption() { Key = nameof(ComObjectTimeout), PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Numberbox, - DisplayLabel = "Test", - DisplayDescription = "Test", + DisplayLabel = Resources.OneNoteComObjectTimeout, + DisplayDescription = Resources.OneNoteComObjectTimeoutDescription, NumberValue = 10000, NumberBoxMin = 1000, NumberBoxMax = 120000, @@ -75,7 +80,7 @@ private set { Key = nameof(ColoredIcons), PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Checkbox, - DisplayLabel = string.Empty, + DisplayLabel = Resources.CreateColoredIconsForNotebooksSections, DisplayDescription = string.Empty, Value = true, }, diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs index d58313a13b1e..c186f7367afe 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs @@ -3,8 +3,11 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics; +using System.Globalization; using System.Reflection; +using System.Text; using System.Windows.Input; +using Microsoft.PowerToys.Run.Plugin.OneNote.Properties; using Odotocodot.OneNote.Linq; using Wox.Infrastructure; using Wox.Plugin; @@ -21,6 +24,18 @@ public class ResultCreator private const string PathSeparator = " > "; private static readonly string _oldSeparator = OneNoteApplication.RelativePathSeparator.ToString(); + private static readonly CompositeFormat ViewNotebookExplorerDescription = CompositeFormat.Parse(Resources.ViewNotebookExplorerDescription); + private static readonly CompositeFormat ViewRecentPagesDescription = CompositeFormat.Parse(Resources.ViewRecentPagesDescription); + private static readonly CompositeFormat CreatePage = CompositeFormat.Parse(Resources.CreatePage); + private static readonly CompositeFormat CreateSection = CompositeFormat.Parse(Resources.CreateSection); + private static readonly CompositeFormat CreateSectionGroup = CompositeFormat.Parse(Resources.CreateSectionGroup); + private static readonly CompositeFormat CreateNotebook = CompositeFormat.Parse(Resources.CreateNotebook); + private static readonly CompositeFormat Location = CompositeFormat.Parse(Resources.Location); + private static readonly CompositeFormat Path = CompositeFormat.Parse(Resources.Path); + private static readonly CompositeFormat SectionNamesCannotContain = CompositeFormat.Parse(Resources.SectionNamesCannotContain); + private static readonly CompositeFormat SectionGroupNamesCannotContain = CompositeFormat.Parse(Resources.SectionGroupNamesCannotContain); + private static readonly CompositeFormat NotebookNamesCannotContain = CompositeFormat.Parse(Resources.NotebookNamesCannotContain); + internal ResultCreator(PluginInitContext context, OneNoteSettings settings, IconProvider iconProvider) { _settings = settings; @@ -94,15 +109,14 @@ internal List EmptyQuery(Query query) { new Result { - Title = "Search OneNote pages", - QueryTextDisplay = string.Empty, + Title = Resources.SearchOneNotePages, IcoPath = _iconProvider.Search, Score = 5000, }, new Result { - Title = "View notebook explorer", - SubTitle = $"Type \"{Keywords.NotebookExplorer}\" or select this option to search by notebook structure ", + Title = Resources.ViewNotebookExplorer, + SubTitle = string.Format(CultureInfo.CurrentCulture, ViewNotebookExplorerDescription, Keywords.NotebookExplorer), QueryTextDisplay = Keywords.NotebookExplorer, IcoPath = _iconProvider.NotebookExplorer, Score = 2000, @@ -114,8 +128,8 @@ internal List EmptyQuery(Query query) }, new Result { - Title = "See recent pages", - SubTitle = $"Type \"{Keywords.RecentPages}\" or select this option to see recently modified pages", + Title = Resources.ViewRecentPages, + SubTitle = string.Format(CultureInfo.CurrentCulture, ViewRecentPagesDescription, Keywords.RecentPages), QueryTextDisplay = Keywords.RecentPages, IcoPath = _iconProvider.Recent, Score = -1000, @@ -127,7 +141,7 @@ internal List EmptyQuery(Query query) }, new Result { - Title = "New quick note", + Title = Resources.NewQuickNote, IcoPath = _iconProvider.QuickNote, Score = -4000, Action = ResultAction(() => @@ -138,7 +152,7 @@ internal List EmptyQuery(Query query) }, new Result { - Title = "Open and sync notebooks", + Title = Resources.OpenSyncNotebooks, IcoPath = _iconProvider.Sync, Score = int.MinValue, Action = ResultAction(() => @@ -189,7 +203,7 @@ internal Result CreateOneNoteItemResult(IOneNoteItem item, bool actionIsAutoComp if (section.Encrypted) { // potentially replace with glyphs if supported - title += $" [Encrypted] {(section.Locked ? "[Locked]" : "[Unlocked]")}"; + title += $" [Encrypted] {(section.Locked ? "[Locked]" : "[Unlocked]")} \uE72E"; } toolTip = @@ -254,8 +268,8 @@ internal Result CreateNewPageResult(string newPageName, OneNoteSection section) newPageName = newPageName.Trim(); return new Result { - Title = $"Create page: \"{newPageName}\"", - SubTitle = $"Path: {GetNicePath(section)}{PathSeparator}{newPageName}", + Title = string.Format(CultureInfo.CurrentCulture, CreatePage, newPageName), + SubTitle = string.Format(CultureInfo.CurrentCulture, Path, GetNicePath(section) + PathSeparator + newPageName), QueryTextDisplay = $"{GetQueryTextDisplay}{newPageName}", IcoPath = _iconProvider.NewPage, Action = ResultAction(() => @@ -273,10 +287,10 @@ internal Result CreateNewSectionResult(string newSectionName, IOneNoteItem paren return new Result { - Title = $"Create section: \"{newSectionName}\"", + Title = string.Format(CultureInfo.CurrentCulture, CreateSection, newSectionName), SubTitle = validTitle - ? $"Path: {GetNicePath(parent)}{PathSeparator}{newSectionName}" - : $"Section names cannot contain: {string.Join(' ', OneNoteApplication.InvalidSectionChars)}", + ? string.Format(CultureInfo.CurrentCulture, Path, GetNicePath(parent) + PathSeparator + newSectionName) + : string.Format(CultureInfo.CurrentCulture, SectionNamesCannotContain, string.Join(' ', OneNoteApplication.InvalidSectionChars)), QueryTextDisplay = $"{GetQueryTextDisplay}{newSectionName}", IcoPath = _iconProvider.NewSection, Action = ResultAction(() => @@ -311,10 +325,10 @@ internal Result CreateNewSectionGroupResult(string newSectionGroupName, IOneNote return new Result { - Title = $"Create section group: \"{newSectionGroupName}\"", + Title = string.Format(CultureInfo.CurrentCulture, CreateSectionGroup, newSectionGroupName), SubTitle = validTitle - ? $"Path: {GetNicePath(parent)}{PathSeparator}{newSectionGroupName}" - : $"Section group names cannot contain: {string.Join(' ', OneNoteApplication.InvalidSectionGroupChars)}", + ? string.Format(CultureInfo.CurrentCulture, Path, GetNicePath(parent) + PathSeparator + newSectionGroupName) + : string.Format(CultureInfo.CurrentCulture, SectionGroupNamesCannotContain, string.Join(' ', OneNoteApplication.InvalidSectionGroupChars)), QueryTextDisplay = $"{GetQueryTextDisplay}{newSectionGroupName}", IcoPath = _iconProvider.NewSectionGroup, Action = ResultAction(() => @@ -349,10 +363,10 @@ internal Result CreateNewNotebookResult(string newNotebookName) return new Result { - Title = $"Create notebook: \"{newNotebookName}\"", + Title = string.Format(CultureInfo.CurrentCulture, CreateNotebook, newNotebookName), SubTitle = validTitle - ? $"Location: {OneNoteApplication.GetDefaultNotebookLocation()}" - : $"Notebook names cannot contain: {string.Join(' ', OneNoteApplication.InvalidNotebookChars)}", + ? string.Format(CultureInfo.CurrentCulture, Location, OneNoteApplication.GetDefaultNotebookLocation()) + : string.Format(CultureInfo.CurrentCulture, NotebookNamesCannotContain, string.Join(' ', OneNoteApplication.InvalidNotebookChars)), QueryTextDisplay = $"{GetQueryTextDisplay}{newNotebookName}", IcoPath = _iconProvider.NewNotebook, Action = ResultAction(() => @@ -377,7 +391,7 @@ internal List LoadContextMenu(Result selectedResult) results.Add(new ContextMenuResult { PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = "Open and sync", + Title = Resources.OpenAndSync, Glyph = "\xE8A7", FontFamily = "Segoe MDL2 Assets", AcceleratorKey = Key.Enter, @@ -395,7 +409,7 @@ internal List LoadContextMenu(Result selectedResult) results.Add(new ContextMenuResult { PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = "Open in notebook explorer", + Title = Resources.OpenInNotebookExplorer, Glyph = "\xEC50", FontFamily = "Segoe MDL2 Assets", AcceleratorKey = Key.Enter, @@ -414,7 +428,7 @@ internal List LoadContextMenu(Result selectedResult) results.Add(new ContextMenuResult { PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = "Visit the Microsoft Store", + Title = Resources.VisitMicrosoftStore, Glyph = "\xE8A7", FontFamily = "Segoe MDL2 Assets", AcceleratorKey = Key.Enter, @@ -446,14 +460,14 @@ internal List NoItemsInCollection(IOneNoteItem? parent, List res case OneNoteNotebook: case OneNoteSectionGroup: // Can create section/section group - results.Add(NoItemsInCollectionResult("section", _iconProvider.NewSection, "(unencrypted) section")); - results.Add(NoItemsInCollectionResult("section group", _iconProvider.NewSectionGroup)); + results.Add(NoItemsInCollectionResult(Resources.CreateSection, _iconProvider.NewSection)); + results.Add(NoItemsInCollectionResult(Resources.CreateSectionGroup, _iconProvider.NewSectionGroup)); break; case OneNoteSection section: // Can create page if (!section.Locked) { - results.Add(NoItemsInCollectionResult("page", _iconProvider.NewPage)); + results.Add(NoItemsInCollectionResult(Resources.CreatePage, _iconProvider.NewPage)); } break; @@ -463,24 +477,23 @@ internal List NoItemsInCollection(IOneNoteItem? parent, List res return results; - static Result NoItemsInCollectionResult(string title, string iconPath, string? subTitle = null) + static Result NoItemsInCollectionResult(string title, string iconPath) { return new Result { - Title = $"Create {title}: \"\"", - SubTitle = $"No {subTitle ?? title}s found. Type a valid title to create one", + Title = title, + SubTitle = Resources.NoItemsFoundTypeValidName, IcoPath = iconPath, }; } } - // TODO Localize internal List NoMatchesFound(bool show) { return show ? SingleResult( - "No matches found", - "Try searching something else, or syncing your notebooks.", + Resources.NoMatchesFound, + Resources.NoMatchesFoundDescription, _iconProvider.Search) : []; } @@ -489,8 +502,8 @@ internal List InvalidQuery(bool show) { return show ? SingleResult( - "Invalid query", - "The first character of the search must be a letter or a digit", + Resources.InvalidQuery, + Resources.InvalidQueryDescription, _iconProvider.Warning) : []; } @@ -498,8 +511,8 @@ internal List InvalidQuery(bool show) internal List OneNoteNotInstalled() { var results = SingleResult( - "OneNote is not installed", - "Please install OneNote to use this plugin", + Resources.OneNoteNotInstalled, + Resources.OneNoteNotInstalledDescription, _iconProvider.Warning); results[0].ContextData = "https://apps.microsoft.com/store/detail/XPFFZHVGQWWLHB?ocid=pdpshare"; diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs index 04b2f2645d4d..bf047d18fc8e 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs @@ -2,6 +2,9 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Globalization; +using System.Text; +using Microsoft.PowerToys.Run.Plugin.OneNote.Properties; using Odotocodot.OneNote.Linq; using Wox.Plugin; @@ -13,6 +16,10 @@ private sealed class NotebookExplorer { private readonly SearchManager _searchManager; private readonly ResultCreator _resultCreator; + private static readonly CompositeFormat OpenXInOneNote = CompositeFormat.Parse(Resources.OpenXInOneNote); + private static readonly CompositeFormat SearchingByTitleInX = CompositeFormat.Parse(Resources.SearchingByTitleInX); + private static readonly CompositeFormat SearchingPagesInX = CompositeFormat.Parse(Resources.SearchingPagesInX); + private static readonly CompositeFormat SearchInItemInfo = CompositeFormat.Parse(Resources.SearchInItemInfo); internal NotebookExplorer(SearchManager searchManager, ResultCreator resultCreator) { @@ -70,16 +77,16 @@ string search when search.StartsWith(Keywords.ScopedSearch, StringComparison.Ord if (parent != null) { var result = _resultCreator.CreateOneNoteItemResult(parent, false, score: 4000); - result.Title = $"Open \"{parent.Name}\" in OneNote"; + result.Title = string.Format(CultureInfo.CurrentCulture, OpenXInOneNote, parent.Name); result.SubTitle = lastSearch switch { string search when search.StartsWith(Keywords.TitleSearch, StringComparison.Ordinal) - => $"Now search by title in \"{parent.Name}\"", + => string.Format(CultureInfo.CurrentCulture, SearchingByTitleInX, parent.Name), string search when search.StartsWith(Keywords.ScopedSearch, StringComparison.Ordinal) - => $"Now searching all pages in \"{parent.Name}\"", + => string.Format(CultureInfo.CurrentCulture, SearchingPagesInX, parent.Name), - _ => $"Use \'{Keywords.ScopedSearch}\' to search this item. Use \'{Keywords.TitleSearch}\' to search by title in this item", + _ => string.Format(CultureInfo.CurrentCulture, SearchInItemInfo, Keywords.ScopedSearch, Keywords.TitleSearch), }; results.Add(result); diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs index 8e5cb650b906..73c7ab18084e 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs @@ -2,6 +2,7 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.PowerToys.Run.Plugin.OneNote.Properties; using Odotocodot.OneNote.Linq; using Wox.Infrastructure; using Wox.Plugin; @@ -68,7 +69,7 @@ private List TitleSearch(string query, IOneNoteItem? parent, IEnumerable { if (query.Length == Keywords.TitleSearch.Length && parent == null) { - return ResultCreator.SingleResult($"Now searching by title.", null, _iconProvider.Search); + return ResultCreator.SingleResult(Resources.SearchingByTitle, null, _iconProvider.Search); } List? highlightData = null; diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.Designer.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.Designer.cs index f8a926537641..0beeb2cacbb0 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.Designer.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.Designer.cs @@ -60,6 +60,222 @@ internal Resources() { } } + /// + /// Looks up a localized string similar to Create colored icons for notebooks and sections. + /// + internal static string CreateColoredIconsForNotebooksSections { + get { + return ResourceManager.GetString("CreateColoredIconsForNotebooksSections", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create notebook: "{0}". + /// + internal static string CreateNotebook { + get { + return ResourceManager.GetString("CreateNotebook", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create page: "{0}". + /// + internal static string CreatePage { + get { + return ResourceManager.GetString("CreatePage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create section: "{0}". + /// + internal static string CreateSection { + get { + return ResourceManager.GetString("CreateSection", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create section group: "{0}". + /// + internal static string CreateSectionGroup { + get { + return ResourceManager.GetString("CreateSectionGroup", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Display unread icon. + /// + internal static string DisplayUnreadIcon { + get { + return ResourceManager.GetString("DisplayUnreadIcon", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Indicate an item has unread changes with: •. + /// + internal static string DisplayUnreadIconDescription { + get { + return ResourceManager.GetString("DisplayUnreadIconDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid query. + /// + internal static string InvalidQuery { + get { + return ResourceManager.GetString("InvalidQuery", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The first character of the search must be a letter or a digit. + /// + internal static string InvalidQueryDescription { + get { + return ResourceManager.GetString("InvalidQueryDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Location: {0}. + /// + internal static string Location { + get { + return ResourceManager.GetString("Location", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to New quick note. + /// + internal static string NewQuickNote { + get { + return ResourceManager.GetString("NewQuickNote", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No items found. Type a valid name to create one. + /// + internal static string NoItemsFoundTypeValidName { + get { + return ResourceManager.GetString("NoItemsFoundTypeValidName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No matches found. + /// + internal static string NoMatchesFound { + get { + return ResourceManager.GetString("NoMatchesFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Try searching something else, or syncing your notebooks.. + /// + internal static string NoMatchesFoundDescription { + get { + return ResourceManager.GetString("NoMatchesFoundDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Notebook names cannot contain: {0}. + /// + internal static string NotebookNamesCannotContain { + get { + return ResourceManager.GetString("NotebookNamesCannotContain", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to OneNote COM object timeout. + /// + internal static string OneNoteComObjectTimeout { + get { + return ResourceManager.GetString("OneNoteComObjectTimeout", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The delay in milliseconds before the OneNote COM object is removed from memory after user input. Higher values reduce the chances needed for performing the slow action of getting the COM object, but keep the COM object in memory for longer.. + /// + internal static string OneNoteComObjectTimeoutDescription { + get { + return ResourceManager.GetString("OneNoteComObjectTimeoutDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to OneNote is not installed. + /// + internal static string OneNoteNotInstalled { + get { + return ResourceManager.GetString("OneNoteNotInstalled", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Please install OneNote to use this plugin. + /// + internal static string OneNoteNotInstalledDescription { + get { + return ResourceManager.GetString("OneNoteNotInstalledDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open and sync. + /// + internal static string OpenAndSync { + get { + return ResourceManager.GetString("OpenAndSync", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open in notebook explorer. + /// + internal static string OpenInNotebookExplorer { + get { + return ResourceManager.GetString("OpenInNotebookExplorer", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open and sync notebooks. + /// + internal static string OpenSyncNotebooks { + get { + return ResourceManager.GetString("OpenSyncNotebooks", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open "{0}" in OneNote. + /// + internal static string OpenXInOneNote { + get { + return ResourceManager.GetString("OpenXInOneNote", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Path: {0}. + /// + internal static string Path { + get { + return ResourceManager.GetString("Path", resourceCulture); + } + } + /// /// Looks up a localized string similar to Searches your local OneNote notebooks. This plugin requires the OneNote desktop app which is included in Microsoft Office. /// @@ -77,5 +293,149 @@ internal static string PluginTitle { return ResourceManager.GetString("PluginTitle", resourceCulture); } } + + /// + /// Looks up a localized string similar to Now searching by title.. + /// + internal static string SearchingByTitle { + get { + return ResourceManager.GetString("SearchingByTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Now searching by title in "{0}". + /// + internal static string SearchingByTitleInX { + get { + return ResourceManager.GetString("SearchingByTitleInX", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Now searching all pages in "{0}". + /// + internal static string SearchingPagesInX { + get { + return ResourceManager.GetString("SearchingPagesInX", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use '{0}' to search this item. Use '{1}' to search by title in this item. + /// + internal static string SearchInItemInfo { + get { + return ResourceManager.GetString("SearchInItemInfo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Search OneNote pages. + /// + internal static string SearchOneNotePages { + get { + return ResourceManager.GetString("SearchOneNotePages", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Section group names cannot contain: {0}. + /// + internal static string SectionGroupNamesCannotContain { + get { + return ResourceManager.GetString("SectionGroupNamesCannotContain", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Section names cannot contain: {0}. + /// + internal static string SectionNamesCannotContain { + get { + return ResourceManager.GetString("SectionNamesCannotContain", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show encrypted sections. + /// + internal static string ShowEncryptedSections { + get { + return ResourceManager.GetString("ShowEncryptedSections", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to When using "{0}" show encrypted sections, if the section has been unlocked, allow temporary access.. + /// + internal static string ShowEncryptedSectionsDescription { + get { + return ResourceManager.GetString("ShowEncryptedSectionsDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show recycle bin. + /// + internal static string ShowRecycleBin { + get { + return ResourceManager.GetString("ShowRecycleBin", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to When using "{0}" show items that are in the recycle bin.. + /// + internal static string ShowRecycleBinDescription { + get { + return ResourceManager.GetString("ShowRecycleBinDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to View notebook explorer. + /// + internal static string ViewNotebookExplorer { + get { + return ResourceManager.GetString("ViewNotebookExplorer", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type "{0}" or select this option to search by notebook structure. + /// + internal static string ViewNotebookExplorerDescription { + get { + return ResourceManager.GetString("ViewNotebookExplorerDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to View recent pages. + /// + internal static string ViewRecentPages { + get { + return ResourceManager.GetString("ViewRecentPages", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type "{0}" or select this option to see recently modified pages. + /// + internal static string ViewRecentPagesDescription { + get { + return ResourceManager.GetString("ViewRecentPagesDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Visit the Microsoft Store. + /// + internal static string VisitMicrosoftStore { + get { + return ResourceManager.GetString("VisitMicrosoftStore", resourceCulture); + } + } } } diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.resx b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.resx index 0419897f3d2a..9d509aa26939 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.resx +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.resx @@ -123,4 +123,132 @@ Searches your local OneNote notebooks. This plugin requires the OneNote desktop app which is included in Microsoft Office + + Now searching by title. + + + Open "{0}" in OneNote + + + Now searching by title in "{0}" + + + Now searching all pages in "{0}" + + + Use '{0}' to search this item. Use '{1}' to search by title in this item + 0 and 1 are static keywords used by then plugin. + + + Display unread icon + + + Indicate an item has unread changes with: • + + + Show encrypted sections + + + When using "{0}" show encrypted sections, if the section has been unlocked, allow temporary access. + 0 is the NotebookExplorer static keyword + + + Show recycle bin + + + When using "{0}" show items that are in the recycle bin. + 0 is the NotebookExplorer static keyword + + + OneNote COM object timeout + + + The delay in milliseconds before the OneNote COM object is removed from memory after user input. Higher values reduce the chances needed for performing the slow action of getting the COM object, but keep the COM object in memory for longer. + + + Create colored icons for notebooks and sections + + + Search OneNote pages + + + View notebook explorer + + + Type "{0}" or select this option to search by notebook structure + 0 is the NotebookExplorer static keyword + + + View recent pages + + + Type "{0}" or select this option to see recently modified pages + + + New quick note + + + Open and sync notebooks + + + Create page: "{0}" + 0 is a user typed name + + + Path: {0} + + + Create section: "{0}" + 0 is a user typed name + + + Section names cannot contain: {0} + + + Create section group: "{0}" + 0 is a user typed name + + + Section group names cannot contain: {0} + + + Create notebook: "{0}" + 0 is a user typed name + + + Location: {0} + + + Notebook names cannot contain: {0} + + + Open and sync + + + Open in notebook explorer + + + Visit the Microsoft Store + + + No matches found + + + Try searching something else, or syncing your notebooks. + + + Invalid query + + + The first character of the search must be a letter or a digit + + + OneNote is not installed + + + Please install OneNote to use this plugin + + + No items found. Type a valid name to create one + \ No newline at end of file From b4752cfe41fbe9581aaa06e36082dc909299d5f7 Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Wed, 1 Jan 2025 11:45:02 +0000 Subject: [PATCH 07/13] Simplify result tooltips Added the Humanizer package Moved user facing strings to resources --- Directory.Packages.props | 1 + .../Components/ResultCreator.cs | 95 ++++++------------- ...rosoft.PowerToys.Run.Plugin.OneNote.csproj | 1 + .../Properties/Resources.Designer.cs | 27 ++++++ .../Properties/Resources.resx | 9 ++ .../PowerLauncher/PowerLauncher.csproj | 1 + 6 files changed, 68 insertions(+), 66 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 2912d5aa89c5..f60e7152ccc4 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -19,6 +19,7 @@ + diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs index c186f7367afe..9237d449eb05 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs @@ -7,6 +7,7 @@ using System.Reflection; using System.Text; using System.Windows.Input; +using Humanizer; using Microsoft.PowerToys.Run.Plugin.OneNote.Properties; using Odotocodot.OneNote.Linq; using Wox.Infrastructure; @@ -32,6 +33,7 @@ public class ResultCreator private static readonly CompositeFormat CreateNotebook = CompositeFormat.Parse(Resources.CreateNotebook); private static readonly CompositeFormat Location = CompositeFormat.Parse(Resources.Location); private static readonly CompositeFormat Path = CompositeFormat.Parse(Resources.Path); + private static readonly CompositeFormat LastModified = CompositeFormat.Parse(Resources.LastModified); private static readonly CompositeFormat SectionNamesCannotContain = CompositeFormat.Parse(Resources.SectionNamesCannotContain); private static readonly CompositeFormat SectionGroupNamesCannotContain = CompositeFormat.Parse(Resources.SectionGroupNamesCannotContain); private static readonly CompositeFormat NotebookNamesCannotContain = CompositeFormat.Parse(Resources.NotebookNamesCannotContain); @@ -48,56 +50,30 @@ internal ResultCreator(PluginInitContext context, OneNoteSettings settings, Icon private string GetTitle(IOneNoteItem item, List? highlightData) { string title = item.Name; - if (item.IsUnread && _settings.ShowUnreadItems) - { - string unread = "\u2022 "; - title = title.Insert(0, unread); - if (highlightData != null) - { - for (int i = 0; i < highlightData.Count; i++) - { - highlightData[i] += unread.Length; - } - } + if (!item.IsUnread || !_settings.ShowUnreadItems) + { + return title; } - return title; - } + const string unread = "\u2022 "; + title = title.Insert(0, unread); - private string GetQueryTextDisplay(IOneNoteItem item) => $"{Keywords.NotebookExplorer}{GetNicePath(item, Keywords.NotebookExplorerSeparator)}{Keywords.NotebookExplorerSeparator}"; - - private static string GetLastEdited(TimeSpan diff) - { - string lastEdited = "Last edited "; - if (PluralCheck(diff.TotalDays, "day", ref lastEdited) - || PluralCheck(diff.TotalHours, "hour", ref lastEdited) - || PluralCheck(diff.TotalMinutes, "min", ref lastEdited) - || PluralCheck(diff.TotalSeconds, "sec", ref lastEdited)) + if (highlightData == null) { - return lastEdited; - } - else - { - return lastEdited += "Now."; + return title; } - static bool PluralCheck(double totalTime, string timeType, ref string lastEdited) + for (int i = 0; i < highlightData.Count; i++) { - var roundedTime = (int)Math.Round(totalTime); - if (roundedTime > 0) - { - string plural = roundedTime == 1 ? string.Empty : "s"; - lastEdited += $"{roundedTime} {timeType}{plural} ago."; - return true; - } - else - { - return false; - } + highlightData[i] += unread.Length; } + + return title; } + private string GetQueryTextDisplay(IOneNoteItem item) => $"{Keywords.NotebookExplorer}{GetNicePath(item, Keywords.NotebookExplorerSeparator)}{Keywords.NotebookExplorerSeparator}"; + internal List EmptyQuery(Query query) { if (_context.CurrentPluginMetadata.IsGlobal && !query.RawUserQuery.StartsWith(query.ActionKeyword, StringComparison.Ordinal)) @@ -177,40 +153,25 @@ internal List EmptyQuery(Query query) internal Result CreateOneNoteItemResult(IOneNoteItem item, bool actionIsAutoComplete, List? highlightData = null, int score = 0) { string title = GetTitle(item, highlightData); - string toolTip = string.Empty; string subTitle = GetNicePath(item); string queryTextDisplay = GetQueryTextDisplay(item); + // TODO: Potential improvement would be to show the children of the OneNote item in its tooltip. + // E.g. for a notebook, it would display the number of section groups, sections and pages. + // Would require even more localisation. + // An example: https://github.com/Odotocodot/Flow.Launcher.Plugin.OneNote/blob/5f56aa81a19641197d4ea4a97dc22cf1aa21f5e6/Flow.Launcher.Plugin.OneNote/ResultCreator.cs#L145 switch (item) { case OneNoteNotebook notebook: - toolTip = - $"Last Modified:\t{notebook.LastModified:F}\n" + - $"Sections:\t\t{notebook.Sections.Count()}\n" + - $"Sections Groups:\t{notebook.SectionGroups.Count()}"; - subTitle = string.Empty; - break; - case OneNoteSectionGroup sectionGroup: - toolTip = - $"Path:\t\t{subTitle}\n" + - $"Last Modified:\t{sectionGroup.LastModified:F}\n" + - $"Sections:\t\t{sectionGroup.Sections.Count()}\n" + - $"Sections Groups:\t{sectionGroup.SectionGroups.Count()}"; - break; case OneNoteSection section: if (section.Encrypted) { - // potentially replace with glyphs if supported - title += $" [Encrypted] {(section.Locked ? "[Locked]" : "[Unlocked]")} \uE72E"; + // potentially replace with glyphs when/if supported + title += string.Format(CultureInfo.CurrentCulture, " [{0}]", section.Locked ? Resources.Locked : Resources.Unlocked); } - toolTip = - $"Path:\t\t{subTitle}\n" + - $"Last Modified:\t{section.LastModified}\n" + - $"Pages:\t\t{section.Pages.Count()}"; - break; case OneNotePage page: queryTextDisplay = !actionIsAutoComplete ? string.Empty : queryTextDisplay[..^1]; @@ -218,13 +179,15 @@ internal Result CreateOneNoteItemResult(IOneNoteItem item, bool actionIsAutoComp actionIsAutoComplete = false; subTitle = subTitle[..^(page.Name.Length + PathSeparator.Length)]; - toolTip = - $"Path:\t\t {subTitle} \n" + - $"Created:\t\t{page.Created:F}\n" + - $"Last Modified:\t{page.LastModified:F}"; break; } + var toolTip = string.Format(CultureInfo.CurrentCulture, LastModified, item.LastModified); + if (item is not OneNoteNotebook) + { + toolTip = toolTip.Insert(0, string.Format(CultureInfo.CurrentCulture, Path, subTitle) + "\n"); + } + return new Result { Title = title, @@ -258,8 +221,8 @@ internal Result CreatePageResult(OneNotePage page, string? query) internal Result CreateRecentPageResult(OneNotePage page) { var result = CreateOneNoteItemResult(page, false, null); - result.SubTitle = $"{GetLastEdited(DateTime.Now - page.LastModified)}\t{result.SubTitle}"; - result.IcoPath = _iconProvider.Page; + result.IcoPath = _iconProvider.Recent; + result.SubTitle = $"{page.LastModified.Humanize(culture: CultureInfo.CurrentCulture)} | {result.SubTitle}"; return result; } diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj index fb334123963f..e9ad17c3b8c4 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj @@ -35,6 +35,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.Designer.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.Designer.cs index 0beeb2cacbb0..ff0486d58409 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.Designer.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.Designer.cs @@ -141,6 +141,15 @@ internal static string InvalidQueryDescription { } } + /// + /// Looks up a localized string similar to Last Modified: {0:F}. + /// + internal static string LastModified { + get { + return ResourceManager.GetString("LastModified", resourceCulture); + } + } + /// /// Looks up a localized string similar to Location: {0}. /// @@ -150,6 +159,15 @@ internal static string Location { } } + /// + /// Looks up a localized string similar to Locked. + /// + internal static string Locked { + get { + return ResourceManager.GetString("Locked", resourceCulture); + } + } + /// /// Looks up a localized string similar to New quick note. /// @@ -393,6 +411,15 @@ internal static string ShowRecycleBinDescription { } } + /// + /// Looks up a localized string similar to Unlocked. + /// + internal static string Unlocked { + get { + return ResourceManager.GetString("Unlocked", resourceCulture); + } + } + /// /// Looks up a localized string similar to View notebook explorer. /// diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.resx b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.resx index 9d509aa26939..05d11076da22 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.resx +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.resx @@ -251,4 +251,13 @@ No items found. Type a valid name to create one + + Last Modified: {0:F} + + + Locked + + + Unlocked + \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj index 5ed713fe28e1..91356e70fe3a 100644 --- a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj +++ b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj @@ -46,6 +46,7 @@ + From b5c3401659927b7d4543925b9cab78dd0ba3d29f Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:31:06 +0000 Subject: [PATCH 08/13] Small code clean up --- .../SearchManager.NotebookExplorer.cs | 52 ++++++++++--------- .../Components/SearchManager.cs | 5 +- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs index bf047d18fc8e..3112334c8068 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs @@ -147,33 +147,35 @@ private List Explorer(string search, IOneNoteItem? parent, IEnumerable results) { - if (!results.Any(result => string.Equals(newItemName.Trim(), result.Title, StringComparison.OrdinalIgnoreCase))) + if (results.Any(result => string.Equals(newItemName.Trim(), result.Title, StringComparison.OrdinalIgnoreCase))) { - if (parent?.IsInRecycleBin() == true) - { - return; - } + return; + } - switch (parent) - { - case null: - results.Add(_resultCreator.CreateNewNotebookResult(newItemName)); - break; - case OneNoteNotebook: - case OneNoteSectionGroup: - results.Add(_resultCreator.CreateNewSectionResult(newItemName, parent)); - results.Add(_resultCreator.CreateNewSectionGroupResult(newItemName, parent)); - break; - case OneNoteSection section: - if (!section.Locked) - { - results.Add(_resultCreator.CreateNewPageResult(newItemName, section)); - } - - break; - default: - break; - } + if (parent?.IsInRecycleBin() == true) + { + return; + } + + switch (parent) + { + case null: + results.Add(_resultCreator.CreateNewNotebookResult(newItemName)); + break; + case OneNoteNotebook: + case OneNoteSectionGroup: + results.Add(_resultCreator.CreateNewSectionResult(newItemName, parent)); + results.Add(_resultCreator.CreateNewSectionGroupResult(newItemName, parent)); + break; + case OneNoteSection section: + if (!section.Locked) + { + results.Add(_resultCreator.CreateNewPageResult(newItemName, section)); + } + + break; + default: + break; } } } diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs index 73c7ab18084e..93a213b06aa0 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.cs @@ -60,9 +60,10 @@ private List DefaultSearch(string query) } var results = OneNoteApplication.FindPages(query) - .Select(pg => _resultCreator.CreatePageResult(pg, query)); + .Select(pg => _resultCreator.CreatePageResult(pg, query)) + .ToList(); - return results.Any() ? results.ToList() : _resultCreator.NoMatchesFound(showSingleResults); + return results.Count != 0 ? results : _resultCreator.NoMatchesFound(showSingleResults); } private List TitleSearch(string query, IOneNoteItem? parent, IEnumerable currentCollection) From ced5d4650c8a74bbd8402cf4053e296ad5d6ab80 Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:35:02 +0000 Subject: [PATCH 09/13] Remove unused package references Removed LazyCache package --- Directory.Packages.props | 3 +-- .../Microsoft.PowerToys.Run.Plugin.OneNote.csproj | 1 - src/modules/launcher/PowerLauncher/PowerLauncher.csproj | 3 +-- src/modules/launcher/Wox.Plugin/Wox.Plugin.csproj | 1 + 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index f60e7152ccc4..33203099094d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -21,8 +21,7 @@ - - + diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj index e9ad17c3b8c4..f478f2100aa0 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Microsoft.PowerToys.Run.Plugin.OneNote.csproj @@ -34,7 +34,6 @@ - all diff --git a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj index 91356e70fe3a..4d507fa2ed96 100644 --- a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj +++ b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj @@ -44,9 +44,8 @@ - - + diff --git a/src/modules/launcher/Wox.Plugin/Wox.Plugin.csproj b/src/modules/launcher/Wox.Plugin/Wox.Plugin.csproj index e9179e6ddf90..cbda9a5adc7c 100644 --- a/src/modules/launcher/Wox.Plugin/Wox.Plugin.csproj +++ b/src/modules/launcher/Wox.Plugin/Wox.Plugin.csproj @@ -31,6 +31,7 @@ + From 7fec7ccb1f86a688f67f16ec1b6234c15f430ca9 Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:39:14 +0000 Subject: [PATCH 10/13] Update plugin.json --- .../Microsoft.PowerToys.Run.Plugin.OneNote/plugin.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/plugin.json b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/plugin.json index 88874001b66c..f7853b8e4621 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/plugin.json +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/plugin.json @@ -4,8 +4,8 @@ "ActionKeyword": "o:", "IsGlobal": true, "Name": "OneNote", - "Author": "palenshus", - "Version": "1.0.0", + "Author": "palenshus and Odotocodot", + "Version": "2.0.0", "Language": "csharp", "Website": "https://aka.ms/PowerToys", "ExecuteFileName": "Microsoft.PowerToys.Run.Plugin.OneNote.dll", From fe0bd0219eab39848dcb5137f339d204cbda9a9d Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Thu, 2 Jan 2025 12:52:15 +0000 Subject: [PATCH 11/13] Add words to spell checker --- .github/actions/spell-check/expect.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index 0e8491dc44af..ad8e208faead 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -1019,9 +1019,11 @@ numberbox nwc Objbase objidl +ocid ocr Ocrsettings odbccp +Odotocodot officehubintl OFN ofs @@ -1083,6 +1085,7 @@ PCWSTR pdbs pdisp pdo +pdpshare pdto pdtobj pdw @@ -1823,6 +1826,7 @@ XDocument XElement xfd XFile +XIn XIncrement XNamespace Xoshiro From f10099af53c85a5c63c0bf99d3e7ebeccb1f9bd7 Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:34:16 +0000 Subject: [PATCH 12/13] Fix incorrect query text --- .../Components/ResultCreator.cs | 30 ++++++++++--------- .../SearchManager.NotebookExplorer.cs | 8 ++--- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs index 9237d449eb05..31557d0a17b5 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs @@ -72,7 +72,12 @@ private string GetTitle(IOneNoteItem item, List? highlightData) return title; } - private string GetQueryTextDisplay(IOneNoteItem item) => $"{Keywords.NotebookExplorer}{GetNicePath(item, Keywords.NotebookExplorerSeparator)}{Keywords.NotebookExplorerSeparator}"; + private string GetQueryTextDisplay(IOneNoteItem? parent) + { + return parent is null + ? $"{Keywords.NotebookExplorer}" + : $"{Keywords.NotebookExplorer}{GetNicePath(parent, Keywords.NotebookExplorerSeparator)}{Keywords.NotebookExplorerSeparator}"; + } internal List EmptyQuery(Query query) { @@ -174,7 +179,7 @@ internal Result CreateOneNoteItemResult(IOneNoteItem item, bool actionIsAutoComp break; case OneNotePage page: - queryTextDisplay = !actionIsAutoComplete ? string.Empty : queryTextDisplay[..^1]; + queryTextDisplay = !actionIsAutoComplete ? page.Name : queryTextDisplay[..^1]; actionIsAutoComplete = false; @@ -233,7 +238,7 @@ internal Result CreateNewPageResult(string newPageName, OneNoteSection section) { Title = string.Format(CultureInfo.CurrentCulture, CreatePage, newPageName), SubTitle = string.Format(CultureInfo.CurrentCulture, Path, GetNicePath(section) + PathSeparator + newPageName), - QueryTextDisplay = $"{GetQueryTextDisplay}{newPageName}", + QueryTextDisplay = $"{GetQueryTextDisplay(section)}{newPageName}", IcoPath = _iconProvider.NewPage, Action = ResultAction(() => { @@ -254,7 +259,7 @@ internal Result CreateNewSectionResult(string newSectionName, IOneNoteItem paren SubTitle = validTitle ? string.Format(CultureInfo.CurrentCulture, Path, GetNicePath(parent) + PathSeparator + newSectionName) : string.Format(CultureInfo.CurrentCulture, SectionNamesCannotContain, string.Join(' ', OneNoteApplication.InvalidSectionChars)), - QueryTextDisplay = $"{GetQueryTextDisplay}{newSectionName}", + QueryTextDisplay = $"{GetQueryTextDisplay(parent)}{newSectionName}", IcoPath = _iconProvider.NewSection, Action = ResultAction(() => { @@ -292,7 +297,7 @@ internal Result CreateNewSectionGroupResult(string newSectionGroupName, IOneNote SubTitle = validTitle ? string.Format(CultureInfo.CurrentCulture, Path, GetNicePath(parent) + PathSeparator + newSectionGroupName) : string.Format(CultureInfo.CurrentCulture, SectionGroupNamesCannotContain, string.Join(' ', OneNoteApplication.InvalidSectionGroupChars)), - QueryTextDisplay = $"{GetQueryTextDisplay}{newSectionGroupName}", + QueryTextDisplay = $"{GetQueryTextDisplay(parent)}{newSectionGroupName}", IcoPath = _iconProvider.NewSectionGroup, Action = ResultAction(() => { @@ -330,7 +335,7 @@ internal Result CreateNewNotebookResult(string newNotebookName) SubTitle = validTitle ? string.Format(CultureInfo.CurrentCulture, Location, OneNoteApplication.GetDefaultNotebookLocation()) : string.Format(CultureInfo.CurrentCulture, NotebookNamesCannotContain, string.Join(' ', OneNoteApplication.InvalidNotebookChars)), - QueryTextDisplay = $"{GetQueryTextDisplay}{newNotebookName}", + QueryTextDisplay = $"{GetQueryTextDisplay(null)}{newNotebookName}", IcoPath = _iconProvider.NewNotebook, Action = ResultAction(() => { @@ -426,13 +431,9 @@ internal List NoItemsInCollection(IOneNoteItem? parent, List res results.Add(NoItemsInCollectionResult(Resources.CreateSection, _iconProvider.NewSection)); results.Add(NoItemsInCollectionResult(Resources.CreateSectionGroup, _iconProvider.NewSectionGroup)); break; - case OneNoteSection section: + case OneNoteSection section when !section.IsDeletedPages && !section.Locked: // Can create page - if (!section.Locked) - { - results.Add(NoItemsInCollectionResult(Resources.CreatePage, _iconProvider.NewPage)); - } - + results.Add(NoItemsInCollectionResult(Resources.CreatePage, _iconProvider.NewPage)); break; default: break; @@ -440,11 +441,12 @@ internal List NoItemsInCollection(IOneNoteItem? parent, List res return results; - static Result NoItemsInCollectionResult(string title, string iconPath) + Result NoItemsInCollectionResult(string title, string iconPath) { return new Result { - Title = title, + Title = string.Format(CultureInfo.CurrentCulture, title, string.Empty), + QueryTextDisplay = $"{GetQueryTextDisplay(parent)}", SubTitle = Resources.NoItemsFoundTypeValidName, IcoPath = iconPath, }; diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs index 3112334c8068..7d34be43522e 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/SearchManager.NotebookExplorer.cs @@ -167,12 +167,8 @@ private void AddCreateNewOneNoteItemResults(string newItemName, IOneNoteItem? pa results.Add(_resultCreator.CreateNewSectionResult(newItemName, parent)); results.Add(_resultCreator.CreateNewSectionGroupResult(newItemName, parent)); break; - case OneNoteSection section: - if (!section.Locked) - { - results.Add(_resultCreator.CreateNewPageResult(newItemName, section)); - } - + case OneNoteSection section when !section.Locked: + results.Add(_resultCreator.CreateNewPageResult(newItemName, section)); break; default: break; From d10358a24d14b41e3c7c4f7fb3232306e865119e Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:34:27 +0000 Subject: [PATCH 13/13] Refactor creating new OneNote item results --- .../Components/OneNoteItemExtensions.cs | 2 +- .../Components/ResultCreator.cs | 142 +++++++----------- .../Properties/Resources.Designer.cs | 9 -- .../Properties/Resources.resx | 3 - 4 files changed, 52 insertions(+), 104 deletions(-) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteItemExtensions.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteItemExtensions.cs index 714a08af8bef..6d13c62d6f64 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteItemExtensions.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/OneNoteItemExtensions.cs @@ -31,7 +31,7 @@ internal static bool OpenItemInOneNote(this IOneNoteItem item) /// /// Brings OneNote to the foreground and restores it if minimized. /// - private static void ShowOneNote() + internal static void ShowOneNote() { using var process = Process.GetProcessesByName("onenote").FirstOrDefault(); if (process?.MainWindowHandle != null) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs index 31557d0a17b5..776cbaf444a9 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Components/ResultCreator.cs @@ -2,6 +2,7 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Collections.Immutable; using System.Diagnostics; using System.Globalization; using System.Reflection; @@ -31,7 +32,6 @@ public class ResultCreator private static readonly CompositeFormat CreateSection = CompositeFormat.Parse(Resources.CreateSection); private static readonly CompositeFormat CreateSectionGroup = CompositeFormat.Parse(Resources.CreateSectionGroup); private static readonly CompositeFormat CreateNotebook = CompositeFormat.Parse(Resources.CreateNotebook); - private static readonly CompositeFormat Location = CompositeFormat.Parse(Resources.Location); private static readonly CompositeFormat Path = CompositeFormat.Parse(Resources.Path); private static readonly CompositeFormat LastModified = CompositeFormat.Parse(Resources.LastModified); private static readonly CompositeFormat SectionNamesCannotContain = CompositeFormat.Parse(Resources.SectionNamesCannotContain); @@ -72,7 +72,7 @@ private string GetTitle(IOneNoteItem item, List? highlightData) return title; } - private string GetQueryTextDisplay(IOneNoteItem? parent) + private static string GetQueryTextDisplay(IOneNoteItem? parent) { return parent is null ? $"{Keywords.NotebookExplorer}" @@ -231,36 +231,24 @@ internal Result CreateRecentPageResult(OneNotePage page) return result; } - internal Result CreateNewPageResult(string newPageName, OneNoteSection section) + private Result CreateNewOneNoteItemResult(string newItemName, IOneNoteItem? parent, CompositeFormat titleFormat, ImmutableArray invalidCharacters, CompositeFormat subTitleFormat, string iconPath, Action createItemAction) { - newPageName = newPageName.Trim(); - return new Result - { - Title = string.Format(CultureInfo.CurrentCulture, CreatePage, newPageName), - SubTitle = string.Format(CultureInfo.CurrentCulture, Path, GetNicePath(section) + PathSeparator + newPageName), - QueryTextDisplay = $"{GetQueryTextDisplay(section)}{newPageName}", - IcoPath = _iconProvider.NewPage, - Action = ResultAction(() => - { - OneNoteApplication.CreatePage(section, newPageName, true); - return true; - }), - }; - } + newItemName = newItemName.Trim(); - internal Result CreateNewSectionResult(string newSectionName, IOneNoteItem parent) - { - newSectionName = newSectionName.Trim(); - bool validTitle = OneNoteApplication.IsSectionNameValid(newSectionName); + bool validTitle = !string.IsNullOrWhiteSpace(newItemName) && !invalidCharacters.Any(newItemName.Contains); + + string subTitle = parent == null + ? OneNoteApplication.GetDefaultNotebookLocation() + System.IO.Path.DirectorySeparatorChar + newItemName + : GetNicePath(parent) + PathSeparator + newItemName; return new Result { - Title = string.Format(CultureInfo.CurrentCulture, CreateSection, newSectionName), + Title = string.Format(CultureInfo.CurrentCulture, titleFormat, newItemName), SubTitle = validTitle - ? string.Format(CultureInfo.CurrentCulture, Path, GetNicePath(parent) + PathSeparator + newSectionName) - : string.Format(CultureInfo.CurrentCulture, SectionNamesCannotContain, string.Join(' ', OneNoteApplication.InvalidSectionChars)), - QueryTextDisplay = $"{GetQueryTextDisplay(parent)}{newSectionName}", - IcoPath = _iconProvider.NewSection, + ? string.Format(CultureInfo.CurrentCulture, Path, subTitle) + : string.Format(CultureInfo.CurrentCulture, subTitleFormat, string.Join(' ', invalidCharacters)), + QueryTextDisplay = $"{GetQueryTextDisplay(parent)}{newItemName}", + IcoPath = iconPath, Action = ResultAction(() => { if (!validTitle) @@ -268,87 +256,59 @@ internal Result CreateNewSectionResult(string newSectionName, IOneNoteItem paren return false; } - switch (parent) - { - case OneNoteNotebook notebook: - OneNoteApplication.CreateSection(notebook, newSectionName, true); - break; - case OneNoteSectionGroup sectionGroup: - OneNoteApplication.CreateSection(sectionGroup, newSectionName, true); - break; - default: - break; - } + createItemAction(); - _context.API.ChangeQuery(_context.CurrentPluginMetadata.ActionKeyword, true); + OneNoteItemExtensions.ShowOneNote(); + _context.API.ChangeQuery($"{GetQueryTextDisplay(parent)}{newItemName}", true); return true; }), }; } - internal Result CreateNewSectionGroupResult(string newSectionGroupName, IOneNoteItem parent) + internal Result CreateNewPageResult(string newPageName, OneNoteSection section) { - newSectionGroupName = newSectionGroupName.Trim(); - bool validTitle = OneNoteApplication.IsSectionGroupNameValid(newSectionGroupName); + return CreateNewOneNoteItemResult(newPageName, section, CreatePage, [], SectionNamesCannotContain, _iconProvider.NewPage, () => OneNoteApplication.CreatePage(section, newPageName, true)); + } - return new Result + internal Result CreateNewSectionResult(string newSectionName, IOneNoteItem parent) + { + return CreateNewOneNoteItemResult(newSectionName, parent, CreateSection, OneNoteApplication.InvalidSectionChars, SectionNamesCannotContain, _iconProvider.NewSection, () => { - Title = string.Format(CultureInfo.CurrentCulture, CreateSectionGroup, newSectionGroupName), - SubTitle = validTitle - ? string.Format(CultureInfo.CurrentCulture, Path, GetNicePath(parent) + PathSeparator + newSectionGroupName) - : string.Format(CultureInfo.CurrentCulture, SectionGroupNamesCannotContain, string.Join(' ', OneNoteApplication.InvalidSectionGroupChars)), - QueryTextDisplay = $"{GetQueryTextDisplay(parent)}{newSectionGroupName}", - IcoPath = _iconProvider.NewSectionGroup, - Action = ResultAction(() => + switch (parent) { - if (!validTitle) - { - return false; - } - - switch (parent) - { - case OneNoteNotebook notebook: - OneNoteApplication.CreateSectionGroup(notebook, newSectionGroupName, true); - break; - case OneNoteSectionGroup sectionGroup: - OneNoteApplication.CreateSectionGroup(sectionGroup, newSectionGroupName, true); - break; - default: - break; - } - - _context.API.ChangeQuery(_context.CurrentPluginMetadata.ActionKeyword, true); - return true; - }), - }; + case OneNoteNotebook notebook: + OneNoteApplication.CreateSection(notebook, newSectionName, true); + break; + case OneNoteSectionGroup sectionGroup: + OneNoteApplication.CreateSection(sectionGroup, newSectionName, true); + break; + default: + break; + } + }); } - internal Result CreateNewNotebookResult(string newNotebookName) + internal Result CreateNewSectionGroupResult(string newSectionGroupName, IOneNoteItem parent) { - newNotebookName = newNotebookName.Trim(); - bool validTitle = OneNoteApplication.IsNotebookNameValid(newNotebookName); - - return new Result + return CreateNewOneNoteItemResult(newSectionGroupName, parent, CreateSectionGroup, OneNoteApplication.InvalidSectionGroupChars, SectionGroupNamesCannotContain, _iconProvider.NewSectionGroup, () => { - Title = string.Format(CultureInfo.CurrentCulture, CreateNotebook, newNotebookName), - SubTitle = validTitle - ? string.Format(CultureInfo.CurrentCulture, Location, OneNoteApplication.GetDefaultNotebookLocation()) - : string.Format(CultureInfo.CurrentCulture, NotebookNamesCannotContain, string.Join(' ', OneNoteApplication.InvalidNotebookChars)), - QueryTextDisplay = $"{GetQueryTextDisplay(null)}{newNotebookName}", - IcoPath = _iconProvider.NewNotebook, - Action = ResultAction(() => + switch (parent) { - if (!validTitle) - { - return false; - } + case OneNoteNotebook notebook: + OneNoteApplication.CreateSectionGroup(notebook, newSectionGroupName, true); + break; + case OneNoteSectionGroup sectionGroup: + OneNoteApplication.CreateSectionGroup(sectionGroup, newSectionGroupName, true); + break; + default: + break; + } + }); + } - OneNoteApplication.CreateNotebook(newNotebookName, true); - _context.API.ChangeQuery(_context.CurrentPluginMetadata.ActionKeyword, true); - return true; - }), - }; + internal Result CreateNewNotebookResult(string newNotebookName) + { + return CreateNewOneNoteItemResult(newNotebookName, null, CreateNotebook, OneNoteApplication.InvalidNotebookChars, NotebookNamesCannotContain, _iconProvider.NewNotebook, () => OneNoteApplication.CreateNotebook(newNotebookName, true)); } internal List LoadContextMenu(Result selectedResult) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.Designer.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.Designer.cs index ff0486d58409..20b7a89eec89 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.Designer.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.Designer.cs @@ -150,15 +150,6 @@ internal static string LastModified { } } - /// - /// Looks up a localized string similar to Location: {0}. - /// - internal static string Location { - get { - return ResourceManager.GetString("Location", resourceCulture); - } - } - /// /// Looks up a localized string similar to Locked. /// diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.resx b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.resx index 05d11076da22..bb3d78f06e36 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.resx +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.OneNote/Properties/Resources.resx @@ -215,9 +215,6 @@ Create notebook: "{0}" 0 is a user typed name - - Location: {0} - Notebook names cannot contain: {0}