Bugfix: Must take polymorphic controls into consideration. (#84)

* Bugfix: Must take polymorphic controls into consideration.

* Bugfix: Must save original position of all tagged controls, regardless of the primary drag vertex status.

Before the fix, it was possible to get out of sync with the "IsTagged" status of the primary drag vertex (it was set after the drag start). When that happened, the secondary vertices being dragged, did not have its OriginalX/Y properties updated, resulting in a "jump" from its visual origin to X=0, Y=0.
This commit is contained in:
jorgensigvardsson 2017-05-31 14:14:37 +02:00 коммит произвёл Alexander Smirnov
Родитель c56eca82e2
Коммит 18be069681
1 изменённых файлов: 11 добавлений и 14 удалений

Просмотреть файл

@ -353,12 +353,12 @@ namespace GraphX.Controls
{
//register the event handlers
#if WPF
if (element.GetType() == typeof(VertexControl))
if (element is VertexControl)
{
element.MouseLeftButtonDown += OnVertexDragStarted;
element.PreviewMouseLeftButtonUp += OnVertexDragFinished;
}
else if (element.GetType() == typeof(EdgeControl))
else if (element is EdgeControl)
{
element.MouseLeftButtonDown += OnEdgeDrageStarted;
element.PreviewMouseLeftButtonUp += OnEdgeDragFinished;
@ -372,12 +372,12 @@ namespace GraphX.Controls
{
//unregister the event handlers
#if WPF
if (element.GetType() == typeof(VertexControl))
if (element is VertexControl)
{
element.MouseLeftButtonDown -= OnVertexDragStarted;
element.PreviewMouseLeftButtonUp -= OnVertexDragFinished;
}
else if (element.GetType() == typeof(EdgeControl))
else if (element is EdgeControl)
{
element.MouseLeftButtonDown -= OnEdgeDrageStarted;
element.PreviewMouseLeftButtonUp -= OnEdgeDragFinished;
@ -491,16 +491,13 @@ namespace GraphX.Controls
SetOriginalX(obj, GraphAreaBase.GetFinalX(obj));
SetOriginalY(obj, GraphAreaBase.GetFinalY(obj));
// Save starting position of all tagged elements
if (GetIsTagged(obj))
{
// Save starting position of all other tagged elements
foreach (var item in area.GetAllVertexControls())
if (GetIsTagged(item))
if (!ReferenceEquals(item, obj) && GetIsTagged(item))
{
SetOriginalX(item, GraphAreaBase.GetFinalX(item));
SetOriginalY(item, GraphAreaBase.GetFinalY(item));
}
}
//capture the mouse
#if WPF