2011-10-28 86 views
0

你好我創建與C#4.0 WWF工作流程,我遇到了一些問題:工作流程連接顯示奇怪

我的測試代碼:

Flowchart flow = new Flowchart 
{ 
    DisplayName = "Test", 
    StartNode = new FlowSwitch<String> { Expression = "[prop1]" }, 
    Variables = { new Variable<String> { Name = "prop1" } }, 
}; 
FlowNode MySwitch = flow.StartNode; 
flow.Nodes.Add(MySwitch); 

我保存它:

StreamWriter sw = File.CreateText(@"../../test.xaml"); 
var xmlWriter = XmlWriter.Create(sw, 
    new XmlWriterSettings { Indent = true, OmitXmlDeclaration = false }); 
    using (xmlWriter) 
    { 
     var xamlXmlWriter = new XamlXmlWriter(xmlWriter, new XamlSchemaContext()); 
     using (xamlXmlWriter) 
     { 
      XamlWriter xamlWriter = ActivityXamlServices.CreateBuilderWriter(xamlXmlWriter); 
      using (xamlWriter) 
      { 
       var activityBuilder = new ActivityBuilder { Name = "Test", Implementation = Workflow }; 
       XamlServices.Save(xamlWriter, activityBuilder); 
      } 
     } 
    } 
    sw.Close(); 

,然後我得到這個XAML:

<?xml version="1.0" encoding="utf-8"?> 
<Activity x:Class="Test" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <Flowchart DisplayName="Test"> 
    <Flowchart.Variables> 
     <Variable x:TypeArguments="x:String" Name="prop1" /> 
    </Flowchart.Variables> 
    <Flowchart.StartNode> 
     <x:Reference>__ReferenceID0</x:Reference> 
    </Flowchart.StartNode> 
    <FlowSwitch x:TypeArguments="x:String" x:Name="__ReferenceID0" Expression="[prop1]" /> 
    </Flowchart> 
</Activity> 

,當我在Visual Studio中加載它,我得到這個工作流程:

My Workflow

我認爲這是錯誤的,因爲從「開始」節點開始弧應該是下面的框中,而不是結束!

如果我添加其他步驟,他們都只使用超過位置連接。

我在做什麼錯了?

+0

老實說,你不需要在標題中加標籤。你已經擁有了他們所屬的地方*。另外,我認爲你沒有做錯什麼;編輯只是沒有就繪製連接線的地方做出正確的決定。只需打開一個連接並要求他們修復其佈局邏輯。 – Will

回答

0

編輯器首次打開活動的XAML時僅使用它的默認值,因爲它沒有可用的視圖狀態。

如果通過設計師編輯,視圖狀態屬性(即設計師的大小,位置等)被添加到XAML:

<Activity mc:Ignorable="sap" x:Class="Test" sap:VirtualizedContainerService.HintSize="654,676" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <Flowchart DisplayName="Test" sad:XamlDebuggerXmlReader.FileName="c:\users\jp-correia\desktop\WorkflowConsoleApplication1\WorkflowConsoleApplication1\test.xaml" sap:VirtualizedContainerService.HintSize="614,636" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces"> 
    <Flowchart.Variables> 
     <Variable x:TypeArguments="x:String" Name="prop1" /> 
    </Flowchart.Variables> 
    <sap:WorkflowViewStateService.ViewState> 
     <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
     <x:Boolean x:Key="IsExpanded">False</x:Boolean> 
     <av:Point x:Key="ShapeLocation">240,72.5</av:Point> 
     <av:Size x:Key="ShapeSize">60,75</av:Size> 
     <av:PointCollection x:Key="ConnectorLocation">240,110 150,110 150,192.5</av:PointCollection> 
     </scg:Dictionary> 
    </sap:WorkflowViewStateService.ViewState> 
    <Flowchart.StartNode> 
     <FlowSwitch x:TypeArguments="x:String" x:Name="__ReferenceID0" Expression="%[prop1]" sap:VirtualizedContainerService.HintSize="60,75"> 
     <sap:WorkflowViewStateService.ViewState> 
      <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
      <av:Point x:Key="ShapeLocation">120,192.5</av:Point> 
      <av:Size x:Key="ShapeSize">60,75</av:Size> 
      </scg:Dictionary> 
     </sap:WorkflowViewStateService.ViewState> 
     </FlowSwitch> 
    </Flowchart.StartNode> 
    <x:Reference>__ReferenceID0</x:Reference> 
    </Flowchart> 
</Activity> 

也許你可以工作了一些與WorkflowViewStateService直接,但它會肯定會讓你陷入麻煩。我會避免搞砸它。

你的情況是什麼?也許你應該使用一個rehosted設計師來完成你想要完成的任何事情。