Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add navigation and zoom functionality to control addin #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/// <summary>
/// ControlAddIn "MarkdownViewer_ANJ."
/// </summary>
namespace ANJ.Tools.Graph;
controladdin MarkdownViewer_ANJ
{
Expand All @@ -12,14 +9,11 @@
StyleSheets = 'src\ControlAddinViewer\Style.css';
VerticalShrink = true;

/// <summary>
/// Ready.
/// </summary>
event Ready();

/// <summary>
/// Draw.
/// </summary>
/// <param name="Markdown">Text.</param>
procedure Draw(Markdown: Text)
}
procedure Draw(Markdown: Text);

Check failure on line 14 in Dependency-Graph/src/ControlAddinViewer/MarkdownViewerANJ.ControlAddin.al

View workflow job for this annotation

GitHub Actions / Build . (Default) / . (Default)

LC0024 Procedure or Trigger declaration should not end with semicolon.

Check failure on line 14 in Dependency-Graph/src/ControlAddinViewer/MarkdownViewerANJ.ControlAddin.al

View workflow job for this annotation

GitHub Actions / Build . (Default) / . (Default)

LC0025 Procedure must be either local, internal or define a documentation comment.

procedure Navigate(Direction: Text);

Check failure on line 16 in Dependency-Graph/src/ControlAddinViewer/MarkdownViewerANJ.ControlAddin.al

View workflow job for this annotation

GitHub Actions / Build . (Default) / . (Default)

LC0024 Procedure or Trigger declaration should not end with semicolon.

Check failure on line 16 in Dependency-Graph/src/ControlAddinViewer/MarkdownViewerANJ.ControlAddin.al

View workflow job for this annotation

GitHub Actions / Build . (Default) / . (Default)

LC0025 Procedure must be either local, internal or define a documentation comment.

procedure Zoom(Level: Integer);

Check failure on line 18 in Dependency-Graph/src/ControlAddinViewer/MarkdownViewerANJ.ControlAddin.al

View workflow job for this annotation

GitHub Actions / Build . (Default) / . (Default)

LC0024 Procedure or Trigger declaration should not end with semicolon.

Check failure on line 18 in Dependency-Graph/src/ControlAddinViewer/MarkdownViewerANJ.ControlAddin.al

View workflow job for this annotation

GitHub Actions / Build . (Default) / . (Default)

LC0025 Procedure must be either local, internal or define a documentation comment.
}
36 changes: 35 additions & 1 deletion Dependency-Graph/src/ControlAddinViewer/Scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,38 @@ function Draw(Markdown) {
catch (e) {
console.log(e);
}
}
}

function Navigate(Direction) {
try {
const container = document.getElementById('controlAddIn');
switch (Direction) {
case 'up':
container.scrollBy(0, -100);
break;
case 'down':
container.scrollBy(0, 100);
break;
case 'left':
container.scrollBy(-100, 0);
break;
case 'right':
container.scrollBy(100, 0);
break;
}
}
catch (e) {
console.log(e);
}
}

function Zoom(Level) {
try {
const container = document.getElementById('controlAddIn');
const currentZoom = parseFloat(container.style.zoom) || 1;
container.style.zoom = currentZoom + Level * 0.1;
}
catch (e) {
console.log(e);
}
}
44 changes: 43 additions & 1 deletion Dependency-Graph/src/ControlAddinViewer/Start.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
HTMLContainer = document.getElementById("controlAddIn");
mermaid.initialize({ startOnLoad: false });
Microsoft.Dynamics.NAV.InvokeExtensibilityMethod("Ready", []);
Microsoft.Dynamics.NAV.InvokeExtensibilityMethod("Ready", []);

document.addEventListener('keydown', function(event) {
switch (event.key) {
case 'ArrowUp':
Navigate('up');
break;
case 'ArrowDown':
Navigate('down');
break;
case 'ArrowLeft':
Navigate('left');
break;
case 'ArrowRight':
Navigate('right');
break;
case '+':
Zoom(1);
break;
case '-':
Zoom(-1);
break;
}
});

document.addEventListener('wheel', function(event) {
if (event.ctrlKey) {
event.preventDefault();
Zoom(event.deltaY < 0 ? 1 : -1);
}
});

document.addEventListener('mousedown', function(event) {
if (event.button === 1) {
document.body.classList.add('zooming');
}
});

document.addEventListener('mouseup', function(event) {
if (event.button === 1) {
document.body.classList.remove('zooming');
}
});
20 changes: 19 additions & 1 deletion Dependency-Graph/src/ControlAddinViewer/Style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,22 @@ iframe {
word-wrap: break-word;
padding-left: 1%;
padding-right: 1;
}
}

.navigation-controls {
position: absolute;
top: 10px;
right: 10px;
z-index: 1000;
}

.zoom-controls {
position: absolute;
top: 50px;
right: 10px;
z-index: 1000;
}

.zooming {
background-color: rgba(0, 0, 0, 0.1);
}
Loading