Workflow Foundation 3.5 中的自定义活动设计器:它们如何工作?

发布于 2024-08-30 21:47:31 字数 1741 浏览 2 评论 0原文

这篇文章的意图:

我意识到 Workflow Foundation 在 StackOverflow 上并不是非常受欢迎,并且可能不会有很多答案,或者根本没有。这篇文章旨在为尝试通过自定义设计器类自定义工作流活动外观的人们提供资源。


目标:

我正在尝试为工作流活动创建自定义设计器类,以实现以下目标:

  1. 使活动看起来技术性较低。例如,我不一定希望看到内部对象名称作为活动的“标题”——相反,我希望看到更具描述性的内容。

  2. 在标题文本下方显示某些属性的值。我希望直接在标题下方查看某些属性的值,这样我就不需要查看其他地方(即,在属性窗口)。

  3. 提供自定义放置区域并绘制自定义内部箭头。例如,我希望能够在非常特定的位置提供自定义放置区域。


到目前为止我发现了什么:

我创建了一个从 SequentialActivityDesigner 派生的自定义设计器类,如下所示:

[Designer(typeof(SomeDesigner))]
public partial class SomeActivity: CompositeActivity
{
    ...
}

class PlainDesigner : SequentialActivityDesigner
{
    ...
}

通过重写一些属性和 OnPaint 方法,我发现了以下之间的对应关系属性以及活动的显示方式:

显示 SequentialActivityDesigner 的某些属性与显示的活动之间关系的图表。
图 1. SequentialActivityDesigner 的某些属性与显示的活动之间的关系。

目标#1(使活动看起来技术性较低)和目标#2(在标题文本下方显示属性值)的可能解决方案

  • 可以通过Title属性更改显示的标题。

  • 如果需要更多空间来在标题下方显示附加信息,则可以增加 TitleHeight 属性(即覆盖该属性并使其返回 base.TitleHeight + n code>,其中 n 是某个正整数)。

  • 重写 OnPaint 方法并在通过 TitleHeight 保留的区域中绘制附加文本。


开放问题:

  • 连接器、连接和连接点的用途是什么?它们看起来是必要的,但是有什么目的?

  • 虽然可以通过 GetDropTargets 方法获取放置目标,但这似乎不一定是设计者实际放置放置活动的位置。当在工作流中拖动活动时,设计器会显示绿色的小加号,可以在其中放置活动;它如何确定这些加号的位置?

  • 设计师如何确定在哪里绘制连接线和箭头?

Intent of this post:

I realise that Workflow Foundation is not extremely popular on StackOverflow and that there will probably be not many answers, or none at all. This post is intended as a resource to people trying to customise workflow activities' appearance through custom designer classes.


Goals:

I am attempting to create a custom designer class for Workflow activities to achieve the following:

  1. Make activities look less technical. For example, I don't necessarily want to see the internal object name as the activity's "title" -- instead, I'd like to see something more descriptive.

  2. Display the values of certain properties beneath the title text. I would like to see some properties' values directly underneath the title so that I don't need to look somewhere else (namely, at the Properties window).

  3. Provide custom drop areas and draw custom internal arrows. As an example, I would like to be able to have custom drop areas in very specific places.


What I found out so far:

I created a custom designer class deriving from SequentialActivityDesigner as follows:

[Designer(typeof(SomeDesigner))]
public partial class SomeActivity: CompositeActivity
{
    ...
}

class PlainDesigner : SequentialActivityDesigner
{
    ...
}

Through overriding some properties and the OnPaint method, I found out about the following correspondences between the properties and how the activity will be displayed:

Diagram showing the relationships between some properties of a SequentialActivityDesigner and the displayed activity.

Figure 1. Relationship between some properties of an SequentialActivityDesigner and the displayed activity.

Possible solutions for goal #1 (make activities look less technical) and goal #2 (display values of properties beneath title text):

  • The displayed title can be changed through the Title property.

  • If more room is required to display additional information beneath the title, the TitleHeight property can be increased (ie., override the property and make it return base.TitleHeight + n, where n is some positive integer).

  • Override the OnPaint method and draw additional text in the area reserved through TitleHeight.


Open questions:

  • What are the connectors, connections, and connection points used for? They seem to be necessary, but for what purpose?

  • While the drop targets can be got through the GetDropTargets method, it seems that this is not necessarily where the designer will actually place dropped activities. When an activity is dragged across a workflow, the designer displays little green plus signs where activities can be dropped; how does it figure out the locations of these plus signs?

  • How does the designer figure out where to draw connector lines and arrows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随梦而飞# 2024-09-06 21:47:31

除非您有非常非常充分的理由将大量资金(这将是大量)投入到 WF 3.5 中,否则不要这么做。请改用 WF4。 WF4 使您能够更好地控制使用 WPF Xaml 呈现的活动的外观。

WF 3.5 技术性很强,对用户来说非常可怕。 WF4 旨在解决这些问题,这似乎符合您的目标。

Unless you have a really, really good reason to pour massive amounts (and this is going to be massive) into WF 3.5 then don't. Use WF4 instead. WF4 gives you much more control over the appearance of the activities being rendered using Xaml by WPF.

WF 3.5 was very technical and very scary to a user. WF4 is designed to address those issues and that seems in line with your goals.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文