WEB开发网
开发学院图形图像Flash 使用silverlight构建一个工作流设计器(十一) 阅读

使用silverlight构建一个工作流设计器(十一)

 2009-05-21 12:08:24 来源:WEB开发网   
核心提示: 6.9 活动对齐功能对于选中的活动,可以按照下面4种方式对齐:l 向左对齐:选中活动的X坐标设置为其中X坐标最小的值,使用silverlight构建一个工作流设计器(十一)(3),l 向右对齐:选中活动的X坐标设置为其中X坐标最大的值,l 向上对齐:选中活动的Y坐标设置为其中X坐标最小的值

6.9 活动对齐功能

对于选中的活动,可以按照下面4种方式对齐:

l         向左对齐:选中活动的X坐标设置为其中X坐标最小的值。

l         向右对齐:选中活动的X坐标设置为其中X坐标最大的值。

l         向上对齐:选中活动的Y坐标设置为其中X坐标最小的值。

l         向下对齐:选中活动的Y坐标设置为其中X坐标最大的值。

为了需要两次遍历选中的活动集合。第一次遍历取得其中X/Y坐标的最小/最大值,第二次遍历设置活动的X/Y坐标为最小/最大值。

代码如下所示:

public void AlignTop()
       {
           if (CurrentSelectedControlCollection == null || CurrentSelectedControlCollection.Count == 0)
               return;
           Activity a = null;
           double minY = 100000.0;
           for (int i = 0; i < CurrentSelectedControlCollection.Count; i++)
           {
               if (CurrentSelectedControlCollection[i] is Activity)
               {
                   a = CurrentSelectedControlCollection[i] as Activity;

                   if (a.CenterPoint.Y < minY)
                       minY = a.CenterPoint.Y;
               }


           }
           for (int i = 0; i < CurrentSelectedControlCollection.Count; i++)
           {
               if (CurrentSelectedControlCollection[i] is Activity)
               {
                   a = CurrentSelectedControlCollection[i] as Activity;
                   a.CenterPoint = new Point(a.CenterPoint.X, minY);
               }


           }
       }
       public void AlignBottom()
       {
           if (CurrentSelectedControlCollection == null || CurrentSelectedControlCollection.Count == 0)
               return;
           Activity a = null;
           double maxY = 0;
           for (int i = 0; i < CurrentSelectedControlCollection.Count; i++)
           {
               if (CurrentSelectedControlCollection[i] is Activity)
               {
                   a = CurrentSelectedControlCollection[i] as Activity;

                   if (a.CenterPoint.Y >maxY)
                       maxY = a.CenterPoint.Y;
               }


           }
           for (int i = 0; i < CurrentSelectedControlCollection.Count; i++)
           {
               if (CurrentSelectedControlCollection[i] is Activity)
               {
                   a = CurrentSelectedControlCollection[i] as Activity;
                   a.CenterPoint = new Point(a.CenterPoint.X, maxY);
               }


           }
       }
       public void AlignLeft()
       {

           if (CurrentSelectedControlCollection == null || CurrentSelectedControlCollection.Count == 0)
               return;
           Activity a = null;
           double minX = 100000.0;
           for (int i = 0; i < CurrentSelectedControlCollection.Count; i++)
           {
               if (CurrentSelectedControlCollection[i] is Activity)
               {
                   a = CurrentSelectedControlCollection[i] as Activity;

                   if (a.CenterPoint.X < minX)
                       minX = a.CenterPoint.X;
               }


           }
           for (int i = 0; i < CurrentSelectedControlCollection.Count; i++)
           {
               if (CurrentSelectedControlCollection[i] is Activity)
               {
                   a = CurrentSelectedControlCollection[i] as Activity;
                   a.CenterPoint = new Point(minX, a.CenterPoint.Y);
               }


           }

          

       }
       public void AlignRight()
       {
           if (CurrentSelectedControlCollection == null || CurrentSelectedControlCollection.Count == 0)
               return;
           Activity a = null;
           double maxX = 0;
           for (int i = 0; i < CurrentSelectedControlCollection.Count; i++)
           {
               if (CurrentSelectedControlCollection[i] is Activity)
               {
                   a = CurrentSelectedControlCollection[i] as Activity;

                   if (a.CenterPoint.X > maxX)
                       maxX = a.CenterPoint.X;
               }


           }
           for (int i = 0; i < CurrentSelectedControlCollection.Count; i++)
           {
               if (CurrentSelectedControlCollection[i] is Activity)
               {
                   a = CurrentSelectedControlCollection[i] as Activity;
                   a.CenterPoint = new Point(maxX, a.CenterPoint.Y);
               }


           }
       }

本文系列索引: 

使用silverlight构建一个图形化流程设计器(一)

使用silverlight构建一个图形化流程设计器(二)

使用silverlight构建一个工作流设计器(三)

使用silverlight构建一个工作流设计器(四)

使用silverlight构建一个工作流设计器(五)

使用silverlight构建一个工作流设计器(六)

使用silverlight构建一个工作流设计器(七)

使用silverlight构建一个工作流设计器(八)

使用silverlight构建一个工作流设计器(九)

使用silverlight构建一个工作流设计器(十)

上一页  1 2 3 

Tags:使用 silverlight 构建

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接