Recently, when using the workflow designer, a problem occurs. When you select an activity in the workflow, you must highlight it, not just a selection handle. The problem seems to be very simple. The simplest way to control the activity color is Activitydesignertheme You can also Designer In Onpaint Method, but I do not like this :).
In Designer. Of Onpaint Method Designer . Designer Of Designertheme You can directly obtain the design style for the attribute, and then Backcolorstart And Backcolorend Assigned a value to run... in full expectation ....... However, the system provides an exception with the following content:" Theme properties can only be changed in the theme configuration dialog. "; Then create a new Theme To Designer How? The answer is no, because Designertheme The attribute is read-only. This exploitation Theme But I didn't give up.
I took a closer look. Theme In Getbackgroundbrush Method.System. Drawing. drawing2d.Lineargradientbrush Type brush. Can I change the color of the brush? I tried it. Linearcolors Assigned value and run. The results are exciting!
Another unsolved problem is to determine whether the activity is selected. Designer There is an attribute Isselected , In Designer In Onpaint .
To sum up, if you only want to change the style at runtime, you cannot directly change the style attribute provided by the style, we can get the pen, brush, and other lower-level objects related to the drawing provided by the style, and then set them accordingly. For fonts Theme Moderate Font . If you are busy at work, try other tasks on your own.
For rehosting WWF designerArticle Please refer to my other articles:
Some technical details and Application Experience of WWF (1)
Some technical details and Application Experience of WWF (2)
Custom activity appearance during running of the rehosting WWF designer
Rehosting WWF designer-custom activity exterior
Rehosting WWF designerp drag activity from toolbox to designer
Rehosting WWF designer