Weifenluo dock kit: floating windows using their design size?

How can I make floating windows use my design size (rather than the default Dock Panel Suite size) with the Wifenluo Dock Panel set?

Hint: I tried the offer from the Dock Panel Suite forums on SF.net, but this does not work.

+3
source share
4 answers

This worked for me:

var topLeft = dockPanel1.Location;
topLeft.X += (dockPanel1.Size.Width / 2 - newForm.Size.Width / 2);
topLeft.Y += (dockPanel1.Size.Height / 2 - newForm.Size.Height / 2);
newForm.Show(dockPanel1, new Rectangle(topLeft, newForm.Size));
+1
source

when CForm is obtained from DockContent, I have a method inside my MDIContainerWindow that looks like this

 public void ShowForm(CForm pForm)
    {
        pForm.MdiParent = this;

        Size lS = pForm.Size;
        dockPanel.DefaultFloatWindowSize = lS;

        pForm.Show(dockPanel);
        pForm.VisibleState = DockState.Float;

    }
+3
source

, , , .

, , , . (, )

I decided it differently. I created a base class that inherits from DockContent that all my document windows inherit. Then I created another overload for the Show method that handles this (I used the source code of DockPanelSuite to create this method).

public void Show(DockPanel dockPanel, DockState dockState, Rectangle floatWindowBounds)
{
    Show(dockPanel, dockState); //shows the panel like normal

    //now for the part to initialize the float pane and size
    if (DockHandler.FloatPane == null)
    {
        DockHandler.FloatPane = dockPanel.DockPaneFactory.CreateDockPane(this, DockState.Float, false);
        DockHandler.FloatPane.FloatWindow.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
    }
    DockHandler.FloatPane.FloatWindow.Bounds = floatWindowBounds;
}
+3
source

This works for me (in VB):

Dim MyForm As New MyForm
MyForm.Show(DockPanel, New Rectangle(MyForm.Location, MyForm.Size))
MyForm.DockState = DockState.DockRight
+1
source

Source: https://habr.com/ru/post/1760089/


All Articles