Skip to content

Commit

Permalink
OneMore Calendar Beta (stevencohn#373)
Browse files Browse the repository at this point in the history
* OneMore Calendar Beta, see Wiki
* Created new File menu; moved import and export commands to this menu
* Updated Link References command to optionally include unindexed pages in query, per stevencohn#358
* Updated Link References command to avoid duplicating the references
* Updated Insert TOC command to avoid duplicating the TOC
* Added ability to reset orphaned Outlook tasks from the Import Outlook Tasks dialog, per stevencohn#349
* Added Export dialog option to replace spaces in file names with underscores, per stevencohn#366
* Fixed Search and Replace to properly replace dollar sign and caret, per stevencohn#372
  • Loading branch information
stevencohn authored Jan 9, 2022
1 parent 0d15fa5 commit c87cad0
Show file tree
Hide file tree
Showing 95 changed files with 7,962 additions and 133 deletions.
14 changes: 14 additions & 0 deletions OneMore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneMoreProtocolHandler", "O
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneMoreSetupActions", "OneMoreSetupActions\OneMoreSetupActions.csproj", "{200381E7-37C7-4B30-9F5E-81FA44BF83CC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneMoreCalendar", "OneMoreCalendar\OneMoreCalendar.csproj", "{1F87159C-B663-4464-B272-E0C57BE22306}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -103,6 +105,18 @@ Global
{200381E7-37C7-4B30-9F5E-81FA44BF83CC}.Release|x64.Build.0 = Release|Any CPU
{200381E7-37C7-4B30-9F5E-81FA44BF83CC}.Release|x86.ActiveCfg = Release|Any CPU
{200381E7-37C7-4B30-9F5E-81FA44BF83CC}.Release|x86.Build.0 = Release|Any CPU
{1F87159C-B663-4464-B272-E0C57BE22306}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F87159C-B663-4464-B272-E0C57BE22306}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F87159C-B663-4464-B272-E0C57BE22306}.Debug|x64.ActiveCfg = Debug|Any CPU
{1F87159C-B663-4464-B272-E0C57BE22306}.Debug|x64.Build.0 = Debug|Any CPU
{1F87159C-B663-4464-B272-E0C57BE22306}.Debug|x86.ActiveCfg = Debug|Any CPU
{1F87159C-B663-4464-B272-E0C57BE22306}.Debug|x86.Build.0 = Debug|Any CPU
{1F87159C-B663-4464-B272-E0C57BE22306}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F87159C-B663-4464-B272-E0C57BE22306}.Release|Any CPU.Build.0 = Release|Any CPU
{1F87159C-B663-4464-B272-E0C57BE22306}.Release|x64.ActiveCfg = Release|Any CPU
{1F87159C-B663-4464-B272-E0C57BE22306}.Release|x64.Build.0 = Release|Any CPU
{1F87159C-B663-4464-B272-E0C57BE22306}.Release|x86.ActiveCfg = Release|Any CPU
{1F87159C-B663-4464-B272-E0C57BE22306}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 3 additions & 0 deletions OneMore/AddInCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public async Task ArrangeContainersCmd(IRibbonControl control)
public async Task BreakingCmd(IRibbonControl control)
=> await factory.Run<BreakingCommand>();

public async Task CalendarCmd(IRibbonControl control)
=> await factory.Run<CalendarCommand>();

public async Task ChangePageColorCmd(IRibbonControl control)
=> await factory.Run<ChangePageColorCommand>();

Expand Down
10 changes: 5 additions & 5 deletions OneMore/Commands/Extras/AnalyzeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public override async Task Execute(params object[] args)
progress.Show(owner);

var container = page.EnsureContentContainer();
var notebooks = one.GetNotebooks();
var notebooks = await one.GetNotebooks();

var prev = false;

Expand All @@ -112,7 +112,7 @@ public override async Task Execute(params object[] args)
WriteHorizontalLine(page, container);
}

ReportSections(container, notebooks);
await ReportSections(container, notebooks);
prev = true;
}

Expand All @@ -132,7 +132,7 @@ public override async Task Execute(params object[] args)
WriteHorizontalLine(page, container);
}

ReportAllPages(container, one.GetNotebook(), null, pageId);
ReportAllPages(container, await one.GetNotebook(), null, pageId);
}

progress.SetMessage("Updating report...");
Expand Down Expand Up @@ -337,7 +337,7 @@ private void WriteHorizontalLine(Page page, XElement container)

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

