-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from whistyun/dev
expose link action command.
- Loading branch information
Showing
4 changed files
with
88 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ on: | |
jobs: | ||
build: | ||
|
||
runs-on: windows-latest | ||
runs-on: windows-2019 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
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,53 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Windows.Input; | ||
|
||
#if MIG_FREE | ||
using Markdown.Xaml; | ||
|
||
namespace Markdown.Xaml.LinkActions | ||
#else | ||
using MdXaml; | ||
|
||
namespace MdXaml.LinkActions | ||
#endif | ||
{ | ||
public class DiaplayCommand : ICommand | ||
{ | ||
private MarkdownScrollViewer Owner; | ||
private bool OpenBrowserWithAbsolutePath; | ||
|
||
public DiaplayCommand(MarkdownScrollViewer owner, bool openBrowserWithAbsolutePath) | ||
{ | ||
Owner = owner; | ||
OpenBrowserWithAbsolutePath = openBrowserWithAbsolutePath; | ||
} | ||
|
||
public event EventHandler CanExecuteChanged; | ||
|
||
public bool CanExecute(object parameter) => true; | ||
|
||
public void Execute(object parameter) | ||
{ | ||
var path = parameter.ToString(); | ||
var isAbs = Uri.IsWellFormedUriString(path, UriKind.Absolute); | ||
|
||
if (OpenBrowserWithAbsolutePath & isAbs) | ||
{ | ||
Process.Start(new ProcessStartInfo(path) | ||
{ | ||
UseShellExecute = true, | ||
Verb = "open" | ||
}); | ||
} | ||
else if (isAbs) | ||
{ | ||
Owner.Open(new Uri(path), true); | ||
} | ||
else | ||
{ | ||
Owner.Open(new Uri(path, UriKind.Relative), true); | ||
} | ||
} | ||
} | ||
} |
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,29 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Windows.Input; | ||
|
||
#if MIG_FREE | ||
namespace Markdown.Xaml.LinkActions | ||
#else | ||
namespace MdXaml.LinkActions | ||
#endif | ||
{ | ||
public class OpenCommand : ICommand | ||
{ | ||
public event EventHandler CanExecuteChanged; | ||
|
||
public bool CanExecute(object parameter) => true; | ||
|
||
public void Execute(object parameter) | ||
{ | ||
var path = parameter.ToString(); | ||
var isAbs = Uri.IsWellFormedUriString(path, UriKind.Absolute); | ||
|
||
Process.Start(new ProcessStartInfo(path) | ||
{ | ||
UseShellExecute = true, | ||
Verb = "open" | ||
}); | ||
} | ||
} | ||
} |
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