Example #1
0
        /// <summary>
        /// 将当前的选中控件,执行下对齐操作。
        /// 只是y坐标发生变化,x坐标保持不变
        /// </summary>
        static public void bottomAlign()
        {
            if (set.Count == 0)
            {
                return;
            }

            List <int> sortList = new List <int>();

            foreach (Control c in set)
            {
                sortList.Add(c.Location.Y + c.Height);
            }

            ///取最大值
            int value = sortList.Max();

            ///遍历移动控件位置
            foreach (Control c in set)
            {
                c.Location = new Point(c.Location.X, value - c.Height);
                SVPanel svPanel = c as SVPanel;
                svPanel.setStartPos(c.Location);
            }
        }
Example #2
0
        /// <summary>
        /// 将当前的选中控件,执行右对齐操作。
        /// 只是x坐标发生变化,y坐标保持不变
        /// </summary>
        static public void rightAlign()
        {
            if (set.Count == 0)
            {
                return;
            }

            List <int> sortList = new List <int>();

            foreach (Control c in set)
            {
                sortList.Add(c.Location.X + c.Width);
            }

            ///取最右端的最大x值
            int value = sortList.Max();

            ///遍历并且移动位置
            foreach (Control c in set)
            {
                c.Location = new Point(value - c.Width, c.Location.Y);
                SVPanel svPanel = c as SVPanel;
                svPanel.setStartPos(c.Location);
            }
        }
Example #3
0
        /// <summary>
        /// 将当前的选中控件,执行左对齐操作。
        /// 只是x坐标发生变化,y坐标保持不变
        /// </summary>
        static public void leftAlign()
        {
            if (set.Count == 0)
            {
                return;
            }

            List <int> sortList = new List <int>();

            foreach (Control c in set)
            {
                sortList.Add(c.Location.X);
            }

            ///取x最小值
            int value = sortList.Min();

            ///遍历并且移动位置
            foreach (Control c in set)
            {
                c.Location = new Point(value, c.Location.Y);
                SVPanel svPanel = c as SVPanel;
                svPanel.setStartPos(c.Location);
            }
        }
Example #4
0
 /// <summary>
 /// 所有选中控件执行一个像素的右移操作
 /// </summary>
 static public void right()
 {
     foreach (Control c in set)
     {
         c.Location = new Point(c.Location.X + 1, c.Location.Y);
         SVPanel svPanel = c as SVPanel;
         svPanel.setStartPos(c.Location);
     }
 }
Example #5
0
        //垂直等间距
        static public void vEqual()
        {
            if (set.Count <= 1)
            {
                return;
            }

            //将当前控件进行排序
            List <Control> ctlList = new List <Control>();

            ctlList.AddRange(set);
            ctlList.Sort((a, b) =>
            {
                return(a.Location.Y.CompareTo(b.Location.Y));
            });

            List <int> sortList = new List <int>();
            int        ctlDis   = 0;

            foreach (Control c in ctlList)
            {
                sortList.Add(c.Location.Y);
                sortList.Add(c.Location.Y + c.Height);

                ctlDis += c.Height;
            }

            int distance = sortList.Max() - sortList.Min();
            int dis      = distance - ctlDis;

            if (dis > 0)
            {
                dis /= (ctlList.Count - 1);
            }
            else
            {
                dis = 0;
            }

            int tmpH = sortList.Min();

            for (int i = 0; i < ctlList.Count; i++)
            {
                Control cc = ctlList[i];
                cc.Location = new Point(cc.Location.X, tmpH);
                SVPanel svPanel = cc as SVPanel;
                svPanel.setStartPos(cc.Location);
                tmpH += cc.Height;
                tmpH += dis;
            }
        }
Example #6
0
        /// <summary>
        /// 将当前的选中控件,执行上对齐操作。
        /// 只是y坐标发生变化,x坐标保持不变
        /// </summary>
        static public void topAlign()
        {
            if (set.Count == 0)
            {
                return;
            }

            List <int> sortList = new List <int>();

            foreach (Control c in set)
            {
                sortList.Add(c.Location.Y);
            }

            int value = sortList.Min();

            foreach (Control c in set)
            {
                c.Location = new Point(c.Location.X, value);
                SVPanel svPanel = c as SVPanel;
                svPanel.setStartPos(c.Location);
            }
        }
Example #7
0
        //水平居中
        static public void hCenterAlign()
        {
            if (set.Count == 0)
            {
                return;
            }

            List <int> sortList = new List <int>();

            foreach (Control c in set)
            {
                sortList.Add(c.Location.Y);
                sortList.Add(c.Location.Y + c.Height);
            }

            int middle = (sortList.Min() + sortList.Max()) / 2;

            foreach (Control cc in set)
            {
                cc.Location = new Point(cc.Location.X, middle - cc.Height / 2);
                SVPanel svPanel = cc as SVPanel;
                svPanel.setStartPos(cc.Location);
            }
        }