private void ReportSections(XElement container, XElement notebooks)
private async Task ReportSections(XElement container, XElement notebooks)
{
progress.SetMessage("Sections...");
progress.Increment();
Expand Down Expand Up @@ -373,7 +373,7 @@ private void ReportSections(XElement container, XElement notebooks)
row[2].SetContent(new Paragraph("# of Copies").SetStyle(HeaderCss).SetAlignment("center"));
row[3].SetContent(new Paragraph("Total Size").SetStyle(HeaderCss).SetAlignment("center"));

var notebook = one.GetNotebook(book.Attribute("ID").Value);
var notebook = await one.GetNotebook(book.Attribute("ID").Value);

var total = ReportSections(table, notebook, null);

Expand Down
14 changes: 8 additions & 6 deletions OneMore/Commands/Extras/SortCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Copyright © 2019 Steven M Cohn. All rights reserved.
//************************************************************************************************

#pragma warning disable S3241 // Methods should not return values that are never used

namespace River.OneMoreAddIn.Commands
{
using System.Collections.Generic;
Expand Down Expand Up @@ -55,11 +57,11 @@ public override async Task Execute(params object[] args)
break;

case OneNote.Scope.Sections:
SortSections(sorting, direction, pinNotes);
await SortSections(sorting, direction, pinNotes);
break;

case OneNote.Scope.Notebooks:
SortNotebooks(sorting, direction);
await SortNotebooks(sorting, direction);
break;
}

Expand Down Expand Up @@ -201,7 +203,7 @@ private static int BuildTree(List<PageNode> tree, List<XElement> elements, int l
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// Sections

private void SortSections(
private async Task SortSections(
SortDialog.Sortings sorting, SortDialog.Directions direction, bool pinNotes)
{
#region Notes
Expand All @@ -223,7 +225,7 @@ private void SortSections(
using (var one = new OneNote())
{
// get the current notebook with its sections
var notebook = one.GetNotebook();
var notebook = await one.GetNotebook();

if (notebook == null)
{
Expand Down Expand Up @@ -326,7 +328,7 @@ private void SortSection(XElement parent, XNamespace ns, string key, bool ascend
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// Notebooks

private void SortNotebooks(SortDialog.Sortings sorting, SortDialog.Directions direction)
private async Task SortNotebooks(SortDialog.Sortings sorting, SortDialog.Directions direction)
{
#region Notes
/*
Expand All @@ -338,7 +340,7 @@ private void SortNotebooks(SortDialog.Sortings sorting, SortDialog.Directions di

using (var one = new OneNote())
{
var root = one.GetNotebooks();
var root = await one.GetNotebooks();
var ns = one.GetNamespace(root);

// nickname is display name whereas name is the folder name
Expand Down
2 changes: 1 addition & 1 deletion OneMore/Commands/File/ArchiveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override async Task Execute(params object[] args)
bookScope = scope == "notebook";

hierarchy = bookScope
? one.GetNotebook(one.CurrentNotebookId, OneNote.Scope.Pages)
? await one.GetNotebook(one.CurrentNotebookId, OneNote.Scope.Pages)
: one.GetSection(one.CurrentSectionId);

var ns = one.GetNamespace(hierarchy);
Expand Down
2 changes: 1 addition & 1 deletion OneMore/Commands/File/CopyFolderCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private async Task Callback(string targetId)
}

// source folder will be in current notebook
var notebook = one.GetNotebook(OneNote.Scope.Pages);
var notebook = await one.GetNotebook(OneNote.Scope.Pages);
var ns = one.GetNamespace(notebook);

// use current page to ascend back to closest folder to handle nesting...
Expand Down
5 changes: 4 additions & 1 deletion OneMore/Commands/File/ExportCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private void Export(List<string> pageIDs)
OneNote.ExportFormat format;
string path;
bool withAttachments;
bool useUnderscores;

// dialog...

Expand All @@ -71,6 +72,7 @@ private void Export(List<string> pageIDs)
path = dialog.FolderPath;
format = dialog.Format;
withAttachments = dialog.WithAttachments;
useUnderscores = dialog.UseUnderscores;
}

// prepare...
Expand Down Expand Up @@ -98,7 +100,8 @@ private void Export(List<string> pageIDs)
foreach (var pageID in pageIDs)
{
var page = one.GetPage(pageID, OneNote.PageDetail.BinaryData);
var filename = Path.Combine(path, page.Title.Replace(' ', '_') + ext);
var title = useUnderscores ? page.Title.Replace(' ', '_') : page.Title;
var filename = Path.Combine(path, title + ext);

progress.SetMessage(filename);
progress.Increment();
Expand Down
72 changes: 39 additions & 33 deletions OneMore/Commands/File/ExportDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions OneMore/Commands/File/ExportDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public ExportDialog(int pageCount)
"folderLabel",
"formatLabel",
"formatBox",
"underBox",
"attachmentsBox",
"okButton=word_OK",
"cancelButton=word_Cancel"
Expand All @@ -49,6 +50,9 @@ public ExportDialog(int pageCount)
public bool WithAttachments => attachmentsBox.Enabled && attachmentsBox.Checked;


public bool UseUnderscores => underBox.Checked;


public OneNote.ExportFormat Format
{
get
Expand Down
2 changes: 1 addition & 1 deletion OneMore/Commands/File/ImportCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private async Task PowerPointImporter(string filepath, bool append, bool split)
{
using (var one = new OneNote())
{
var section = one.CreateSection(Path.GetFileNameWithoutExtension(filepath));
var section = await one.CreateSection(Path.GetFileNameWithoutExtension(filepath));
var sectionId = section.Attribute("ID").Value;
var ns = one.GetNamespace(section);

Expand Down
2 changes: 1 addition & 1 deletion OneMore/Commands/File/PluginDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public PluginDialog(Plugin plugin)
public string PageName { set; private get; }


protected async override void OnLoad(EventArgs e)
protected override async void OnLoad(EventArgs e)
{
base.OnLoad(e);

Expand Down
Loading

0 comments on commit c87cad0

Please sign in to comment.