Building a workflow designer with Silverlight (12)

Source: Internet
Author: User

Source code Download: http://www.shareidea.net/opensource.htm

Online Demo: http://www.shareidea.net/workflow.htm

Video Tutorials: http://www.shareidea.net/video/sharedesigner/sharedesigner.html

This chapter contains the following:

L New Active graphics, graphics more clear and beautiful.

L Increase the support of the next key (select activity or rule, use the arrow keys to move, hold down CTRL, the distance increases each time). However, there is a problem, can not capture the arrow keys of the press event, but to catch the release of mouse events, I do not know why

• To achieve the changing skin approach we covered in chapter tenth.

The two-point update above this chapter has no value to say, below to implement the method of changing the skin as we speak in the tenth chapter,

If you do not understand the principle of changing skin, please refer to chapter tenth.

Eight, the realization change skin function

We do experiments on the Activity.xaml class, and the steps are as follows:

1. First we take the Activity.g.cs (located under the obj "Debug" designer folder) in the Activity.xaml.cs file that copies the class variables and InitializeComponent methods. The code looks like this:

Internal System.Windows.Controls.Canvas container;
Internal System.Windows.Controls.ToolTip Ttactivitytip;
Internal System.Windows.Shapes.Ellipse eicenterellipse;
Internal Shareidea.Web.UI.Control.Workflow.Designer.ActivityPictureContainer sdpicture;
private bool _contentloaded;
[System.Diagnostics.DebuggerNonUserCodeAttribute ()]
public void InitializeComponent ()
{
if (_contentloaded)
{
Return
}
_contentloaded = true;
System.Windows.Application.LoadComponent (This, new System.Uri ("/sharedesigner;component/designer/activity.xaml"), System.UriKind.Relative));
This.container = ((System.Windows.Controls.Canvas) (this. FindName ("container"));
This.ttactivitytip = ((SYSTEM.WINDOWS.CONTROLS.TOOLTIP) (this. FindName ("Ttactivitytip"));
This.eicenterellipse = ((System.Windows.Shapes.Ellipse) (this. FindName ("Eicenterellipse"));
This.sdpicture = ((Shareidea.Web.UI.Control.Workflow.Designer.ActivityPictureContainer) (this. FindName ("Sdpicture"));
}

2. Then compile the code, and there will be an error, saying that the same variables and methods already exist. This is because the same code exists in the Activity.xaml.cs and Activity.g.cs files. We remove all Activity.g.cs content, compile again, OK, pass.

3. Although the compilation passed, but the InitializeComponent code can not set breakpoints, because the property is set

[System.Diagnostics.DebuggerNonUserCodeAttribute ()]

This property is used to indicate a type or member that does not belong to the application user code, and this property tells Vs.net that the debugging mechanism will not enter this section of code. Let's comment out this attribute and then run it again.

4. Next, create a new activity skin file. Through the Vs.net class browser, we copy the Activity.xaml file, and the new copy of the file is named Activity2.xaml.

5. Then compile the code, there is an error, because the automatically generated Activity2.g.cs file contains some code, we empty the Activity2.g.cs, and then compile. Ok, pass.

6. Modify the Activity2.xaml style to distinguish it from Activity.xaml.

7. Modify the System.Windows.Application.LoadComponent in the Activity.xaml.cs file (this, new System.Uri ("/sharedesigner;component/ Designer/activity.xaml ", System.UriKind.Relative)" method,/activity.xaml modified to/activity2.xaml, so as to load the new skin Activity2.xaml file.

Finally run the code, you can see, using the new Activity2.xaml file.

This allows us to dynamically load the specified skin by changing the second parameter of the System.Windows.Application.LoadComponent.

So far, we've completed a code that changes the skin. But there are some places to think deeply.

1, if there are a lot of skin, then do not want users to download all the skin files at the first time, this will increase the user wait time, if you can dynamically download Xmal code from the network is good, but has not found this method.

2, the above method does not make. Xmal and Xaml.cs files are not associated, we can manually cut Xaml.cs files to other files, and the skin file (. xmal file) in a separate folder, easy to manage.

3, automatically generated. g.cs file can you get rid of it? This file is generated automatically at compile time and is located under the obj "Debug" designer folder.

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.