Can VS2010 Workflow Designer auto arrange layout?

不想你离开。 提交于 2019-12-22 08:44:18

问题


In VS2010 WF4 workflow designer is there any way to get it to auto arrange the layout? I want to add a new step near the top of a workflow and I can't see any way to easily make room for the new item. The process flow underneath where I want to add the new step is a switch statement with several branches; it doesn't even seem to be possible to multi-select items and move them all down to make room.


回答1:


Sadly, there is no way, other than adding what you want to add and then deleting the .layout file, forcing it to generate a new layout. Make sure you back up the file in case the new arrangement is worse than the old.




回答2:


Expand your DataSet.xsd tree and delete XSS File...

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



回答3:


If you're adventurous, you can run code such as this (back up your XSS file first, this code will overwrite it!). The code will auto-arrange the shapes in the designer neatly. You can tweak the constants for best effect. Their meanings should be obvious.

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);

    }


来源:https://stackoverflow.com/questions/9129522/can-vs2010-workflow-designer-auto-arrange-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!