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

Added the possibility to provide custom controls in Blazor.Dagre #114

Merged
merged 1 commit into from
Sep 10, 2024
Merged
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
63 changes: 48 additions & 15 deletions src/Neuroglia.Blazor.Dagre/DagreGraph.razor
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,48 @@
{
@ExtraControls
}
<button class="btn" type="button" @onclick="CenterAsync" title="center graph">
<svg>
<use href="#center-target" />
</svg>
</button>
<button class="btn" type="button" @onclick="ZoomToFitAsync" title="zoom to fit">
<svg>
<use href="#fit" />
</svg>
</button>
<button class="btn" type="button" @onclick="SaveAsPngAsync" title="save as png">
<svg>
<use href="#save" />
</svg>
</button>
@if (CenterControl != null)
{
<CascadingValue Value="CenterAsync" Name="CenterAsync">
@CenterControl
</CascadingValue>
}
else
{
<button class="btn" type="button" @onclick="CenterAsync" title="Center graph">
<svg>
<use href="#center-target" />
</svg>
</button>
}
@if (ZoomToFitControl != null)
{
<CascadingValue Value="ZoomToFitAsync" Name="ZoomToFitAsync">
@ZoomToFitControl
</CascadingValue>
}
else
{
<button class="btn" type="button" @onclick="ZoomToFitAsync" title="Zoom to fit">
<svg>
<use href="#fit" />
</svg>
</button>
}
@if (SaveAsPngControl != null)
{
<CascadingValue Value="SaveAsPngAsync" Name="SaveAsPngAsync">
@SaveAsPngControl
</CascadingValue>
}
else
{
<button class="btn" type="button" @onclick="SaveAsPngAsync" title="Save as png">
<svg>
<use href="#save" />
</svg>
</button>
}
<!--<button class="btn" type="button" @onclick="ToggleOrientationAsync" title="toggle orientation">
<svg>
<use href="#toggle-orientation" />
Expand Down Expand Up @@ -138,6 +165,12 @@

[Parameter] public EventCallback<GraphEventArgs<WheelEventArgs>> OnWheel { get; set; }

[Parameter] public RenderFragment? CenterControl { get; set; }

[Parameter] public RenderFragment? ZoomToFitControl { get; set; }

[Parameter] public RenderFragment? SaveAsPngControl { get; set; }

[Parameter] public RenderFragment? ExtraControls { get; set; }

ElementReference graphReference;
Expand Down
Loading