Use of the open source component dockpanel suite

Source: Internet
Author: User
ArticleDirectory
    • 1. Multi-Document Interface (MDI)
    • 2. dockstate
    • 3. dockpane and dockalignment
    • 4. dockarea
    • 5. documentstyle
    • 6. Miscellaneous

The previous article mentioned the dockpanel suite, which can be docked. Next I will briefly introduce how to use this component.

1. Multi-Document Interface (MDI)

The main form of dockpanel suite is similar to the parent form of the MDI application developed in winform. The parent form contains all the dock forms, and the dock form is similar to the child form in MDI.

The red area is a panel inherited from weifenluo. winformsui. Docking. dockpanel. All child forms must be docked, suspended, and hidden in the panel. Because it is an MDI-based application, the ismdicontainer attribute of the parent form must be set to true. In addition, child forms are inherited from weifenluo. winformsui. Docking. dockcontent so that they can be docked in the parent form.

2. dockstate

Docksate in dockpanel suite is a very important attribute:

Public Enum dockstate {unknown = 0, /// <summary> /// floating // </Summary> float = 1, /// <summary> /// automatically hide the top form /// </Summary> docktopautohide = 2, /// <summary> /// hide the left-Stop form automatically /// </Summary> dockleftautohide = 3, /// <summary> /// automatically hide the docking form at the bottom /// </Summary> dockbottomautohide = 4, /// <summary> /// automatically hide the right-docked form /// </Summary> dockrightautohide = 5, /// <summary> /// doc //// </Summary> document = 6, /// <summary> /// dock at the top /// </Summary> docktop = 7, /// <summary> /// left stop /// </Summary> dockleft = 8, /// <summary> /// dock at the bottom /// </Summary> dockbottom = 9, /// <summary> /// right stop /// </Summary> dockright = 10, hidden = 11}

CodeThe comment in indicates the position of the child form to dock the parent form. In the child form inherited from dockcontent, The showhint attribute can be used to initialize the orientation of the child form when it is displayed.

The test results are as follows:

Dockpanel suite provides a corresponding dockstatechanged to monitor the dockstate change of the child form.

3. dockpane and dockalignment

You can also choose dockpane to dock the dock form. The dock panel is a built-in Panel (PANE) in the dock form, which is a usercontrol. The method is as follows:

 
Public void show (dockpane previouspane, dockalignment alignment, double proportion)

The dockalignment Parameter Enumeration is as follows:

Public Enum dockalignment {// <summary> /// relative to the left of the dock panel /// </Summary> left, /// <summary> /// relative to the right of the dock panel /// </Summary> right, /// <summary> /// relative to the top of the dock panel /// </Summary> top, /// <summary> /// relative to the bottom of the dock panel /// </Summary> bottom}

The proportion parameter refers to the percentage of the position occupied by the relatively docked panel:

In the figure, the red area is the built-in panel area of form0, Which is 0.4 away from the docked panel.

4. dockarea

There is a dock area in the dock form. Its attribute is dockarea, which is similar to dockstate and is of the enumeration type:

[Flags] [serializable] [Editor (typeof (dockareaseditor), typeof (system. drawing. design. uitypeeditor)] public Enum dockareas {float = 1, dockleft = 2, dockright = 4, docktop = 8, dockbottom = 16, document = 32}

Generally, you can set the dock area during the initialization of the dock form to limit the location of the drag area. It should be noted that when the dockstate is dockleft | dockright | docktop | dockbottom | float | document, dockleft | dockright | docktop | dockbottom | float | the document is invalid. For example, if the dockstate is dockright, The dockright setting area in dockareas is invalid, and an exception is thrown. An extension is made in my test code to avoid unnecessary exceptions (the exception information is: invalid value: the value of dockareas conflicts with current dockstate ):

Public static bool isdockareavalid (this dockcontent dock, dockareas areas) {bool valid = true; Switch (areas) {Case dockareas. dockbottom: Valid = (dock. dockstate! = Dockstate. dockbottom); break; Case dockareas. dockleft: Valid = (dock. dockstate! = Dockstate. dockleft); break; Case dockareas. dockright: Valid = (dock. dockstate! = Dockstate. dockright); break; Case dockareas. docktop: Valid = (dock. dockstate! = Dockstate. docktop); break; Case dockareas. Document: Valid = (dock. dockstate! = Dockstate. Document); break; Case dockareas. Float: Valid = (dock. dockstate! = Dockstate. Float); break; default: break;} return valid ;}
5. documentstyle

You can set the dockpanel container documentstyle to change the style of the dock form. The documentstyle Enumeration type is as follows:

 
Public Enum documentstyle {dockingmdi, dockingwindow, dockingsdi, systemmdi ,}

The default value is dockingmdi. I personally think the style of these forms is almost the same.

6. Miscellaneous

In dockpanel suiteSource codeSome common functions are as follows:

    • Disable activated dock forms, and close all docked forms
    • Storage and loading of the dock object layout (code and XML); you can use the code to build the entire application in advance.ProgramAnd save the layout to XML when the application exits. Then, the XML is used as the standard
      Interface layout File
    • Dock form skin replacement
    • In addition, if you need to set a shortcut menu for a non-document dock form, you can set the attribute tabpagecontextmenustrip in the dockcontent class to its own contextmenu,

The effect is as follows:


Demo source code download: dockablewindowsample.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.