For smaller projects, developers with some experience should be able to design and build applications that are easy to maintain and extend. However, as the number of functional modules (and the people who develop and maintain them) continues to increase, the difficulty of controlling the project begins to grow exponentially.
The Sailingease WinForm Framework provides you with a solution for this issue. In this article, you will explain the definition of a composite application based on the Sailingease WinForm framework and briefly explain how to build a composite application that is based on the Sailingease WinForm framework functionality.
A traditional single application
A traditional single application each control is tightly coupled, and there is a lot of logic in the UI to coordinate the various parts. There is also a dependency relationship between controls.
Because of these dependencies, it is not possible to break up the application into a form in which the different parts can be developed separately in some simple way. While it is possible to put all user controls in a separate assembly to improve maintainability, this approach simply transfers the problem from the main application to the control assembly, without a cure. In this model, it is very difficult to make major changes or introduce new functionality.
Composite applications based on the Sailingease WinForm framework (plug-in applications)
Composite applications based on the Sailingease WinForm framework consist of loosely coupled modules that are dynamically discovered and formed by the runtime. Modules contain visual and non-visual components that represent different vertical segments of the system. Visual components (views) are grouped together in a regular shell and can be used as a host for all content of the application. Composite applications can provide a variety of services that combine these module-level components. Modules provide additional services that are relevant to the specific functionality of the application.
At a high level, a composite application is an implementation of the composite view design pattern, which describes the recursive UI structure of the view that contains the children, which are themselves views. These views are then combined by some mechanism-usually at runtime and not at design time.
The module affects the view in which the main composite view (also known as the Shell) is created. Modules never directly refer to each other, nor do they refer directly to the shell. Instead, they use the service to communicate with each other and with the shell in response to user actions.
There are many advantages to using modules to compose a system. Modules can aggregate data from different back-end systems in the same application. In addition, the system can evolve more easily over time. When system requirements change and a new module needs to be added to the system, the modular system is much less conflicted than a non-modular system. You can also improve testability by making more independent improvements to existing modules. Finally, the modules can be developed, tested, and maintained by different teams.
A typical application based on the Sailingease WinForm framework
Create an application based on the Sailingease WinForm framework
Boot programs and containers
When building a composite application using the Sailingease WinForm framework, you must first initialize several core composite services. This introduces the bootstrap program. It can perform all the functions required to make a composite. In many ways, it is similar to the Main method of the application.
For containers, the control inversion (IoC) container/Dependency Injection (DI) container is referred to. Containers play a key role in the application. The container stores all the application services used in the application. It is responsible for injecting these services where needed.
Several core services, such as event aggregators, are also automatically registered while the container is configured, and the basic bootstrapper allows you to overwrite any of these services. For example, the Imoduleloader service is automatically registered. If you overwrite the Configurecontainer method in the bootstrapper, you can register your own module loader.
Loading of modules
In the bootloader, the required modules can be loaded by overwriting the method Getmodulecatalog, in addition to loading the modules through the Modulecatalog addmodule method, where any other required module loading methods are implemented.
definition and implementation of a module
In an application based on the Sailingease WinForm Framework, a module is a detached unit of a composite application that can be deployed as a separate assembly (although not required). The module contains most of the functionality.
This is a module in an application based on the Sailingease WinForm framework, and StartPageModule.cs is the class that implements the IModule interface. This interface contains only one method, called Initialize. If you think of the bootloader as the main method of the application, then the Initialize method here is the main of the module.
In the constructor of the module, we get the Iunitycontainer container, the event aggregator Ieventaggregator, and the workspace service Iworkbenchservice.
Iunitycontainer,ieventaggregator and Iworkbenchservice, where did they come from? Do I have to hardcode logic into the initialization code of the module?
The answer is "no". When loading a module, the Sailingease WinForm framework automatically parses the service required by the module from the container and injects it into the module's constructor, if we need to get other services when the module is initialized, simply add the parameters directly in the constructor.
In the Initialize method of the module, we do two things: Register the navigation item in the application's shell ( main window ), and subscribe to events in the application.
Publish/Subscribe to events between different modules
The Sailingease WinForm Framework provides you with event aggregation services in a traditional single application where event subscriptions between different function points are direct references and dependencies, while the Sailingease WinForm framework through the event aggregation service makes the event subscribers, Fully decoupled from the publisher, there is no reference and dependency.
Traditional Application Event Publishing subscriptions:
Feature a publishes event projectopenedevent, when feature B subscribes to this event, it must be dependent on the encoding process, referencing the function A's assembly or class.
Event Publishing subscriptions based on the Sailingease WinForm framework:
Module B obtains the event aggregation service, subscribes event projectopenedevent to the event aggregator, and when there are other event publishers, such as module A, which publishes event projectopenedevent to the event aggregator, Module B will be notified to execute the relevant code.
Module A and Module B, or more of this event subscription, publisher, do not have any dependencies, reference relationships, they are published through the event aggregation service, subscribe to events.
For example, our previous Startpagemodule subscribed to two events, Applicationrunevent and Projectopenedevent.
Our startpagemodule does not need to be concerned about who is the publisher of the event applicationrunevent and projectopenedevent, nor does it need to be a matter of when the Publisher will publish both events, Startpagemodule only need to be prepared to respond to these two events.
And our event publishers don't have to worry about who is the subscriber of the event, just publish the event to the event aggregator when the event should be published.
The following code publishes the event applicationrunevent.
Through the event aggregation mechanism, the event release between modules, the response realizes the complete decoupling, the module and the module does not exist any reference, the dependence relationship. Even if the Subscriber module or Publisher module of an event is temporarily moved out of the system, no other modules are affected.
interacting data or invoking functions between different modules through a service
In the past, single-application applications, where interaction data or functional calls were required between different functional points, were often put together at the time of encoding, and experienced programmers might place different functional points in different assemblies, but still avoid the high coupling and dependency of the inter-assembly references.
In the Sailingease WinForm framework, the concept of service is used to solve the interoperability problem between modules, so that there is no dependency or reference between modules.
As a simple example, our module a provides basic information management capabilities for our customers, and Module B is designed to handle contact records with customers. How do I need to list the contact records for a specified customer in module a?
We design a service interface Icustomercontactservice for the customer Contact Records Management Module (module B), we define the interface in an underlying assembly Infrastructure known to all modules, and we implement this interface in module B. Implements the method defined in the interface to provide contact logging information and registers the implemented service in the service container of the Sailingease WinForm framework.
Module A, when it is necessary to list the customer's contact record information, simply takes out the icustomercontactservice from the service container and can invoke the method provided by the interface to obtain information, without having to relate to the provider and the person who is the interface.
The Sailingease WinForm Framework enables you to implement many of the services required to develop a. NET platform-based Windows application, such as multi-document window management, context menu management, system environment-related services, and more. Based on these services, you will have easy access to professional Windows applications that are reliable, scalable, and low-coupling configurable.
Rich package of controls
WinForm control development has always been one of the difficulties in the development of. NET Windows applications, the uneven level of developers, the prevalence of the web, making it difficult for businesses or development teams to find talent skilled in the development of WinForm controls, our team is proficient in GDI + when recruiting talent. NET developers are hard to come by. Our Sailingease WinForm Development Framework provides you with the most commonly used and most useful control packages: DataGridView Landscaping, ComboBox beautification, and specially developed ComboBox for complex situations, ImageView for image thumbnail browsing.
Here you can briefly describe several representative control effects and a brief description of our implementation methods
DataGridView
We offer features such as landscaping and search/replace for Microsoft native DataGridView.
The beautified DataGridView gives your application a fairly professional-level visual effect. In addition, we provide cell search replacements, background watermark text, checkbox columns with disabled effects, and image columns that display different images through object type or attribute value mapping.
Some of the source code is structured as follows:
How to adjust the visual effect of DataGridView according to the project needs? by Datagridviewrenderertheme class:
With an independent rendering mechanism, how to customize your own DataGridView visuals believe you are at a glance.
How do I implement search/swap for DataGridView? If you want to integrate this functionality into existing projects, do you need to drastically change existing code? No, you just need to add a line of code to your existing code that uses DataGridView:
Datagridviewsearchpresenter searchpresenter = new Datagridviewsearchpresenter (dataGridView);
You can invoke the public methods provided in Datagridviewsearchpresenter to implement various search and replace functions for cells. Examples of how to use object compositing in polygon-like object programming to provide functionality are many in our framework.
ComboBox
In addition to providing a strong version of the Microsoft native ComboBox, we have completely re-implemented a more beautiful and more functional ComboBox.
The ComboBox we provide is highly scalable for developers, in addition to having a good visual effect. The way to customize the look is similar to the DataGridView appearance customization method mentioned above, which focuses on how to extend the ComboBox. First take a look at the source code structure diagram:
From the source code structure, we can see that our ComboBox is a composite control, the list that is rendered when you click Com Bobox, is implemented by using Selistview. With the Secomboselectortheme class, you can customize the visual effects, and with the Layout functionality provided by Selistview, you can implement a drop-down list of any effect. The Layout implementation of this arbitrary effect, what can be achieved, we might as well take a look at the ImageView control to render the image.
The ImageView control itself is a selistview, but we have implemented a layout specifically for rendering the image, and in this complex layout implementation, we define how the list items are rendered, providing box-selection, single-selection, inverse-selection, and keyboard manipulation functions. Apply this Layout if you want the image thumbnails to be rendered when the ComboBox is expanded for user selection.
With the layout and theme features of Selistview, you can almost achieve a list of any effects and functions.
Extendedwebbrowser
Even Windows applications may inevitably interact with Web pages in some cases.
Clicking "Open Project" or "New project" in the Web page here will invoke the corresponding feature in the WinForm application.
Integrating Web pages into your project, in addition to the possible interactions between business logic and other Web projects, uses Web pages instead of some Windows interfaces, which are not only aesthetically pleasing, but designed to be much less difficult to design than WinForm controls that use GDI +, you only need to design traditional Web pages.
Addressbar
Use a Windows7- like site to navigate your application, with a clear structure, strong functionality, and a professional-level navigation effect.
other typical WinForm controls:
Professional title bar Effect
menu, Context menu Landscaping
Command-line effects
Wizard Framework
The above listed part of the representative part of the WinForm control, there are some minor changes in appearance is only a functional enhancement of the control is not listed, our controls have been professionally designed and meticulous implementation, I believe you can from our previous source code structure and introduction of the understanding, using Sailingease The WinForm framework provides controls that greatly increase the efficiency and professionalism of your application development, making it easy for your project team to develop WinForm applications.
Rich Package of components
The Sailingease WinForm Development Framework provides a number of functional components that may not be directly reflected in the user interface of the project, but are an important part of the framework, such as: Automatic update of HTTP-based applications, AES,DES,MD5 cryptographic algorithm encapsulation, To improve the reflection performance of the cache, object attribute value snapshot/restore function, attribute related functions, the function of class type (type), XML, Zip stream/file package processing, regular expression related functions, The encapsulation implementation of TCP communication and so on.
Part of the source code structure:
All the components in the Sailingease WinForm framework are refined in many years of project practice and can solve many problems encountered in the development of WinForm applications, improve the efficiency of your project development, shorten the development cycle by more than 50%, and save your project cost very well. The good design of the framework itself can also greatly enhance or enhance the robustness of your project.
Building a composite application using the Sailingease WinForm framework (plug-in application)