Progressive development of WinForm Project (3) project design of--winform interface layer

Source: Internet
Author: User

1, the interface layer of project construction

We from the previous two essays in the introduction, you can probably understand what happens below the interface layer, this article continues this trend, introduces the interface layer development content.

First we create a Windows Application project, use the Windows Application project that VS2010 (other versions can) create, and then modify their project target framework and output type as shown below.

Then delete all automatically generated form and class library code, the interface finally becomes the following content.

The intention of this is to put this interface part as a separate module, we start the program framework can be very convenient to include it in use, because we know that every time we develop the business may only belong to a large project in a certain part of the module, according to the division of the module to develop, easy to manage maintenance, Convenient integration of use and other characteristics.

Finally in the main interface integration is a module, each module has a different form interface to use, the approximate interface module combination of graphics as shown below.

2, the WinForm interface of the business module generation

A clean Interface Project module can be built from the first section, but there is no content in it, which requires us to build or manually write the interface we need.

In order to speed up efficiency, reduce the trivial setting of the interface control name, and reduce the code writing of object assignment, we generally recommend the use of tools to generate the interface, as shown in the following interface.

Using the code generation tool to generate the interface, naming and database field names corresponding, unified style, reduce the chance of error, improve development efficiency.

Through the above setup interface, we can set the content of the query condition in the list interface, and the content of the fields that need to be displayed, and edit and add the data content of the object interface, then we will be able to generate the related form interface.

After clicking "Windows interface code generation", the resulting form interface file is divided into two parts, one is the list interface, the other is the data editing interface, and by hand, we also recommend merging new and edited data so as to reduce the code files of the large project module.

Copy the relevant interface content to the empty Project project you just created, and add the relevant class library application, such as the interface base class that the framework needs to support, the common class library and other necessary assemblies, which is also our common development operation, again not repeat.

The final interface layer project is shown below.

3, the form interface adjustment processing

In general, the auto-generated interface may require some manual processing, such as the possibility that some class libraries do not add an application, the associated items are not added, and so on, or the problem of data type conversion, but the general problem is small, a little processing can be solved.

Let's make some adjustments to the auto-generated form interface to facilitate our data display and processing.

The Automatically created list interface opens as shown below.

Rough look we should think it is still a standard list interface, but in order to better see, more unified, we still need to do some fine-tuning, such as because the age is a numeric type, here the query condition has two as a range of combination query; In addition, the control width of each query condition is automatically scaled by default, due to fewer conditions, We still set it to a fixed width better, and finally we slightly beautify the adjusted form interface as shown below.

To fix the list interface, let's take a look at the editing interface section of the data, the results of the data editing interface are as follows (I have narrowed it down for the reasons of the layout).

We see that the field inside the description, the name of the control and so on, have been reasonably arranged, basically design the database, the specified field notes can be generated correctly.

The table fields shown here are relatively small, so there may not be a good presentation of the layout, but we know that the Layoutcontrol layout of devexpress itself is very powerful and we can adjust the position of the controls at will.

For types of controls, you can also make different types of conversions, such as text types, input controls that convert to numeric types, and so on.

Such a simple interface may be a lot of readers will say, this I add a few controls on my own, but also very quickly, but if you need to display the interface control (database field a lot), if the control display content, control name, layout location, all to manually adjust, then this workload is very amazing.

I am in the development of a project program "Customer Relationship Management System" when the business of many table fields are many, I just need to drag, adjust the next position or add some special controls to the reasonable display, do not need to adjust too much content, this can save me a lot of interface development time, more importantly, Reduce the chance of errors.

For the customer Relationship Management system customer contact This table, a lot of fields, the generated interface many controls, the default is a single row, I would like to arrange them again, and add a TabControl tab control to place more content, and make the necessary distinction, The detailed adjustment of the interface effect as shown below, this is a complex interface adjustment of a good case description.

4. Integrate business logic layer to interface project

I was in the design of the interface layer, when the interface project reference, the business Logic layer of project engineering included in the reference, as shown below.

Such a reference operation is not a problem, but if our project components are split more, each interface also needs to carry a business logic assembly, then the number of assembly DLLs will be doubled, not easy to manage.

What I mean is to integrate them all to avoid too fragmented files, but it's best to avoid copying files everywhere, which increases maintenance costs, not what we want to see.

Based on the two considerations above, we can add the file "link" operation in the interface project, that is, the shadow of the code file, when compiling, they are compiled into the assembly, but when we maintain, all of their "link" references, are pointing to the same file, will not cause multiple replication problems.

The final project composition is as follows and can be compiled smoothly so that when we use this customer's business module, we only need an assembly (WHC.TestProject.UIDx.DLL) of the interface part.

Progressive development of WinForm Project (3) project design of--winform interface layer

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.