Skip to content

Commit c303ed6

Browse files
committed
Implement the preview panel
1 parent 3e998cb commit c303ed6

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Flow.Launcher.Plugin.OneNote/ResultCreator.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public List<Result> EmptyQuery()
8585
AutoCompleteText = $"{ActionKeyword} {settings.Keywords.RecentPages}",
8686
IcoPath = iconProvider.Recent,
8787
Score = -1000,
88-
Action = c =>
88+
Action = _ =>
8989
{
9090
context.API.ChangeQuery($"{ActionKeyword} {settings.Keywords.RecentPages}", true);
9191
return false;
@@ -96,8 +96,8 @@ public List<Result> EmptyQuery()
9696
Title = "New quick note",
9797
IcoPath = iconProvider.QuickNote,
9898
Score = -4000,
99-
PreviewPanel = new Lazy<UserControl>(() => new NewOneNotePagePreviewPanel(context, null, null)),
100-
Action = c =>
99+
PreviewPanel = GetNewPagePreviewPanel(null, null),
100+
Action = _ =>
101101
{
102102
OneNoteApplication.CreateQuickNote(true);
103103
WindowHelper.FocusOneNote();
@@ -109,7 +109,7 @@ public List<Result> EmptyQuery()
109109
Title = "Open and sync notebooks",
110110
IcoPath = iconProvider.Sync,
111111
Score = int.MinValue,
112-
Action = c =>
112+
Action = _ =>
113113
{
114114
var notebooks = OneNoteApplication.GetNotebooks();
115115
foreach (var notebook in notebooks)
@@ -240,8 +240,8 @@ public Result CreateNewPageResult(string newPageName, OneNoteSection section)
240240
SubTitle = $"Path: {GetNicePath(section)}{PathSeparator}{newPageName}",
241241
AutoCompleteText = $"{GetAutoCompleteText}{newPageName}",
242242
IcoPath = iconProvider.NewPage,
243-
PreviewPanel = new Lazy<UserControl>(() => new NewOneNotePagePreviewPanel(context, section, newPageName)),
244-
Action = c =>
243+
PreviewPanel = GetNewPagePreviewPanel(section, newPageName),
244+
Action = _ =>
245245
{
246246
OneNoteApplication.CreatePage(section, newPageName, true);
247247
Main.ForceReQuery();
@@ -264,7 +264,7 @@ public Result CreateNewSectionResult(string newSectionName, IOneNoteItem parent)
264264
: $"Section names cannot contain: {string.Join(' ', OneNoteApplication.InvalidSectionChars)}",
265265
AutoCompleteText = $"{GetAutoCompleteText}{newSectionName}",
266266
IcoPath = iconProvider.NewSection,
267-
Action = c =>
267+
Action = _ =>
268268
{
269269
if (!validTitle)
270270
{
@@ -301,7 +301,7 @@ public Result CreateNewSectionGroupResult(string newSectionGroupName, IOneNoteIt
301301
: $"Section group names cannot contain: {string.Join(' ', OneNoteApplication.InvalidSectionGroupChars)}",
302302
AutoCompleteText = $"{GetAutoCompleteText}{newSectionGroupName}",
303303
IcoPath = iconProvider.NewSectionGroup,
304-
Action = c =>
304+
Action = _ =>
305305
{
306306
if (!validTitle)
307307
{
@@ -338,7 +338,7 @@ public Result CreateNewNotebookResult(string newNotebookName)
338338
: $"Notebook names cannot contain: {string.Join(' ', OneNoteApplication.InvalidNotebookChars)}",
339339
AutoCompleteText = $"{GetAutoCompleteText}{newNotebookName}",
340340
IcoPath = iconProvider.NewNotebook,
341-
Action = c =>
341+
Action = _ =>
342342
{
343343
if (!validTitle)
344344
{
@@ -411,10 +411,14 @@ Result NoItemsInCollectionResult(string title, string iconPath, string subTitle
411411
Title = $"Create {title}: \"\"",
412412
SubTitle = $"No {subTitle ?? title}s found. Type a valid title to create one",
413413
IcoPath = iconPath,
414-
PreviewPanel = section != null ? new Lazy<UserControl>(() => new NewOneNotePagePreviewPanel(context, section, null)) : null ,
414+
PreviewPanel = section != null ? GetNewPagePreviewPanel(section, null) : null ,
415415
};
416416
}
417417
}
418+
419+
private Lazy<UserControl> GetNewPagePreviewPanel(OneNoteSection section, string pageTitle) =>
420+
new(() => new NewOneNotePagePreviewPanel(context, section, pageTitle));
421+
418422
public static List<Result> NoMatchesFound()
419423
{
420424
return SingleResult("No matches found",

0 commit comments

Comments
 (0)