Esempio n. 1
0
        private void CreateLeftDockedBars()
        {
            // Dock first two bars side by side and dock third bar next to them...
            Bar bar = new Bar("Bar1");

            bar.Name                  = "leftBar1";
            bar.LayoutType            = eLayoutType.DockContainer; // Dock Container Layout needed for dockable windows
            bar.Stretch               = true;                      // Dockable windows stretch to fill container
            bar.AutoHideAnimationTime = 0;                         // Some controls do not support animation so turn it off
            bar.GrabHandleStyle       = eGrabHandleStyle.Caption;  // Dockable Windows have captions
            bar.CanHide               = true;
            // Create DockContainerItem for the bar. The item should be added before the bar is docked.
            DockContainerItem dockItem = new DockContainerItem("leftDockItem1", "Top Left Dock Container");

            bar.Items.Add(dockItem);
            // Create control that is hosted on dock container
            UserControl1 dockedControl = new UserControl1();

            dockedControl.label1.Text = bar.Name + " - " + dockItem.Text;
            dockedControl.BackColor   = Color.Khaki;
            dockItem.Control          = dockedControl;                       // Specify that control is hosted on the dock container
            dotNetBarManager1.Bars.Add(bar);                                 // DotNetBar needs to be aware of the bar so it can manage it's docking etc.
            dotNetBarManager1.LeftDockSite.GetDocumentUIManager().Dock(bar); //Performs actual docking of the Bar to the specified dock site
            dockItem.Width = 128;                                            // Specify Width of dock container item after it is docked

            // Create second bar and dock it below the first bar but still on the same line
            Bar bar2 = new Bar("Bar2");

            bar2.Name                  = "leftBar2";
            bar2.LayoutType            = eLayoutType.DockContainer; // Dock Container Layout needed for dockable windows
            bar2.AutoHideAnimationTime = 0;                         // Some controls do not support animation so turn it off
            bar2.Stretch               = true;                      // Dockable windows stretch to fill container
            bar2.CanHide               = true;
            bar2.GrabHandleStyle       = eGrabHandleStyle.Caption;  // Dockable Windows have captions
            // Add new Dock Container to the bar, should be done before adding the bar so size can be calculated properly
            dockItem = new DockContainerItem("leftDockItem2", "Bottom Left Dock Container");
            bar2.Items.Add(dockItem);
            // Create control that is hosted on dock container
            dockedControl             = new UserControl1();
            dockedControl.label1.Text = bar.Name + " - " + dockItem.Text;
            dockedControl.BackColor   = Color.Lavender;
            dockItem.Control          = dockedControl;                                               // Specify that control is hosted on the dock container
            dotNetBarManager1.Bars.Add(bar2);                                                        // DotNetBar needs to be aware of the bar so it can manage it's docking etc.
            dotNetBarManager1.LeftDockSite.GetDocumentUIManager().Dock(bar, bar2, eDockSide.Bottom); // Dock new bar2 below the bar that we created previously

            // Create third bar that is docked next to the first and second
            // i.e. on the line 1
            bar                       = new Bar("Bar3");
            bar.Name                  = "leftBar3";
            bar.LayoutType            = eLayoutType.DockContainer; // Dock Container Layout needed for dockable windows
            bar.AutoHideAnimationTime = 0;                         // Some controls do not support animation so turn it off
            bar.Stretch               = true;                      // Dockable windows stretch to fill container
            bar.CanHide               = true;
            bar.GrabHandleStyle       = eGrabHandleStyle.Caption;  // Dockable Windows have captions
            dockItem                  = new DockContainerItem("leftDockItem3", "Left Dock Container line 1");
            bar.Items.Add(dockItem);
            // Create control that is hosted on dock container
            dockedControl             = new UserControl1();
            dockedControl.label1.Text = bar.Name + " - " + dockItem.Text;
            dockedControl.BackColor   = Color.LemonChiffon;
            dockItem.Control          = dockedControl;  // Specify that control is hosted on the dock container
            dotNetBarManager1.Bars.Add(bar);            // DotNetBar needs to be aware of the bar so it can manage it's docking etc.
            dotNetBarManager1.LeftDockSite.GetDocumentUIManager().Dock(bar);

            // Setting the width of the dock site will also scale the bars docked inside,
            // however the size should be large enough to accomodate all bars including the constraints like MinimumSize etc.
            dotNetBarManager1.LeftDockSite.Width = 150;
        }