This is a migrated thread and some comments may be shown as answers.

Interaction with the FloatingParent field during a DockStateChanged

2 Answers 65 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Gabriele Svelto
Top achievements
Rank 1
Gabriele Svelto asked on 09 Feb 2010, 05:30 PM
 Hello,
I have hooked an event handler to the DockStateChanged event in order to intercept the tool windows that were being detached from the dock. Once I find a tool window whose DockState has turned to Floating I adjust its size and change the border style so that the user cannot resize it anymore while it is floating. However I encountered a small problem with this approach: if I detach the tool window by clicking its tab and dragging it out of the tab strip the FloatingParent field of the DockWindow provided in the event arguments is properly set and I can alter it. However if I double-click on the tab or use the context menu to make the window floating the FloatingParent field is set to null. Curiously this only happens the first time I undock the window this way, if I dock the window again and then undock it FloatingPanel is not null anymore (the same is true if I undock the window by dragging it out of the tab strip). Is this an intended behavior or a bug? Here's my event handler code (which throws a NullReferenceException when FloatingParent is null):

void event_DockStateChanged(object sender, DockWindowEventArgs e) 
    if (e.DockWindow.DockState == DockState.Floating) 
    { 
        // Resize a tool window to fit its contents and make it fixed-size. 
        e.DockWindow.FloatingParent.ClientSize = e.DockWindow.GetPreferredSize(Size.Empty); 
        e.DockWindow.FloatingParent.FormBorderStyle = FormBorderStyle.FixedToolWindow; 
    } 

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi
Telerik team
answered on 12 Feb 2010, 07:55 AM
Hi Gabriele,

Thank you for contacting us and for the detailed description of the problem you experience.

Due to the transaction-based mechanism in RadDock TooWindow's caption double click will trigger the following events:

- RedockTransaction - if there is a previous floating state for this window, it will be restored. That is why the second time everything works just fine - such a state already exists
- When such a redock state does not exist, RadDock will take the default action, which in this case is to register another FloatTransaction.

What I can see as a wrong behavior here is that the first transaction is changing the state of the window while it is still docked on RadDock. In fact it is the second transaction that does the actual floating. We will revisit this behavior and implement it properly either for Q1 2010 or for some of our next major releases (including service packs).

For now you can hook the TransactionCommitted event of RadDock and examine the FloatingParent member of all AssociatedWindows:

void radDock1_TransactionCommitted(object sender, RadDockTransactionEventArgs e)
{
    foreach (DockWindow window in e.Transaction.AssociatedWindows)
    {
        FloatingWindow floatingWindow = window.FloatingParent;
        if (floatingWindow != null)
        {
            floatingWindow.ClientSize = new Size(200, 200);
            floatingWindow.FormBorderStyle = FormBorderStyle.FixedToolWindow;
        }
    }
}

I would like to thank you for your time and your feedback. Do not hesitate to contact us if you have other questions.


All the best,
Georgi
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Gabriele Svelto
Top achievements
Rank 1
answered on 12 Feb 2010, 11:25 AM
Thank you for your reply, using the TransactionCommited event as you suggested worked very well and fixed my problem.
Tags
Dock
Asked by
Gabriele Svelto
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Gabriele Svelto
Top achievements
Rank 1
Share this question
or