Skip to content

Commit

Permalink
Merge pull request #87 from lucas404x/feature/highlight-only-action
Browse files Browse the repository at this point in the history
Add 'HighlightOnly' ClickAction and fix incorrect command name.
  • Loading branch information
whistyun authored Feb 6, 2024
2 parents 06beaa7 + 39193d9 commit 54d17c3
Show file tree
Hide file tree
Showing 3 changed files with 39 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
28 changes: 28 additions & 0 deletions MdXaml/LinkActions/HighlightOnlyCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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) {}
}
}
12 changes: 9 additions & 3 deletions MdXaml/MarkdownScrollViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,21 +443,26 @@ 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:
Engine.HyperlinkCommand = new HighlightOnlyCommand();
Engine.OnHyperLinkClicked = _onHyperLinkClicked;
return;

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

public enum SyntaxVersion
Expand Down

0 comments on commit 54d17c3

Please sign in to comment.