I have recently been asked by several different users of Krypton about how to start a drag operation from an external source and allow it to be dragged into the docking area. For example, you might have a TreeView with nodes and when the user drags one of those nodes you want to automatically create a new page and have it draggable into the docking area of the application.
This seems like a very reasonable requirement but it was not really possible to get it working fully and correctly. With the introduction of two new events this is now possible:-
It has always been possible to start the drag operation in the scenario described above, you just need to call the KryptonDockingManager.DoDragDrop and pass in your newly created KryptonPage instance. Unfortunately there was no way to get feedback on when the drag operation was finished and if it succeeded or failed. Without this feedback it is hard, if not impossible, to correctly handle the operation. So now the DoDragDockEnd and DoDragDockQuit allow you to get the result of the dragging operation.
To make it easier to see how to actually implement this there is a new sample called External Drag To Docking where you can see the full source code. In particular the code inside the TreeView shows how to start the drag operation and also how to clean up afterwards using the new events.
Here you can see the new sample with the mouse about to drag the Document node of the tree…
Once the drag starts you get a new docking page titled Document 3 and it has been created as a floating window. The user then drag this to any part of the docking system or just leave it as a floating window if preferred.
AutoHidden Window States
Another common request has been an event to indicate when an AutoHidden window has been scrolled out into view so that additional actions can then be taken, such as updating the contents of the page. To allow this the following new event has been added:-
The event provides a parameter that indicates the AutoHidden page has changed to one of these four possible states:-
The events would usually occur in the same order that they are listed above. But note that sometimes the SlidingOut and SlidingIn do not occur because an action has caused the page to shift directly from Hidden to Showing or vice-versa. So I recommend you always hook and process the Hidden and Showing events.