CN117435271A - WinForm control dynamic loading method, device, equipment and medium - Google Patents

WinForm control dynamic loading method, device, equipment and medium Download PDF

Info

Publication number
CN117435271A
CN117435271A CN202311440963.9A CN202311440963A CN117435271A CN 117435271 A CN117435271 A CN 117435271A CN 202311440963 A CN202311440963 A CN 202311440963A CN 117435271 A CN117435271 A CN 117435271A
Authority
CN
China
Prior art keywords
control
child
controls
father
real
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311440963.9A
Other languages
Chinese (zh)
Inventor
张莉
韩志强
马文琦
郭晓晶
秦高强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CRSC Xian Rail Transit Industry Co Ltd
Xian Railway Signal Co Ltd
Original Assignee
CRSC Xian Rail Transit Industry Co Ltd
Xian Railway Signal Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CRSC Xian Rail Transit Industry Co Ltd, Xian Railway Signal Co Ltd filed Critical CRSC Xian Rail Transit Industry Co Ltd
Priority to CN202311440963.9A priority Critical patent/CN117435271A/en
Publication of CN117435271A publication Critical patent/CN117435271A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention discloses a dynamic loading method, a device, equipment and a medium for WinForm control, and relates to the technical field of computers. Basic typesetting information of a user interface is acquired first, and then a parent control of the bottom layer in the user interface is designed. When the user interface is actually applied, the number of the sub-controls actually contained in each parent control can be determined according to the number of the interaction requirements determined before the user interface is applied, so that the arrangement mode of each sub-control actually contained is determined based on the number of the sub-controls actually contained and the design arrangement positions of the sub-controls respectively contained in each parent control based on basic typesetting information, and the sub-controls contained in each parent control are dynamically loaded after the designed user interface containing a plurality of parent controls is displayed. The invention simplifies the design process of the user interface, improves the integral typesetting of the user interface, and has extremely high self-adaptability in the application process.

Description

