We’re revamping our winforms user interface to use the Weifen Luo DockPanel Suite and since our old UI didn’t have tabs, we would like to show a ballon tooltip when a new window is docked to the document area, informing users that they may rip-out the document and float it wherever they would like.
I figure to do this I need to be able to programatically determine the location of a docked window’s tab. Our DockPanel’s DocumentStyle is set to DockingWindow, so tabs are always shown for any windows docked into the ‘document’ area.
Any ideas?
From your description it’s unclear if you want to precisely position the bubble over the newly created tab, or if you are fine with it appearing over the tabstrip, at a fixed x-axis location, but positioned correctly based on the y-axis position of the strip (this is the simpler of the two approaches).
So I will provide a solution for the easier scenario, and options for the more complex scenario.
First the easy solution. When the tabs are on top, the Bounds.Top and ClientRectangle.Top values are not the same. When the tabs are on the bottom they are. We can use this information along with the Bounds.Height and Bounds.Top to compute the proper y-axis location.
Below is some sample code that does just this, albeit Naiive. (e.g. It doesn’t handle a doc immediately after a create different than if it happened due to user dragging a window, this is left as an exercise for the reader.)
When setting up DockContent, register the event:
When processing the event:
If you want the fancier approach things will not be as easy. The options I’ve come up with
for you are below:
1) Alter the base library code to make the DockPaneStripBase.Tab class public and expose the tabs rectangle.
2) Implement your own custom DockPaneStrip as illustrated in the DockSample application code.
3) Examine the code for options 1 and/or 2 and devise a scheme that allows you to compute the location to place the tooltips.
FYI, for others reading this who wish to understand the amount of effort involved in the fancier approach.
The source for both WeifenLuo DockPanel and the DockSample app may be obtained from:
http://sourceforge.net/projects/dockpanelsuite/files/DockPanel%20Suite/2.5.0%20RC1/
It’s the package name ending in _Src.