-
-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add HashtaggerDialog to cherry-pick tags for insertion
- Loading branch information
1 parent
b6014ce
commit f55fe42
Showing
22 changed files
with
4,510 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//************************************************************************************************ | ||
// Copyright © 2024 Steven M Cohn. All rights reserved. | ||
//************************************************************************************************ | ||
|
||
namespace River.OneMoreAddIn.Commands | ||
{ | ||
using River.OneMoreAddIn.Models; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
using System.Xml.Linq; | ||
|
||
internal class HashtaggerCommand : Command | ||
{ | ||
|
||
public HashtaggerCommand() | ||
{ | ||
} | ||
|
||
|
||
public override async Task Execute(params object[] args) | ||
{ | ||
await using var one = new OneNote(out var page, out var ns); | ||
|
||
using var dialog = new HashtaggerDialog(page); | ||
if (dialog.ShowDialog(owner) != DialogResult.OK) | ||
{ | ||
return; | ||
} | ||
|
||
var updated = false; | ||
if (dialog.AddToBank) | ||
{ | ||
var banker = new TagBankCommand(); | ||
banker.MakeWordBank(page, ns); | ||
if (banker.BankOutline is not null) | ||
{ | ||
var run = banker.BankOutline.Descendants(ns + "T").FirstOrDefault(); | ||
if (run.GetCData() is XCData cdata) | ||
{ | ||
cdata.Value = $"{cdata.Value} {dialog.Tags}"; | ||
updated = true; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
var editor = new PageEditor(page); | ||
editor.InsertOrReplace(dialog.Tags); | ||
updated = true; | ||
} | ||
|
||
if (updated) | ||
{ | ||
|
||
await one.Update(page); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.