WinForm control dynamic loading method, device, equipment and medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a medium for dynamically loading a WinForm control.
Background
Currently, with the development of computer technology, development technology for user interfaces is also gradually developed. In general, windows can design forms and visual controls to create rich Windows-based applications.
In the prior art, when designing a man-machine user interface (hereinafter referred to as UI interface), a conventional Windows application program generally adopts a method of directly dragging and placing a display control at a suitable position of the design interface. The design method has the advantages that: the realization is simple, and the visual operability is strong.
However, the prior art also has the obvious defect that the display control is arranged in a mode of directly dragging the display control, so that the operability of the single display control is strong, and the integral typesetting is difficult to consider in the process of operating the single display control, so that the integral typesetting is poor, and the self-adaption is not realized in the display process.
Disclosure of Invention
Based on the above, it is necessary to provide a method, a device, equipment and a medium for dynamically loading a WinForms control according to the above technical problems.
The technical scheme adopted in the specification is as follows:
the specification provides a WinForm control dynamic loading method, which comprises the following steps:
Acquiring basic typesetting information of a user interface; the basic typesetting information comprises the number of father controls contained in a user interface, the design arrangement positions and the design sizes of child controls contained in each father control respectively, and the father controls and the child controls are WinForms;
typesetting and designing a plurality of father controls in a user interface according to the quantity of the father controls;
determining the number of child controls truly contained in each parent control in the user interface application process according to the determined interaction demand number of the user interface before the user interface application;
determining the real arrangement positions of the child controls contained in each father control according to the number of the child controls contained in each father control truly and the design arrangement positions of the child controls contained in each father control;
and displaying the designed user interface containing a plurality of father controls, and dynamically loading each child control in each father control according to the number of the child controls actually contained in each father control, the real arrangement position and the design size of each child control.
Optionally, the design arrangement positions of the sub-controls in the basic typesetting information include:
the design arrangement line number and the design arrangement line number of the child control,
A design start horizontal axis coordinate and a design start vertical axis coordinate of the first sub-control,
The vertical axis offset is designed between rows and the horizontal axis offset is designed between columns.
Optionally, determining the actual arrangement positions of the child controls respectively included in the father controls according to the number of the child controls actually included in the father controls and the design arrangement positions of the child controls respectively included in the father controls specifically includes:
determining the real arrangement number and the real arrangement number of the child controls contained in each parent control according to the number of the child controls, the design arrangement number and the design arrangement number of the child controls contained in each parent control;
and determining the real starting horizontal axis coordinate and the real starting vertical axis coordinate of the first child control in each father control in the application process of the user interface according to the difference between the real arrangement row number and the real arrangement column number of the child control, the design arrangement row number and the design arrangement column number which are respectively contained in each father control.
Optionally, the basic typesetting information further includes an alignment mode of child controls in each parent control;
the determining the real arrangement positions of the child controls respectively contained in the father controls according to the number of the child controls actually contained in the father controls and the design arrangement positions of the child controls respectively contained in the father controls specifically comprises the following steps:
Determining the real arrangement number and the real arrangement number of the child controls contained in each parent control according to the number of the child controls, the design arrangement number and the design arrangement number of the child controls contained in each parent control;
and determining the real initial horizontal axis coordinate and the real initial vertical axis coordinate of the first child control in each father control in the application process of the user interface according to the difference between the real arrangement row number and the real arrangement column number of the child control, the design arrangement row number and the design arrangement column number and the alignment mode of the child control, which are respectively contained in each father control.
Optionally, determining the actual arrangement positions of the child controls respectively included in the father controls according to the number of the child controls actually included in the father controls and the design arrangement positions of the child controls respectively included in the father controls specifically includes:
determining the real arrangement number and the real arrangement number of the child controls contained in each parent control according to the number of the child controls, the design arrangement number and the design arrangement number of the child controls contained in each parent control;
acquiring the real display size of each parent control when a user interface containing a plurality of parent controls is displayed;
determining the width expansion ratio and the height expansion ratio of the father control according to the difference between the design size of each father control and the real display size of each father control in the application process;
Determining the real initial horizontal axis coordinates of the first child control in each parent control according to the difference between the real arrangement number and the design arrangement number of the child controls contained in each parent control and the width expansion ratio;
and determining the real initial ordinate of the first child control in each parent control according to the difference between the real arrangement line number and the design arrangement line number of the child control respectively contained in each parent control and the height expansion ratio.
Optionally, in each parent control, dynamically loading each child control according to the number of child controls actually contained in each parent control, the real arrangement position and the design size of each child control:
determining the real size of the child control in each parent control according to the design size of the child control in each parent control, the width expansion ratio and the height expansion ratio of the parent control;
determining the real font size of the child controls in each parent control according to the design font size, the width expansion proportion and the height expansion proportion of the parent control, which correspond to the display content of each child control respectively contained in each parent control;
in each parent control, dynamically loading each child control according to the number of child controls actually contained in each parent control, the real arrangement position of each child control, the real size of each child control and the real font size of each child control.
The present specification provides a WinForm control dynamic loading device, including:
the acquisition module is used for acquiring basic typesetting information of the user interface; the basic typesetting information comprises the number of father controls contained in a user interface, the design arrangement positions and the design sizes of child controls contained in each father control respectively, and the father controls and the child controls are WinForms;
the design module is used for typesetting and designing a plurality of father controls in the user interface according to the quantity of the father controls;
the determining module is used for determining the number of child controls truly contained in the parent control in the application process of the user interface according to the determined interaction demand number of the user interface before the application of the user interface;
the adjustment module is used for determining the real arrangement positions of the child controls contained in each father control according to the number of the child controls truly contained in each father control and the design arrangement positions of the child controls contained in each father control;
the display module is used for displaying the designed user interface containing a plurality of father controls, and dynamically loading the child controls in each father control according to the number of the child controls actually contained in each father control, the real arrangement position and the design size of each child control.
The present disclosure provides a computer readable storage medium storing a computer program which, when executed by a processor, implements the WinForm control dynamic loading method described above.
The present disclosure provides a computer device, including a memory, a processor, and a computer program stored on the memory and capable of running on the processor, where the processor implements the WinForm control dynamic loading method described above when executing the program.
The above-mentioned at least one technical scheme that this specification adopted can reach following beneficial effect:
basic typesetting information of a user interface is acquired first, and then a parent control of the bottom layer in the user interface is designed. When the user interface is actually applied, the number of the sub-controls actually contained in each parent control can be determined according to the number of the interaction requirements determined before the user interface is applied, so that the arrangement mode of each sub-control actually contained is determined based on the number of the sub-controls actually contained and the design arrangement positions of the sub-controls respectively contained in each parent control based on basic typesetting information, and the sub-controls contained in each parent control are dynamically loaded after the designed user interface containing a plurality of parent controls is displayed.
According to the invention, basic typesetting information of child controls contained in the parent controls is preset, then when a user interface is designed, only the parent controls in the user interface are required to be designed, and in the application process of the user interface, the child control information truly contained in the parent controls is determined in real time, so that typesetting of each child control is dynamically determined based on the basic typesetting information, and each child control is dynamically loaded. The design process of the user interface is simplified, the overall typesetting of the user interface is improved, meanwhile, the user interface has extremely high self-adaptability in the application process, and the display quantity and the display position of the child controls can be automatically adjusted according to the display requirement.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute an undue limitation to the application. In the drawings:
FIG. 1 is a schematic flow chart of a dynamic loading method of WinForm control provided in the present specification;
FIG. 2 is a schematic diagram of a parent control full-scale interface provided in the present disclosure;
FIG. 3 is a schematic diagram of a dynamic loading interface for a sub-control provided in the present disclosure;
FIG. 4 is a schematic diagram of a control display in Normal state for a parent control provided in the present disclosure;
FIG. 5 is a schematic illustration of a control display in a parent control Maximized state provided herein;
fig. 6 is a schematic diagram of a dynamic loading device for a WinForm control provided in the present specification;
fig. 7 is a schematic diagram of a computer device for implementing a dynamic loading method of a WinForm control provided in the present specification.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the present specification more apparent, the technical solutions of the present application will be clearly and completely described below with reference to specific embodiments of the present specification and corresponding drawings. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the disclosure, are intended to be within the scope of the present application based on the embodiments described herein.
Currently, when designing a UI interface, a visual interface of UI interface design software is usually designed by directly dragging a display control and placing the display control at a suitable position of the design interface. However, the design method has obvious disadvantages, on one hand, the user cannot customize the number and the display positions of the display controls, and after the design in the visual interface is completed, the user cannot adjust the display according to actual needs in the display process. On the other hand, the designed display control cannot adaptively adjust the size, margin and font size according to the change of the size of the father window in the actual scene in the display process.
The following describes in detail the technical solutions provided by the embodiments of the present application with reference to the accompanying drawings.
Fig. 1 is a flow chart of a dynamic loading method of a WinForm control in the present specification, which specifically includes the following steps:
s101: acquiring basic typesetting information of a user interface; the basic typesetting information comprises the number of father controls contained in the user interface, the design arrangement positions and the design sizes of child controls contained in each father control respectively, and the father controls and the child controls are WinForms.
Generally, when designing a UI interface, an art staff of a service platform may determine basic typesetting information according to the interface design requirement. Then, the server of the service platform can call the obtained basic typesetting information of the user interface to serve the interface designer or the interface display task.
The basic typesetting information may refer to design information such as the number, the position, the size, etc. of each display control in the user interface. Of course, the user interface is typically formed as an overall interface by stacking and nesting of display controls, so that the underlying display control may be considered a parent control and the display control stacked above the parent control may be considered a child control. Of course, both the parent control and child control are WinForms herein.
Specifically, in one or more embodiments of the present disclosure, the basic typesetting information may include the number of parent controls included in the user interface, the maximum number of child controls included in each parent control, and the design layout position and design size of each child control. The design arrangement position of each child control refers to a display position of the child control in an interface, for example, the number of design arrangement rows and design arrangement columns of the child control, the design start horizontal axis coordinate and the design start vertical axis coordinate of the first child control, the design vertical axis offset between rows and the design horizontal axis offset between columns may be used. Of course, the relative display position of the child control with respect to the parent control may also be referred to. The design layout position of the child control can be determined according to the requirement, and the specification does not limit the design layout position. The design arrangement line number and the design arrangement line number of the child control may refer to the design maximum arrangement line number and the design maximum arrangement line number of the child control in each parent control. The design arrangement positions of the child controls in each parent control can be different or the same, and the design arrangement positions can be determined according to the needs.
Further, in one or more embodiments of the present disclosure, the server may describe the basic typesetting information through XML markup language, and generate a typesetting information configuration file, so as to facilitate storage and use. The underlying layout information may also be stored in a database in a suitable data structure.
For example, taking the case that Label child controls are displayed in a plurality of rows and columns in the same parent control Panel, the server can acquire basic typesetting information including the following:
the number of the parent controls Panel is 1, and the maximum row number rowsMaxNum and the maximum column number colsMaxNum of Label child controls can be placed by the parent controls Panel.
First Label subcontrol information: the X coordinate startX of the starting position and the Y coordinate startY of the starting position.
And an X-axis offset factor between columns, and a Y-axis offset factor between rows.
Child control size (i.e., width and Height) labSize.
The basic typesetting information in the above example can be recorded and stored in a configuration file or other modes, and the server can directly call the stored configuration file or other modes of corresponding storage data when executing the method.
The server mentioned in the present specification may be a server provided on a service platform, or a device such as a desktop, a notebook, or the like capable of executing the aspects of the present specification. For convenience of explanation, only the server is used as the execution subject.
S102: and typesetting and designing a plurality of father controls in the user interface according to the number of the father controls.
S103: and determining the number of child controls actually contained in the parent control in the user interface application process according to the determined interaction requirement number of the user interface before the user interface application.
S104: and determining the real arrangement positions of the child controls respectively contained in the father controls according to the number of the child controls actually contained in the father controls and the design arrangement positions of the child controls respectively contained in the father controls.
After the basic typesetting information corresponding to the UI interface is obtained, the server can respond based on design operation of the user through UI interface design software, and display a design interface containing a plurality of father controls, so that the user typesets and designs the plurality of father controls in the user interface according to the number of the father controls and the design requirement of the father controls.
After the design of the parent control of the bottom layer is finished by a user, in the actual application process of the user interface, the server can determine the number of child controls actually contained in the parent control in the application process of the user interface according to the determined interaction demand number of the user interface before the application of the user interface. Before the user interface is applied, the user-defined information of the number of the real child controls can be filled into a data file of the basic typesetting information through data interaction, or an application user can carry out user-defined setting on the number of the real child controls before the user interface is applied in a real-time interaction mode.
For example, the user interface may be a movie hall footage interface, the parent control may be a movie hall footage presentation area, the parent control may include a plurality of footage child controls, the child controls bind to the footage, and so on. Assuming that at most 100 seat child controls can be displayed in the display area of the parent control, 100 is the maximum number of seat child controls included in the parent control in the movie hall display area in step S101. In practice, if the seats in each hall are less than 100, for example, hall a may contain 80 seats, then in the practical application process of the user interface, the child seat control actually contained in the parent control of the hall seat display area is 80. The self-defining information of the 80 seats can be determined before the application of the interface of the video hall by the application user of the video hall in an interactive mode, so that the determined interface of the video hall is applied to the consumption user, and the consumption user performs the seat selecting service.
Then, the server can determine the real arrangement positions of the child controls contained in each parent control according to the basic typesetting information in the step S101 and the number of the child controls contained in each parent control. Continuing taking the above-mentioned movie theatre selection interface as an example, the server can adjust the default arrangement mode according to the default arrangement mode of each child control in the preset father control and the difference between the maximum number of child controls and the number of child controls actually contained, so as to determine the arrangement of each child control actually contained.
Continuing to take the case of displaying Label sub-controls in multiple columns in the same parent control Panel, it is assumed that the number of Label sub-controls that need to be actually drawn is determined according to the interaction requirement of the user interface determined in the running process of the business application program (ctrlnum=7). Maximum row number rowsmaxnum=5, maximum column number colsmaxnum=4, first Label child control start position X coordinate startx=46, start position Y coordinate starty=48, X-axis offset factor x=82, Y-axis offset factor y=30, child control size labSize (width=75, height=23) of the Label child control that the parent control Panel can place. As shown in fig. 2.
Fig. 2 is a schematic diagram of a parent control full-scale interface in the present specification. It can be seen that in the display background as a Panel parent, 20 Label child controls are contained in a 5 row 4 column full distribution.
The server can determine the arrangement positions of the Label sub-controls through the following processes:
first, the server may calculate the number of columns (colNum) to be drawn according to ctrlNum and rowsMaxNum, where the formula is as follows:
int colNum=(int)Math.Ceiling((double)ctrlNum/rowsMaxNum)
here, a celing (rounding up) method is adopted, so that it is ensured that each child control to be drawn can be normally loaded and displayed under the condition of non-whole columns.
Next, from colNum and colsMaxNum, a column index (colIndex) for the child control to start drawing is calculated, and the index is ordered from 0, and the formula is as follows:
int colIndex=(colsMaxNum-colNum)/2
the above algorithm ensures that child controls displayed in a nested manner by a user are always displayed in the middle of the level in the parent control. Because the maximum column number is 4, the column index is 0-3, the index of the first column obtained by the above formula is 1, the column indexes of the sub-controls actually contained are 1 and 2 after the calculation by the above formula, and the sub-controls obtained by the determination of the above formula are centrally displayed. If the display position of the child control needs to be shifted left/right, only the value of the colIndex needs to be modified.
Fig. 3 is a schematic diagram of a dynamic loading interface of a sub-control in the present specification. It can be seen that in the display background as the Panel parent control, 7 Label child controls actually contained in the application process of 5 rows and 2 columns are contained, and the two Label child controls are distributed in the middle left and right.
Of course, the number of columns of the sub-control actually contained is calculated by the maximum column, and the same is true, the number of columns of the sub-control actually contained can be calculated by the maximum column. Other limitations may be added to the specific arrangement as desired, and are not limited in this specification.
In addition, in one or more embodiments of the present disclosure, the server may further determine, according to the number of child controls actually included in each parent control, the number of design arrangement rows and the number of design arrangement columns of the child controls, the number of actual arrangement rows and the number of actual arrangement columns of the child controls respectively included in each parent control. The design arrangement line number is the maximum arrangement line number, and the design arrangement column number is the maximum arrangement column number.
Then, the server can determine the real initial horizontal axis coordinate and the real initial vertical axis coordinate of the first child control in each parent control in the application process of the user interface according to the difference between the real arrangement row number and the real arrangement column number of the child controls and the design arrangement row number and the design arrangement column number respectively contained in each parent control.
Specifically, taking the actual initial horizontal axis coordinate of the first child control as an example for explanation, the server can determine the actual initial horizontal axis coordinate of the child control in the parent control according to the difference between the design arrangement number and the actual arrangement number of the child control in the basic typesetting information.
For example, assuming that the design arrangement number is 4, the real arrangement number is 2, and assuming that the default arrangement mode is centered, the column position of the first child control in the parent control corresponds to the design position of the second column in the design situation, so that the real initial horizontal axis coordinate of the first child control in the parent control can be obtained by adding the product of the design initial horizontal axis coordinate of the first child control in the basic typesetting information and the difference of the design horizontal axis offset and the column index between the columns.
For other columns, the real initial horizontal axis coordinates of the other column child controls can be obtained by adding the product of the designed horizontal axis offset and the column index between the columns to the real initial horizontal axis coordinates of the first child control. The same applies to the true start vertical axis coordinates of the first child control and the true start vertical axis coordinates of the other row child controls. Therefore, in the process of dynamically loading the child controls contained in the parent control, the display positions of the child controls are accurately positioned. Of course, the server can also calculate the real initial horizontal axis coordinate and the real initial vertical axis coordinate of the first child control in the process of actually dynamically loading the child control. The actual starting abscissa and ordinate of the sub-control can be determined according to the requirement, and the specification does not limit the actual starting abscissa and ordinate.
S105: and displaying the designed user interface containing a plurality of father controls, and dynamically loading each child control in each father control according to the number of the child controls actually contained in each father control, the real arrangement position and the design size of each child control.
In the actual application process of the user interface, after the arrangement positions of the child controls truly contained in the father controls are determined, the server can display the designed user interface containing a plurality of father controls, and meanwhile in each father control, each child control is dynamically loaded according to the number of the child controls truly contained in each father control, the calculated true arrangement positions of each child control and the design size of each child control.
Continuing taking the Label sub-control displayed in a plurality of rows and columns in the same parent control Panel as an example, the server can dynamically draw the Label control according to the initial coordinate and the X/Y axis offset of the first Label sub-control in the actual application process of the user interface, and main codes are as shown in the specification:
wherein colNum, rowsMaxNum, ctrlNum, startX, startY, factorX, factorY and labSize are defined as described in step S101. count is a local variable for counting the number of Label child controls drawn, and pnl is a parent control object.
For each Label sub-control to be drawn, the position X coordinate is as follows: startx+ (colindex+i) factor x, Y coordinates are: starty+j factor y).
The child controls contained in the parent control can be dynamically loaded according to the actual interaction requirements of the user interface through the server. Of course, the user interface can be displayed in a multi-layer nested mode, and the server can dynamically load child controls nested in each layer by layer in a recursive mode based on the parent control of the bottom layer.
Based on the WinForm control dynamic loading method shown in FIG. 1, basic typesetting information of a user interface is acquired first, and then a parent control of a bottom layer in the user interface is designed. When the user interface is actually applied, the number of the sub-controls actually contained in each parent control can be determined according to the number of the interaction requirements determined before the user interface is applied, so that the arrangement mode of each sub-control actually contained is determined based on the number of the sub-controls actually contained and the design arrangement positions of the sub-controls respectively contained in each parent control based on basic typesetting information, and the sub-controls contained in each parent control are dynamically loaded after the designed user interface containing a plurality of parent controls is displayed.
According to the invention, basic typesetting information of the child controls contained in the parent controls is preset, then only the parent controls in the user interface are needed when the user interface is used, and the child control information truly contained in the parent controls is determined in real time in the application process of the user interface, so that typesetting of each child control is dynamically determined based on the basic typesetting information, and dynamic loading is carried out on each child control. The design process of the user interface is simplified, the overall typesetting of the user interface is improved, meanwhile, when the same user interface is applied to a plurality of application scenes for interaction, the user interface has extremely high self-adaptability in the application process of different scenes, and the display quantity and the display position of the child controls can be automatically adjusted according to display requirements.
When the WinForm control dynamic loading method provided by the specification is applied, the method can be executed without the sequence of steps shown in FIG. 1, and the specific execution sequence of the steps can be determined according to the needs, so that the specification is not limited.
In addition, in one or more embodiments of the present disclosure, the basic typesetting information in step S101 may further include an alignment manner of child controls actually included in each parent control during the application process of the user interface. In other words, for the alignment mode of the child controls included in each parent control, default setting can be performed in the process of dynamically loading the child controls, and the child controls can be written into the data file of the basic typesetting information by the user based on real-time data interaction.
Then, in step S104, when determining the real arrangement positions of the child controls included in each parent control, the server may determine the real arrangement number and the real arrangement number of the child controls included in each parent control according to the number of child controls actually included in each parent control, the design arrangement number and the design arrangement number of the child controls. And determining the real initial horizontal axis coordinate and the real initial vertical axis coordinate of the first child control in the application process of the user interface according to the difference between the real arrangement row number and the real arrangement column number of the child control, the design arrangement row number and the design arrangement column number and the alignment mode of the child control, which are respectively contained in each parent control.
For example, if the interaction requirement specifies that the alignment mode of child controls included in a parent control is left alignment, the index for each column of child controls starts from 0 regardless of the number of child controls actually included. Or the interaction requirement designates the alignment mode of the child control included in the parent control to be up-down centering and left-right centering, and the server can determine the real initial horizontal axis coordinate and the real initial vertical axis coordinate of the first child control in the parent control according to the difference between the real arrangement line number and the design arrangement line number of the child control and the difference between the real arrangement line number and the design arrangement line number. And then combining the row-column index, the vertical axis offset between each row and the horizontal axis offset between each column to obtain the real initial horizontal axis coordinate and the real initial vertical axis coordinate of each sub-control in the application process of the user interface.
The adaptivity of the user interface application process is further improved by the alignment mode of the stator control through real-time data interaction.
In addition, since the same user interface may be displayed on screens with different resolutions, the display size of each parent control may not be the same as the design size, and the server may obtain the real display size of each parent control in the application process of the user interface in real time, so as to adjust the real display size of the child control included in the parent control according to the real display size of the parent control.
Therefore, in one or more embodiments of the present disclosure, in step S104, when determining the real arrangement positions of the child controls included in each parent control, the server may determine the real arrangement number and the real arrangement number of the child controls included in each parent control according to the number of child controls, the design arrangement number and the design arrangement number of the child controls included in each parent control. Then, the real display size of each parent control when the user interface containing a plurality of parent controls is displayed is obtained. And determining the width expansion ratio and the height expansion ratio of the father control according to the difference between the design size of each father control obtained by design and the real display size of each father control in the application process. And finally, determining the real initial horizontal axis coordinates of the first child control in each parent control according to the difference between the real arrangement row number and the design arrangement row number of the child control and the width expansion ratio respectively contained in each parent control, and determining the real initial vertical coordinates of the first child control in each parent control according to the difference between the real arrangement row number and the design arrangement row number of the child control respectively contained in each parent control and the height expansion ratio.
Further, in step S105, the server may determine the real size of the child control in each parent control according to the design size of the child control in each parent control, the width expansion ratio and the height expansion ratio of the parent control, and may determine the real font size of the child control in each parent control according to the design font size corresponding to the display content of each child control, the width expansion ratio and the height expansion ratio of the parent control, which are included in each parent control, respectively, and finally dynamically load each child control in each parent control according to the number of child controls actually included in each parent control, the real arrangement position of each child control, the real size of each child control, and the real font size of each child control.
For example, the server may preset a global variable, record the original dimensions of the parent control Panel and each Label child control, and specific parameters include:
x coordinates of child control to left edge of parent control: left_original.
Y coordinates of child control to upper edge of parent control: top_original.
Width of child control: width_original.
Child control height: height_original.
Sub control font size: fontsize_original.
In practical applications, if each Label sub-control further includes a sub-control, the original dimensions of all sub-controls need to be recursively recorded.
Secondly, in all events triggered by the change of the size of the parent control, the following implementation is added:
according to the original size (width_original and height_original) and the existing size (width and height) of the parent control Panel, a width scale and a height scale are calculated, and the formulas are as follows:
floatwScale=(float)width/width_origina;
floathScale=(float)height/height_original;
the display parameters of all Label sub-controls (including their sub-controls) are calculated and adjusted according to wScale and hScale. The formulas for left, top, width and height are as follows:
left=(int)Math.Round(left_original*wScale);
top=(int)Math.Round(top_original*hScale);
width=(int)Math.Round(width_original*wScale);
height=(int)Math.Round(height_original*hScale);
the calculation formula of the font size is as follows:
float wSize=fontSize_original*wScale;
float hSize=fontSize_original*hScale;
label.Font.Size=Math.Min(hSize,wSize);
the Label is an object of each Label sub-control.
The original size record result is updated, and the formula is as follows:
left_original=left_original*wScale;
top_original=top_original*hScale;
width_original=width_original*wScale;
height_original=height_original*hScale;
fontSize_original=label.Font.Size;
in contrast to the computational formulas of left, top, width and height, the formulas do not use the rounded-up values when updating the left_original, top_ original, width _original, and height_original attributes. The design is mainly used for avoiding the phenomenon that display controls are overlapped and displayed after the program repeatedly rounds the calculated display positions for avoiding the multiple size changes of the father window.
The real display size of the child controls contained in the parent control is further correspondingly adjusted according to the real display size of the parent control in the application process of the user interface, so that overlapping display of the child controls caused by different screen resolutions in actual application is avoided, and the self-adaptability of the user interface in the application process is further improved. And simultaneously, the font size corresponding to the display content in the child control is adjusted, so that the problem that the child control is not matched with the display content in size after being adjusted is avoided.
Fig. 4 is a schematic diagram of a control display in a Normal state of a parent control in the present specification, and fig. 5 is a schematic diagram of a control display in a Maximized state of a parent window in the present specification. As can be seen from fig. 4 and fig. 5, the resolution of the display background as the Panel parent control is not the same, but the Label child control contained therein is also adaptively adjusted, and the typesetting proportion of the Label child control in the two figures is consistent with the real display size proportion between the parent controls.
In addition, in one or more embodiments of the present disclosure, when the child controls included in each parent control are dynamically loaded, the server may name each child control through a name attribute and record the name attribute into a global variable, so as to adapt to the requirement of quickly searching for the child control in other business requirements.
The above method for dynamically loading WinForms provided for one or more embodiments of the present disclosure further provides a corresponding device for dynamically loading WinForms based on the same concept, as shown in FIG. 6.
Fig. 6 is a schematic diagram of a dynamic loading device for a WinForm control provided in the present specification, including:
an obtaining module 201, configured to obtain basic typesetting information of a user interface; the basic typesetting information comprises the number of father controls contained in a user interface, the design arrangement positions and the design sizes of child controls contained in each father control respectively, and the father controls and the child controls are WinForms;
A design module 202, configured to typeset and design a plurality of parent controls in the user interface according to the number of the parent controls;
the determining module 203 is configured to determine, for each parent control, the number of child controls actually included in the parent control during the application process of the user interface according to the number of interaction requirements of the user interface determined before the application of the user interface;
the adjustment module 204 is configured to determine the actual arrangement positions of the child controls included in each parent control according to the number of child controls actually included in each parent control and the design arrangement positions of the child controls included in each parent control;
the display module 205 is configured to display the designed user interface including multiple parent controls, and dynamically load each child control in each parent control according to the number of child controls actually included in each parent control, the actual arrangement position and the design size of each child control.
Optionally, the design arrangement positions of the child controls in the basic typesetting information include: the number of the design arrangement rows and the number of the design arrangement columns of the child control, the design start horizontal axis coordinate of the first child control, the design start vertical axis coordinate of the first child control, the design vertical axis offset between the rows and the design horizontal axis offset between the columns.
Optionally, the adjustment module 204 determines, according to the number of child controls actually included in each parent control, the design arrangement number of rows and the design arrangement number of columns of the child controls, the actual arrangement number of rows and the actual arrangement number of columns of the child controls respectively included in each parent control, and determines, according to differences between the actual arrangement number of rows and the actual arrangement number of columns of the child controls respectively included in each parent control, the design arrangement number of rows and the design arrangement number of columns, the actual start horizontal axis coordinate and the actual start vertical axis coordinate of the first child control in each parent control in the application process of the user interface.
Optionally, the interaction requirement further includes an alignment mode of child controls actually included in each parent control in the application process of the user interface;
optionally, the adjustment module 204 determines, according to the number of child controls actually included in each parent control, the design arrangement number of the child controls, and the design arrangement number of the child controls, the real arrangement number of the child controls and the real arrangement number of the child controls respectively included in each parent control, and determines, according to the difference between the real arrangement number of the child controls and the design arrangement number of the child controls and the alignment manner of the child controls, the real start horizontal axis coordinate and the real start vertical axis coordinate of the first child control in each parent control in the application process of the user interface.
Optionally, the interaction requirement further includes a real display size of each parent control in the user interface application process;
optionally, the adjustment module 204 determines, according to the number of child controls actually included in each parent control, the design arrangement number of the child controls, and the design arrangement number of the design arrangement number, the real arrangement number of the child controls and the real arrangement number of the actual arrangement number of the child controls respectively included in each parent control, obtains the real display size of each parent control when the user interface including a plurality of parent controls is displayed, determines the width expansion ratio and the height expansion ratio of each parent control according to the difference between the design size of each parent control obtained by design and the real display size of each parent control in the application process, determines the real start horizontal axis coordinate of the first child control in each parent control according to the difference between the real arrangement number of the child controls respectively included in each parent control and the design arrangement number of the child controls and the width expansion ratio, and determines the real start vertical coordinate of the first child control in each parent control according to the difference between the real arrangement number of the child controls respectively included in each parent control and the design arrangement number of the child controls and the height expansion ratio.
Optionally, the display module 205 determines the real size of the child control in each parent control according to the design size of the child control in each parent control, the width expansion ratio and the height expansion ratio of the parent control, and determines the real font size of the child control in each parent control according to the design font size corresponding to the display content of each child control, the width expansion ratio and the height expansion ratio of the parent control, which are respectively included in each parent control, and dynamically loads each child control in each parent control according to the number of child controls actually included in each parent control, the real arrangement position of each child control, the real size of each child control and the real font size of each child control.
For specific limitation of the WinForm control dynamic loading device, reference may be made to the limitation of the WinForm control dynamic loading method hereinabove, and no further description is given here. All or part of each module in the WinForm control dynamic loading device can be realized by software, hardware and a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
The present disclosure also provides a computer readable storage medium storing a computer program, where the computer program may be used to execute the WinForm control dynamic loading method provided in FIG. 1.
The present specification also provides a schematic structural diagram of the computer device shown in fig. 7, where, as shown in fig. 7, the computer device includes a processor, an internal bus, a network interface, a memory, and a nonvolatile memory, and may include hardware required by other services. The processor reads the corresponding computer program from the nonvolatile memory to the memory and then runs the computer program to realize the WinForm control dynamic loading method provided by the FIG. 1.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile memory may include Read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, or the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.

