Preface since the release of silverlight2, many developers have been paying attention to it. Both runtime and tools have brought us many surprises, such as supporting the framework languages Visual Basic, Visual C #, ironruby, ironpython, a series of new features such as JSON, Web Service, WCF, and sockets support. Among them, the most important thing is the cross-browser capability and powerful user interface performance. In the following article, I will use it to design and develop an intelligent Form Designer. Because the first time I came into contact with the Silverlight Development Form Designer, many problems will be encountered in the development and design processes, I will record the entire process of learning new knowledge and solving problems, and communicate and discuss with friends who have the same interests. Please read this article with your friends. This article describes how to use. net2010 developed a Silverlight-based smart Form Designer. I will not introduce the basic Silverlight technology knowledge. If you do not know sliverlight, you can find a lot of related information on Baidu and Google. To recommend three Learning Websites
1. http://www.silverlight.net/(official site)
2, http://silverlight.cn/index.php? Q = node/516 (terrylee Series)
3. http://blog.joycode.com/scottgu/archive/2008/02/29/114918.aspx (Scott Guthrie's series) this series of articles contains the following sections.
- System Scope
- System Design
- Class Design
- XML design
I. System Scope
First, let's define the functions to be completed by the system. Here, the basic functions of smart forms in my imagination can be as follows:
• Graphical form display
• Supports creating, editing, and dragging elements (such as text boxes and drop-down boxes)
• Export the corresponding XML description file from the graphic form
• Display form images based on XML Description files
Note: This article is based on the Program writing progress, the program is constantly improved, and this article will be constantly modified and improved.
The following figure shows the system:
Ii. System Design
According to the system scope section, the Form Designer can be divided into three small parts: Form containers, controls, and design panels, therefore, in general, we need to create three objects to meet the functional requirements of the Form Designer.
• Control: controls are commonly used, such as text labels, text boxes, drop-down boxes, and date controls.
• Form container (form): similar to winform, it is only used for window containers.
• Design panel: Design panel is the container object of form elements.
Next, we will further describe the specific requirements of the three objects:
• Widget functions: 1. Move the widget's position in the center by dragging the mouse; 2. Drag the widget's four-side stroke to change the widget's size; 3. You can move the selected control on the keyboard, bottom, left, and right. 4. You can serialize an object to an XML sequence stream. 5. You can deserialize an XML sequence stream into an object instance and generate a graph.
• Form container: 1. Manage and display all controls in the container; 2. Drag the four-side widget to change the size of the form container; 3. Support the Del key deletion function; 4. Support for CTR + Multiple mouse selection; 5. Support for Object serialization into XML sequence stream; 6. Support deserializing XML sequence stream into object instances and generating images; 7. Establish the logical relationship between sub-elements in the container.
• Design panel: 1. Provides the control toolbox. You can drag or drop a widget in the toolbox to create an instance of the control on the form container. 2. provides functions such as inputting and editing form information; 3. provides functions such as entering, editing, and deleting control information.