Not able to find direction of my toolwindow using toolwindow.GetDirectionRelativeToWorks.

Docking/MDI for WPF Forum

Posted 9 years ago by Piyush Parsai
Version: 15.1.0620
Avatar

Hi,

I am trying to find out docked direction of my toolwindow using toolwindow.GetDirectionRelativeToWorkspace() method but its returning None.

Below is my sample xaml code:

<DockPanel LastChildFill="True">
        <Button x:Name="GetDirection" Content="Direction" DockPanel.Dock="Top" Click="SnapToDefault_Click" Width="258"></Button>
        <docking:DockSite x:Name="dockSite">
            <docking:SplitContainer x:Name="splitContainer">
                
                <docking:ToolWindowContainer x:Name="toolWindowContainer" docking:DockSite.ControlSize="75,75" >
                    <docking:ToolWindow x:Name="toolWindow1" Title="Test_Tool_Window_1" CanMaximize="False"/>
                    <docking:ToolWindow x:Name="toolWindow2" Title="Test_Tool_Window_2"  CanMaximize="False"/>
                </docking:ToolWindowContainer>
                
            </docking:SplitContainer>
        </docking:DockSite>
    </DockPanel>

I have created and sent you sample in which you can see if we docked the tool window at specific position and click on Direction button it gives us direction as None.

I have searched for this issue and found out that adding <Workspace> may help, but I cannot add this in my application. This will require lots of changes in application.


Please let me know if there is any way to find out Docked Direction of my toolwindow without adding <workspace>.

 

Thanks,
Piyush

[Modified 9 years ago]

Comments (7)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

You are using tool window inner fill mode in this sample, and in that mode, there is no Workspace so the method won't help you.  I don't believe we have any other methods that would give a direction in this non-workspace scenario.  I would suggest that you perhaps examine the bounds of the tool window's parent container (ToolWindow.ParentContainer) relative to the DockSite's bounds, and see which side its midpoint is closest to.


Actipro Software Support

Posted 9 years ago by Piyush Parsai
Avatar

Hi,

Thanks for quick response. I still have below queries:

1) Could you please let me know how to find bounds(x,y coordinates) of ToolWindow.ParentContainer. I have looked into this but not able to found out the bounds. I have tried ToolWindow.ParentContainer.Clip proeprty but in my case its set to null.
Also let me know hot to found bounds of other windows i.e. docksite, toolwindwos.
Also could you please explain me that how to find out mid point of docksite.

2) When I float any toolWindow than its also floating outside the parent container or application. I just want to restrict it to the application and if minimize the application toolWindow should also get minimized.

Please suggest me your inputs on this.

[Modified 9 years ago]

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

1) Something along the lines of this will give you the midpoint of the container in coordinates that are relative to the DockSite:

var container = toolWindow.ParentContainer;
if (container != null) {
	var containerMidPoint = new Point(container.ActualWidth / 2, container.ActualHeight / 2);
	containerMidPoint = container.TranslatePoint(containerMidPoint, container.DockSite);
	// Compare point with DockSite's ActualWidth/ActualHeight to pick a side here
}

2) Please see the "Docking Window Capabilities" topic in the documentation.  That lists all the properties that let you control behaviors.  For instance, you can set DockSite.CanToolWindowsRaft  to false to prevent rafting.


Actipro Software Support

Posted 9 years ago by Piyush Parsai
Avatar

Hi,

I still have following queries:
1) I have used DockSite.CanToolWindowsRaft, but this will restrict floating of docked window. I do not want to restrict floating of docked windows. I want them to float only inside Application. I want floating window to be child of the Application so that it can float inside application but not separately outside application.
2) I am using DockSite.SetControlSizeForState and DockSite.SetControlSize method to set the size of tool windows. But this is not working; after loading tool windows size get changed.
I have tried this for both container and toolWindow:

DockSite.SetControlSizeForState(tempToolWindow.ParentContainer, osize, ActiproSoftware.Windows.Controls.Docking.DockingWindowState.Docked);
DockSite.SetControlSizeForState(tempToolWindow, oSize, ActiproSoftware.Windows.Controls.Docking.DockingWindowState.Docked);

 But the tool windows take size automatically as per docking layout(i.e. if I docked window to left and given height as half of application it is automatically taking full size.).

Please let me know solution for these issues.

Thanks,
Piyush

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

1) Ok, please look at the "Hosted Rafting Windows" topci in the documentation.  That describes a DockSite.UseHostedRaftingWindows property that perhaps you'd want to set to true.

2) The control size only affects the initial width or height depending on which side the window is docked.  For instance, if you dock left, only the width portion of the control size will be used.  The height will fill the available area in that scenario.  That's just how docking windows work in general.


Actipro Software Support

Posted 9 years ago by Piyush Parsai
Avatar

Hi,

Thanks for your response.

I have two queries:
1) As suggested by you I have used DockSite.UseHostedRaftingWindows. After this floating window will become child of application and this is the same functionality I want to achieve.
But with this I have another issue it’s like: Float any tool window and save the layout next time when we load layout toolwindow will be in floating state and will be child of application (desired behavior). But If I try to dock this tool window its throwing object reference set to null exception.
Please correct me If I am doing anything wrong here or if there is any workaround for this.
2) To overcome above condition I have one workaround it’s like: when we load saved layout at that time I intentionally close the floating window and opens it just after main application rendered, in a dispatcher.
This way floating window is taking same position and state as last saved and is child of application and also I am able to dock this .
Please let me know if there are any drawbacks of this approach.

I have noticed that my approch is impacting performance of application. I would like to prefer any available functionlity (solution for issue in #1) so that it may not impact performance. 

[Modified 9 years ago]

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello, when trying your sample in v2015.1 (our latest version) with UseHostedRaftingWindows="True" on the DockSite, we don't see any issues like what you describe.  If you can repro the issue in our 2015.1 version, then please send our support address a new simple sample project that shows the issue so that we can debug it.  In your email, be sure to give exact steps on how to repro the issue.  Thanks!


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.