Skip to content

Commit

Permalink
Add context menu option to open the document with another app
Browse files Browse the repository at this point in the history
  • Loading branch information
Segilmez06 committed Dec 15, 2022
1 parent 72a7e13 commit c35a6d6
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 72 deletions.
63 changes: 0 additions & 63 deletions .github/workflows/release-build.yml

This file was deleted.

7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# ReadDown

[![Debug build](https://github.com/Segilmez06/ReadDown/actions/workflows/debug-build.yml/badge.svg)](https://github.com/Segilmez06/ReadDown/actions/workflows/debug-build.yml)
[![Release build](https://github.com/Segilmez06/ReadDown/actions/workflows/release-build.yml/badge.svg)](https://github.com/Segilmez06/ReadDown/actions/workflows/release-build.yml)
![Visitor Count](https://visitor-badge.glitch.me/badge?page_id=Zyex.ReadDown&left_color=gray&right_color=green&left_text=Visitors)
![Visitor Count](https://visitor-badge.glitch.me/badge?page_id=Zyex.ReadDown&left_color=gray&right_color=lime&left_text=Visitors)

ReadDown is a fluent and easy to use Markdown reader.

It converts Markdown to HMTL via [Markdig](https://github.com/xoofx/markdig) and renders it via [Edge WebView2](https://developer.microsoft.com/en-us/microsoft-edge/webview2/).
ReadDown has a few features which is easy to use:
- Export as HTML file
- Export as PDF document
Also supports exporting to other formats like `.docx`, `.pdf` and `.html`.

## Installation

Expand Down
15 changes: 14 additions & 1 deletion ReadDown/Forms/Viewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private void CoreWebView2_ContextMenuRequested(object? sender, CoreWebView2Conte
OpenItem.CustomItemSelected += delegate (object sender, object EventArgs)
{
System.Windows.Forms.OpenFileDialog openDialog = new();
openDialog.Filter = "Markdown document (*.md;*.markdown)|*.md;*.markdown|All files (*.*)|*.*";
openDialog.Filter = "Markdown document (*.md)|*.md;*.markdown;*.mkd;*.mkdn;*.mdwn;*.mdown;*.markdn;*.markdown;*.mdtxt;*.mdtext|All files (*.*)|*.*";
openDialog.FileName = "";
var result = openDialog.ShowDialog();
if (result == DialogResult.OK)
Expand Down Expand Up @@ -204,6 +204,19 @@ private void CoreWebView2_ContextMenuRequested(object? sender, CoreWebView2Conte
};
InsertNewItem(ContextMenuList, ExportItem);

var editIcon = new MemoryStream();
SvgDocument.FromSvg<SvgDocument>(Resources.open_with).Draw().Invert().Save(editIcon, ImageFormat.Png);
var EditItem = CreateNewItem(Renderer, "View with another app", editIcon);
EditItem.CustomItemSelected += delegate (object sender, object EventArgs)
{
Process p = new();
p.EnableRaisingEvents = false;
p.StartInfo.FileName = "rundll32.exe";
p.StartInfo.Arguments = "shell32,OpenAs_RunDLL " + FilePath;
p.Start();
};
InsertNewItem(ContextMenuList, EditItem);

#if DEBUG
var Seperator = CreateNewItem(Renderer, "", new MemoryStream(), CoreWebView2ContextMenuItemKind.Separator);
InsertNewItem(ContextMenuList, Seperator);
Expand Down
11 changes: 10 additions & 1 deletion ReadDown/Properties/Resources.Designer.cs

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

3 changes: 3 additions & 0 deletions ReadDown/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
<data name="open" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\open.svg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="open_with" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\open_with.svg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="RD_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\RD_Icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down
2 changes: 1 addition & 1 deletion ReadDown/Resources/open.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ReadDown/Resources/open_with.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Todo.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### TODO

- [ ] Add `Open with editor` option to context menu
- [x] Add `Open with` option to context menu

0 comments on commit c35a6d6

Please sign in to comment.