【问题标题】:Can VS2010 Workflow Designer auto arrange layout?VS2010 Workflow Designer 可以自动排列布局吗?
【发布时间】:2012-02-03 13:39:33
【问题描述】:

在 VS2010 WF4 工作流设计器中,有没有办法让它自动排列布局?我想在工作流顶部附近添加一个新步骤,但我看不到任何方法可以轻松地为新项目腾出空间。我要添加新步骤的下面的流程是一个带有多个分支的 switch 语句;甚至似乎不可能多选项目并将它们全部向下移动以腾出空间。

【问题讨论】:

    标签: .net visual-studio-2010 workflow-foundation-4


    【解决方案1】:

    遗憾的是,除了添加您要添加​​的内容然后删除 .layout 文件,强制它生成新的布局之外,没有其他办法。请务必备份文件,以防新安排比旧安排差。

    【讨论】:

    • 好的,谢谢,我想知道这是否是 Visual Studio 扩展的市场空白;如果你能掌握足够的信息来做到这一点
    • 这肯定有用!
    • .layout 文件仅存在于 WF3 中,在 WF4 中,布局嵌入在 XAML 文件中。但除此之外,答案是正确的,你不能。更糟糕的是,您现在甚至无法分组选择一些活动来拖动一个组。不过,组选择将出现在 .NET 4.5 中,
    【解决方案2】:

    展开您的 DataSet.xsd 树并删除 XSS 文件...

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

    【讨论】:

    • WF 不使用 .xss 文件。数据集可以,但问题不在于这些。
    【解决方案3】:

    如果你喜欢冒险,你可以运行这样的代码(先备份你的 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);
    
        }
    

    【讨论】:

    • WF 不使用 .xss 文件。数据集可以,但问题不在于这些。
    • 虽然这不能回答发布的问题,但这确实对我有帮助,所以谢谢。
    猜你喜欢
    • 2013-07-31
    • 1970-01-01
    • 2012-09-12
    • 2011-03-30
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 2016-01-01
    相关资源
    最近更新 更多