Hi
I am creating a similar diagram and while dropping the link from one node to other I was showing a message box for confirmation and I add links from a pallet
while adding links I am not getting issue if I add from pallet but if I am relinking the existing link to other node during message box AbortTransation is happening rather than “moveselection” transaction.
Are you overriding both methods? That’s unusual. Also, are you calling the base method in both overrides? What are you doing in those overrides? It is unlikely that you need to override DoDrop, and I am guessing that in doing so you have broken the DraggingTool’s transaction.
Yes I am overriding both the methods and I am calling the base methods in both overrides
In both overrides I have written some validations and displaying a confirmation MessageBox
If overridden has broken the transaction the dragging link from pallet should also broke the transaction which isn’t happening.
Is there any difference between dragging a link from link pallet and re-linking the connected link to other node?
I tried not overriding DraggingTool.DoDrop and I am displaying MessageBox in DropOnto before displaying the MessageBox, ChangeLinkFromPort transactions are being called followed by RolledbackTransaction
To be specific, the DraggingTool code works fine while “AddingLink” but it rollbacks in “MoveSelection”. We do have some Rollback transactions but none of them gets called explicitly in this scenario.
We are not setting TransactionResult at all.
DropOnto() - We get the DraggedLink and check either FromData or ToData for a certain property. If it is set to some value, we show a message box and ask the user if he would like to continue, if he selects Yes, we go ahead and perform our operation, if not we are calling DoCancel() and RollbackTransaction().
As and when we call the MessageBox.Show() - the transaction is rolled back.
Model Changed - We are storing the custom data to the database for CommittedTransactions.
In DropOnto() - DoCancel() does cancel the Dragging Tool but UI doesn’t get refreshed ? Any idea ?
This again works fine in “AddingLink” but not in “MoveSelection”
So, is it mandatory to assign values to TransactionResult for every transaction of ours ??
Even at that point where we show the dialog, if we skip that code execution, it works fine but we need that Message Box to be shown.
When calling DoCancel() in DropOnto() the diagram doesn’t refresh.
Lets say I have moved my Link from Terminal A to Terminal B and in DraggingTool, I have called DoCanel(), the link shows connected to Terminal B rather than Terminal A. (Note: This works fine when I am adding a link from Palette control which triggers AddingLink)
Yes, it is mandatory to set TransactionResult to a non-null value if you want the transaction to commit instead of to rollback. However you are callling the base method of DoDrop, or you are not overriding that method at all, which should result in setting TransactionResult in the normal behavior.
When I try calling MessageBox.Show in an override of DropOnto, it always works well, completing the move as expected:
We are calling the base.DropOnto(pt) method. That’s the first line in our override as well. Is there any way to know what triggered the Rollback Transaction ???
In the mean time, I will try setting the TransactionResult and see if that works,
The implementation of DraggingToolDoDrop first sets TransactionResult, then calls DropOnto, then raises a Diagram event, and finally calls StopTransaction (which looks at TransactionResult to decide whether to commit or rollback).
The built-in implementation of DropOnto does not set TransactionResult.
For debugging I suppose you could override StopTransaction to check the value of DiagramTool.TransactionResult before calling the base method.