Claims (9)

1. A WinForm control dynamic loading method is characterized by comprising the following steps:
acquiring basic typesetting information of a user interface; the basic typesetting information comprises the number of father controls contained in a user interface, the design arrangement positions and the design sizes of child controls contained in each father control respectively, and the father controls and the child controls are WinForms;
typesetting and designing a plurality of father controls in a user interface according to the quantity of the father controls;
determining the number of child controls truly contained in each parent control in the user interface application process according to the determined interaction demand number of the user interface before the user interface application;
determining the real arrangement positions of the child controls contained in each father control according to the number of the child controls contained in each father control truly and the design arrangement positions of the child controls contained in each father control;
and displaying the designed user interface containing a plurality of father controls, and dynamically loading each child control in each father control according to the number of the child controls actually contained in each father control, the real arrangement position and the design size of each child control.
2. The dynamic loading method of WinForm control according to claim 1, wherein the design arrangement position of the sub-control in the basic typesetting information comprises:
The design arrangement line number and the design arrangement line number of the child control,
A design start horizontal axis coordinate and a design start vertical axis coordinate of the first sub-control,
The vertical axis offset is designed between rows and the horizontal axis offset is designed between columns.
3. The dynamic loading method of the WinForm control according to claim 2, wherein the determining the actual arrangement positions of the child controls included in each parent control according to the number of child controls actually included in each parent control and the design arrangement positions of the child controls included in each parent control specifically includes:
determining the real arrangement number and the real arrangement number of the child controls contained in each parent control according to the number of the child controls, the design arrangement number and the design arrangement number of the child controls contained in each parent control;
and determining the real starting horizontal axis coordinate and the real starting vertical axis coordinate of the first child control in each father control in the application process of the user interface according to the difference between the real arrangement row number and the real arrangement column number of the child control, the design arrangement row number and the design arrangement column number which are respectively contained in each father control.
4. The dynamic loading method of WinForm control according to claim 2, wherein the basic typesetting information further comprises alignment modes of child controls in each parent control;
The determining the real arrangement positions of the child controls respectively contained in the father controls according to the number of the child controls actually contained in the father controls and the design arrangement positions of the child controls respectively contained in the father controls specifically comprises the following steps:
determining the real arrangement number and the real arrangement number of the child controls contained in each parent control according to the number of the child controls, the design arrangement number and the design arrangement number of the child controls contained in each parent control;
and determining the real initial horizontal axis coordinate and the real initial vertical axis coordinate of the first child control in each father control in the application process of the user interface according to the difference between the real arrangement row number and the real arrangement column number of the child control, the design arrangement row number and the design arrangement column number and the alignment mode of the child control, which are respectively contained in each father control.
5. The dynamic loading method of the WinForm control according to claim 2, wherein the determining the actual arrangement positions of the child controls included in each parent control according to the number of child controls actually included in each parent control and the design arrangement positions of the child controls included in each parent control specifically includes:
determining the real arrangement number and the real arrangement number of the child controls contained in each parent control according to the number of the child controls, the design arrangement number and the design arrangement number of the child controls contained in each parent control;
Acquiring the real display size of each parent control when a user interface containing a plurality of parent controls is displayed;
determining the width expansion ratio and the height expansion ratio of the father control according to the difference between the design size of each father control and the real display size of each father control in the application process;
determining the real initial horizontal axis coordinates of the first child control in each parent control according to the difference between the real arrangement number and the design arrangement number of the child controls contained in each parent control and the width expansion ratio;
and determining the real initial vertical axis coordinates of the first child control in each parent control according to the difference between the real arrangement line numbers and the design arrangement line numbers of the child controls contained in each parent control and the height expansion ratio.
6. The dynamic loading method of WinForm control according to claim 5, wherein in each parent control, each child control is dynamically loaded according to the number of child controls actually included in each parent control, the actual arrangement position and the design size of each child control:
determining the real size of the child control in each parent control according to the design size of the child control in each parent control, the width expansion ratio and the height expansion ratio of the parent control;
Determining the real font size of the child controls in each parent control according to the design font size, the width expansion proportion and the height expansion proportion of the parent control, which correspond to the display content of each child control respectively contained in each parent control;
in each parent control, dynamically loading each child control according to the number of child controls actually contained in each parent control, the real arrangement position of each child control, the real size of each child control and the real font size of each child control.
7. A WinForm control dynamic loading device, comprising:
the acquisition module is used for acquiring basic typesetting information of the user interface; the basic typesetting information comprises the number of father controls contained in a user interface, the design arrangement positions and the design sizes of child controls contained in each father control respectively, and the father controls and the child controls are WinForms;
the design module is used for typesetting and designing a plurality of father controls in the user interface according to the quantity of the father controls;
the determining module is used for determining the number of child controls truly contained in the parent control in the application process of the user interface according to the determined interaction demand number of the user interface before the application of the user interface;
The adjustment module is used for determining the real arrangement positions of the child controls contained in each father control according to the number of the child controls truly contained in each father control and the design arrangement positions of the child controls contained in each father control;
the display module is used for displaying the designed user interface containing a plurality of father controls, and dynamically loading the child controls in each father control according to the number of the child controls actually contained in each father control, the real arrangement position and the design size of each child control.
8. A computer-readable storage medium, characterized in that the storage medium stores a computer program which, when executed by a processor, implements the method of any of the preceding claims 1-6.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of any of the preceding claims 1-6 when executing the program.
CN202311440963.9A 2023-11-01 2023-11-01 WinForm control dynamic loading method, device, equipment and medium Pending CN117435271A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311440963.9A CN117435271A (en) 2023-11-01 2023-11-01 WinForm control dynamic loading method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311440963.9A CN117435271A (en) 2023-11-01 2023-11-01 WinForm control dynamic loading method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN117435271A true CN117435271A (en) 2024-01-23

