繁体   English   中英

Windows Workflow Sequence活动的设计器源代码是否可供参考?

[英]Is the designer source code for Windows Workflow Sequence activity available for reference?

Re-sharper可以从Workflow中找到Sequence活动本身的源代码。 在环顾System.Activities dll时,我的项目引用没有看到设计器是如何链接的。 我应该在某处找到对AttributeTableBuilder的引用,并调用AddCustomAttributes,就像使用自定义设计器进行的活动一样。

Internet上是否可以找到Sequence活动设计器的设计器源代码? 我希望对此进行研究,以了解Microsoft如何设计Sequence UI。 我尝试使用Google搜索,但只发现了有关构建自定义活动设计器的信息。

如果要实现与内置Sequence Activity相同的功能,则“自定义活动”是正确的选择,并且应使用WorkflowItemsPresenter,此示例将结果显示为内置Sequence Activity:
活动设计师xaml:

<sap:ActivityDesigner x:Class="ProjectForm2.ActivityDesigner1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation">
<sap:ActivityDesigner.Resources>
     <Style x:Key="WorkflowItemsPresenterStyle" TargetType="sap:WorkflowItemsPresenter">
            <Setter Property="SpacerTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Border Background="Transparent">
                            <Path Data="F1M181.297,177.841L181.205,177.746 181.385,177.563 202.804,156.146 202.804,135.07 178.497,159.373 170.847,167.026 170.666,167.205 163.107,159.653 138.804,135.345 138.804,156.42 160.219,177.841 170.76,188.379 181.297,177.841z" 
                      Stretch="Uniform" Fill="#FFDEDDDD" 
                      Width="15" Height="15" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5"/>
                        </Border>

                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate >
                        <StackPanel  Orientation="Vertical"/>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
        </Style>
</sap:ActivityDesigner.Resources>
<Grid>
    <Grid.Resources>

    </Grid.Resources>
    <sap:WorkflowItemsPresenter Style="{StaticResource WorkflowItemsPresenterStyle}" AllowDrop="True"   Items="{Binding Path=ModelItem.Activities}"  HintText="Insert here">

    </sap:WorkflowItemsPresenter>
</Grid>

活动课:

  [Designer(typeof(ActivityDesigner1))]
  public sealed class CodeActivity1 : CodeActivity
{
    public CodeActivity1()
    {
          Activities = new List<Activity>();
        Activities.Add(new Assign());
        Activities.Add(new Assign());
    }
   public List<Activity> Activities { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
    }
}

该设计器存在于System.Activities.Core.Presentation.dll中,如果将其添加到使用的项目中,则可以使用Re-Sharper浏览到:System.Activities.Core.Presentation.SequenceDesigner

设计器通过DesignerMetadata类中的AtributeTableBuilder映射:System.Activities.Core.Presentation.DesignerMetadata

您还可以在以下位置查看c#代码: http : //referencesource.microsoft.com/#System.Activities.Core.Presentation/System/Activities/Core/Presentation/SequenceDesigner.xaml.cs

我后来发现的一种有趣的方法是,您可以直接使用此答案中概述的序列设计器。

我仍然没有找到实际的XAML。...看到真实的东西会很有趣。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM