-
Notifications
You must be signed in to change notification settings - Fork 213
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 #43 from zHaytam/develop
Version 1.1.2
- Loading branch information
Showing
15 changed files
with
118 additions
and
27 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
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,28 @@ | ||
@page "/demos/drag-and-drop" | ||
@layout DemoLayout | ||
@inject LayoutData LayoutData | ||
|
||
<div class="row h-100"> | ||
<div class="col-4"> | ||
@* Toolbox *@ | ||
<div class="row h-100 p-4 no-gutters" style="background: #eee;"> | ||
<div class="col-6"> | ||
<div class="text-center" draggable="true" @ondragstart="() => OnDragStart(0)"> | ||
<img class="d-block m-auto" src="_content/SharedDemo/img/DefaultNodeWidget.png" /> | ||
<span>Default Node</span> | ||
</div> | ||
</div> | ||
<div class="col-6"> | ||
<div class="text-center" draggable="true" @ondragstart="() => OnDragStart(1)"> | ||
<img class="d-block m-auto" src="_content/SharedDemo/img/BotAnswerNodeWidget.png" /> | ||
<span>Bot Answer Node</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-8" ondragover="event.preventDefault();" @ondragover:preventDefault @ondrop="OnDrop"> | ||
<CascadingValue Name="DiagramManager" Value="_diagramManager"> | ||
<DiagramCanvas></DiagramCanvas> | ||
</CascadingValue> | ||
</div> | ||
</div> |
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,42 @@ | ||
using Blazor.Diagrams.Core; | ||
using Blazor.Diagrams.Core.Models; | ||
using Microsoft.AspNetCore.Components.Web; | ||
|
||
namespace SharedDemo.Demos | ||
{ | ||
public partial class DragAndDrop | ||
{ | ||
private readonly DiagramManager _diagramManager = new DiagramManager(); | ||
private int? _draggedType; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
base.OnInitialized(); | ||
|
||
LayoutData.Title = "Drag & Drop"; | ||
LayoutData.Info = "A very simple drag & drop implementation using the HTML5 events."; | ||
LayoutData.DataChanged(); | ||
|
||
_diagramManager.RegisterModelComponent<BotAnswerNode, BotAnswerWidget>(); | ||
} | ||
|
||
private void OnDragStart(int key) | ||
{ | ||
// Can also use transferData, but this is probably "faster" | ||
_draggedType = key; | ||
} | ||
|
||
private void OnDrop(DragEventArgs e) | ||
{ | ||
if (_draggedType == null) // Unkown item | ||
return; | ||
|
||
var position = _diagramManager.GetRelativePoint(e.ClientX, e.ClientY); | ||
var node = _draggedType == 0 ? new NodeModel(position) : new BotAnswerNode(position); | ||
node.AddPort(PortAlignment.Top); | ||
node.AddPort(PortAlignment.Bottom); | ||
_diagramManager.AddNode(node); | ||
_draggedType = null; | ||
} | ||
} | ||
} |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.