Skip to content

Commit

Permalink
Add 'HighlightOnly' click action and fix incorrect command name.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas404x committed Feb 5, 2024
1 parent 06beaa7 commit 2812930
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
namespace MdXaml.LinkActions
{
// set `public` access level for #29.
public class DiaplayCommand : ICommand
public class DisplayCommand : ICommand
{
private MarkdownScrollViewer Owner;
private bool OpenBrowserWithAbsolutePath;
private ICommand OpenCommand;

public DiaplayCommand(MarkdownScrollViewer owner, bool openBrowserWithAbsolutePath, bool safety)
public DisplayCommand(MarkdownScrollViewer owner, bool openBrowserWithAbsolutePath, bool safety)
{
Owner = owner;
OpenBrowserWithAbsolutePath = openBrowserWithAbsolutePath;
Expand Down
38 changes: 38 additions & 0 deletions MdXaml/LinkActions/HighlightOnlyCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Windows.Input;

namespace MdXaml.LinkActions
{
public class HighlightOnlyCommand : ICommand
{
public event EventHandler? CanExecuteChanged;

private bool _isExecutable = true;
public bool IsExecutable
{
get => _isExecutable;
set
{
if (_isExecutable != value)
{
_isExecutable = value;
CanExecuteChanged?.Invoke(this, new EventArgs());
}
}
}

public bool CanExecute(object? parameter) => _isExecutable;

public void Execute(object? parameter)
{
//var path = parameter?.ToString();
//if (path is null) throw new ArgumentNullException(nameof(parameter));

//Process.Start(new ProcessStartInfo(path)
//{
// UseShellExecute = true,
// Verb = "open"
//});
}
}
}
11 changes: 8 additions & 3 deletions MdXaml/MarkdownScrollViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,19 +443,23 @@ private void UpdateClickAction()
break;

case ClickAction.DisplayWithRelativePath:
command = new DiaplayCommand(this, true, false);
command = new DisplayCommand(this, true, false);
break;

case ClickAction.DisplayAll:
command = new DiaplayCommand(this, false, false);
command = new DisplayCommand(this, false, false);
break;

case ClickAction.SafetyOpenBrowser:
command = new SafetyOpenCommand();
break;

case ClickAction.SafetyDisplayWithRelativePath:
command = new DiaplayCommand(this, true, true);
command = new DisplayCommand(this, true, true);
break;

case ClickAction.HighlightOnly:
command = new HighlightOnlyCommand();
break;

default:
Expand Down Expand Up @@ -641,6 +645,7 @@ public enum ClickAction
DisplayAll,
SafetyOpenBrowser,
SafetyDisplayWithRelativePath,
HighlightOnly,
}

public enum SyntaxVersion
Expand Down

0 comments on commit 2812930

Please sign in to comment.