Skip to content

Commit dc0b66f

Browse files
committed
Add create page shortcut
#20
1 parent 9e1273c commit dc0b66f

File tree

4 files changed

+31
-29
lines changed

4 files changed

+31
-29
lines changed

Changelog.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1-
### Unreleased
2-
3-
- [x] Add Icon Themes ( change the smelly OneNoteItemIcons class)
4-
- This involves doing up the icons.GetIcon method.
5-
- Needs a setting for icons
6-
- Colored Icons takes precedence over the light and dark icons.
7-
- will need to check powerytoys for getting the imageSource/Bitmap source thing.
8-
- [x] Fix clearing cached icons button
9-
- [x] Implement PluginTheme setting
10-
- [ ] Maybe use AsParallel for getting recent items [link](https://devblogs.microsoft.com/pfxteam/plinq-ordering/)
11-
- [ ] Make static icon class non static icon provider
12-
- [ ] refactor settings
13-
- [ ] Add stuff to new page with title and discription see iseue.
1+
### 2.1.0 - 2024-6-14
142
#### Added
153
- New and improved icons.
16-
- New setting for plugin theme: system, light, dark and color.
4+
- New preview panel for creating pages (Closes [#20](https://github.com/Odotocodot/Flow.Launcher.Plugin.OneNote/issues/20))
5+
- New setting for icon theme: system, light, dark and color.
176

187
#### Changed
198
- Refactored icon generation.
9+
- Refactored settings view.
2010

2111
#### Removed
2212

2313

2414

15+
2516
<!-- omit from toc -->
2617
### 2.0.0 - 2023-10-05
2718

Flow.Launcher.Plugin.OneNote/UI/ViewModels/NewOneNotePageViewModel.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Windows.Input;
3+
using Flow.Launcher.Plugin.OneNote.Icons;
34
using Odotocodot.OneNote.Linq;
45

56
namespace Flow.Launcher.Plugin.OneNote.UI.ViewModels
@@ -29,10 +30,17 @@ private void CreatePage(bool openImmediately)
2930
pageContentXml = pageContentXml.Insert(pageContentXml.IndexOf("</one:Page>", StringComparison.Ordinal), xmlWrap);
3031
OneNoteApplication.UpdatePageContent(pageContentXml);
3132
Main.ForceReQuery();
32-
if (!openImmediately)
33-
return;
34-
page.OpenInOneNote();
35-
context.API.HideMainWindow();
33+
if (openImmediately)
34+
{
35+
page.OpenInOneNote();
36+
context.API.HideMainWindow();
37+
}
38+
else
39+
{
40+
context.API.ShowMsg("Page Created in OneNote",
41+
$"Title: {PageTitle}",
42+
$"{context.CurrentPluginMetadata.PluginDirectory}/{IconProvider.Logo}");
43+
}
3644
}
3745
public string PageTitle
3846
{

Flow.Launcher.Plugin.OneNote/UI/Views/NewOneNotePagePreviewPanel.xaml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
</ResourceDictionary.MergedDictionaries>
1919
</ResourceDictionary>
2020
</UserControl.Resources>
21+
<UserControl.InputBindings>
22+
<KeyBinding Command="{Binding CreateCommand}" Gesture="CTRL+S" />
23+
</UserControl.InputBindings>
2124
<DockPanel Margin="10,5,5,5" LastChildFill="True">
2225
<DockPanel>
2326
<Grid
@@ -44,10 +47,10 @@
4447
<RowDefinition Height="Auto" />
4548
</Grid.RowDefinitions>
4649
<TextBox
47-
Grid.Row="0"
4850
x:Name="TextBoxPageTitle"
51+
Grid.Row="0"
4952
ui:ControlHelper.PlaceholderText="Page Title"
50-
Text="{Binding PageTitle}" />
53+
Text="{Binding PageTitle, UpdateSourceTrigger=PropertyChanged}" />
5154
<TextBox
5255
Grid.Row="2"
5356
ui:ControlHelper.PlaceholderText="Page Content"
@@ -56,8 +59,8 @@
5659
AcceptsReturn="True"
5760
HorizontalScrollBarVisibility="Auto"
5861
MinLines="3"
59-
Text="{Binding PageContent}"
60-
TextWrapping="NoWrap"
62+
Text="{Binding PageContent, UpdateSourceTrigger=PropertyChanged}"
63+
TextWrapping="Wrap"
6164
VerticalScrollBarVisibility="Auto" />
6265
<WrapPanel
6366
Grid.Row="4"
@@ -67,17 +70,17 @@
6770
Width="70"
6871
Height="{Binding ElementName=ButtonCreateAndOpen, Path=ActualHeight}"
6972
Margin="4,0,25,0"
70-
ToolTip="Creates a page in OneNote"
7173
Command="{Binding CreateCommand}"
7274
Content="Create"
73-
Style="{DynamicResource SettingButton}" />
75+
Style="{DynamicResource SettingButton}"
76+
ToolTip="Creates a page in OneNote (CTRL+S)" />
7477
<Button
7578
x:Name="ButtonCreateAndOpen"
7679
Width="70"
7780
Margin="25,0,4,0"
78-
ToolTip="Creates a page in OneNote and opens it"
7981
Command="{Binding CreateAndOpenCommand}"
80-
Style="{DynamicResource SettingButton}">
82+
Style="{DynamicResource SettingButton}"
83+
ToolTip="Creates a page in OneNote and opens it">
8184
<TextBlock TextAlignment="Center">
8285
Create<LineBreak />
8386
&amp; Open</TextBlock>

Flow.Launcher.Plugin.OneNote/UI/Views/NewOneNotePagePreviewPanel.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public partial class NewOneNotePagePreviewPanel : UserControl
1010
{
1111
public NewOneNotePagePreviewPanel(PluginInitContext context, OneNoteSection section, string pageTitle)
1212
{
13-
InitializeComponent();
1413
DataContext = new NewOneNotePageViewModel(context, section, pageTitle);
14+
InitializeComponent();
1515
}
1616
private void NewOneNotePagePreviewPanel_OnLoaded(object sender, RoutedEventArgs e)
1717
{
@@ -25,12 +25,12 @@ private void OnKeyDown(object sender, KeyEventArgs e)
2525

2626
if (e.Source is not (TextBox or Button))
2727
return;
28-
28+
2929
var focusNavigationDirection = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)
3030
? FocusNavigationDirection.Previous
3131
: FocusNavigationDirection.Next;
3232
((UIElement)Keyboard.FocusedElement)?.MoveFocus(new TraversalRequest(focusNavigationDirection));
33-
33+
3434
e.Handled = true;
3535
}
3636
}

0 commit comments

Comments
 (0)