Family

ID=89554949

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311440963.9A Pending CN117435271A (en) 2023-11-01 2023-11-01 WinForm control dynamic loading method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN117435271A (en)

Similar Documents

Publication Publication Date Title
JP7354294B2 (en) System and method for providing responsive editing and display integrating hierarchical fluid components and dynamic layout
US8826152B2 (en) Displaying icon layouts in different resolutions
KR101130487B1 (en) Grid canvas
US5577187A (en) Method and system for tiling windows based on previous position and size
US8938685B2 (en) Automated graphical user interface design and development systems and methods
US8756528B2 (en) System and method of customizing video display layouts having dynamic icons
US9513783B1 (en) Determining available screen area
US11112927B2 (en) Digital content automated layout system
US10289671B2 (en) Graphically displaying selected data sources within a grid
US10565560B2 (en) Alternative people charting for organizational charts
CN113687745B (en) Interface display method, system and terminal for split-screen window
WO2014117559A1 (en) 3d-rendering method and device for logical window
US5566287A (en) Method for asynchronously maintaining an image on a display device
JP5325977B2 (en) Space-time layout of media objects
CN104995622A (en) Compositor support for graphics functions
US20230377228A1 (en) Map data visualizations with multiple superimposed marks layers
US10467782B2 (en) Interactive hierarchical bar chart
US10809904B2 (en) Interactive time range selector
CN117435271A (en) WinForm control dynamic loading method, device, equipment and medium
CN116069323A (en) Method for dynamically constructing visual large screen in modularized mode
CN111190894A (en) Map display method and device, related storage medium and client
CN114780081A (en) Animation display method, electronic device and storage medium
US11816320B2 (en) Paginated growing widgets
CN117152300B (en) Dynamic layer planning algorithm for optimizing drawing performance of DCS (distributed control system) flow chart
CN109710355B (en) WEB interaction-based TIP display content processing method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination