2012-02-03 108 views
4

在VS2010中WF4工作流設計器有什麼辦法讓它自動安排佈局?我想在工作流程的頂部附近添加一個新步驟,但我無法找到任何方法輕鬆爲新項目騰出空間。下面我要添加新步驟的流程流是一個包含多個分支的switch語句;它似乎不可能多選物品並將它們全部向下移動以騰出空間。VS2010工作流設計器可以自動排列布局嗎?

回答

3

不幸的是,除了添加要添加的內容然後刪除.layout文件外,沒有辦法強制它生成新的佈局。請確保備份文件,以防新安排比舊版更差。

+0

好的,謝謝,我想知道這是否是Visual Studio擴展的市場空白;如果你能得到足夠的信息去做 – 2012-02-03 13:55:31

+0

這肯定會是一個有用的! – 2012-02-03 14:22:27

+2

.layout文件僅存在於WF3中,在WF4中,佈局嵌入在XAML文件中。但除此之外,答案是正確的,你不能。而更糟糕的是,你甚至無法選擇一些活動來拖動團隊。該組選擇是在.NET 4.5中,但是, – Maurice 2012-02-03 14:33:12

2

展開您的DataSet.xsd樹和刪除XSS文件...

DataSet.xsd 
--DataSet.cs 
--DataSet.xsc 
--DataSet.xss <-- Delete this one... 
--DataSet.cs 
--DataSet.Designer.cs 
+0

爲我工作.. – 2014-08-05 17:45:01

+0

WF不使用.xss文件。 DataSets可以,但問題不在於這些。 – hvd 2015-03-20 10:00:44

-1

如果你喜歡冒險,你可以像這樣運行的代碼(首先備份文件的XSS,該代碼將覆蓋它!)。該代碼將自動排列設計器中的形狀。您可以調整常量以獲得最佳效果。他們的含義應該是顯而易見的。

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Xml.Linq; 
using System.Text; 

namespace AutoArrangeXss 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      AutoArrange(yourXssFilePath); 
     } 

    static void AutoArrange(string xssFile) 
    { 
     const int xPad = 80; 
     const int yPad = 20; 
     const int maxY = 1500; 

     XDocument doc = XDocument.Load(xssFile); 
     var ns = doc.Root.Name.Namespace; 

     var shapes = doc.Descendants(ns + "Shape").ToList(); 

     int X = 0; 
     int Y = 0; 
     int columnW = 0; 
     foreach (XElement shape in shapes) 
     { 
      int Height = int.Parse(shape.Attribute("Height").Value); 
      int Width = int.Parse(shape.Attribute("Width").Value); 
      if (Width > columnW) columnW = Width; 

      shape.Attribute("X").Value = X.ToString(); 
      shape.Attribute("Y").Value = Y.ToString(); 

      Y += Height + yPad; 

      if (Y > maxY) 
      { 
       X += columnW + xPad; 
       Y = 0; 
       columnW = 0; 
      } 

     } 

     doc.Save(xssFile); 

    } 
+0

WF不使用.xss文件。 DataSets可以,但問題不在於這些。 – hvd 2015-03-20 10:00:51