Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 创建一个页面新的ID号
        /// </summary>
        public UInt16 createID()
        {
            if (this.Parent == null)
            {
                return(0);
            }

            HashSet <UInt16> idList = new HashSet <UInt16>();

            foreach (var item in this.Parent.Controls)
            {
                SVPanel panel = item as SVPanel;
                if (panel == null)
                {
                    continue;
                }

                idList.Add(panel.Id);
            }

            for (UInt16 i = 1; i < 10000; i++)
            {
                if (!idList.Contains(i))
                {
                    this.Id = i;
                    return(i);
                }
            }

            return(0);
        }
Ejemplo n.º 5
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);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 移动与当前控件都被选中的兄弟控件
        /// </summary>
        /// <param oldName="control">当前选中控件</param>
        /// <param oldName="x">在x方向上的偏离值</param>
        /// <param oldName="y">在y方向上的偏离值</param>
        static public void moveSelectControls(Control control, int cX, int cY)
        {
            var Parent = control.Parent;

            foreach (var item in set)
            {
                SVPanel panel = item as SVPanel;
                if (panel == null)
                {
                    continue;
                }

                Int32 disX = cX + panel.Location.X;
                Int32 disY = cY + panel.Location.Y;

                if (disX < 0)
                {
                    disX = 0;
                    cX   = -panel.Location.X;
                }

                if (disY < 0)
                {
                    disY = 0;
                    cY   = -panel.Location.Y;
                }

                if (disX + panel.Width > Parent.Width)
                {
                    disX = Parent.Width - panel.Width;
                    cX   = disX - panel.Location.X;
                }

                if (disY + panel.Height > Parent.Height)
                {
                    disY = Parent.Height - panel.Height;
                    cY   = disY - panel.Location.Y;
                }
            }

            foreach (var item in set)
            {
                SVPanel panel = item as SVPanel;
                if (panel == null)
                {
                    continue;
                }

                panel.Location = new Point(panel.Location.X + cX, panel.Location.Y + cY);
                //panel.clearFocus();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 控件在移动过程中进行释放,将释放过程执行保存
        /// </summary>
        static public void moveSelectMouseUp()
        {
            foreach (var item in set)
            {
                SVPanel panel = item as SVPanel;
                if (panel == null)
                {
                    continue;
                }

                panel.SizeChangedEvent();
            }
        }
Ejemplo n.º 8
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;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 将当前复制列表中的控件,放到指定的月诶安窗口中
        /// </summary>
        static public void pasteOperator()
        {
            ///一个临时列表
            List <Control> vTmp = new List <Control>();

            foreach (Control ctrl in copyList)
            {
                SVPanel svPanel = ctrl as SVPanel;
                vTmp.Add((Control)svPanel.cloneObject());
            }

            ///粘贴事件的发送
            PasteEvent(vTmp);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 将当前选中列表中的控件存放到复制列表中
        /// </summary>
        static public void copyOperator()
        {
            if (set.Count == 0)
            {
                return;
            }

            copyList.Clear();
            foreach (Control ctrl in set)
            {
                SVPanel svPanel = ctrl as SVPanel;
                copyList.Add((Control)svPanel.cloneObject());
            }
            CopyEvents(new List <Control>(set));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 将所有选中的控件进行反选
        /// </summary>
        static public void clearSelectControls()
        {
            List <Control> tmp = new List <Control>(set);

            foreach (var item in tmp)
            {
                SVPanel panel = item as SVPanel;
                if (panel == null)
                {
                    continue;
                }

                panel.Selected = false;
            }

            set.Clear();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 对全局中的选中控件执行删除操作
        /// </summary>
        static public void removeOperator()
        {
            List <Control> tmp = new List <Control>();

            tmp.AddRange(set);

            ///删除控件并回收ID号
            foreach (Control ctrl in tmp)
            {
                SVPanel sv = (SVPanel)ctrl;
                sv.Selected = false;
                ctrl.Parent.Controls.Remove(ctrl);
            }

            ///清空选中状态
            set.Clear();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 将当前选中列表中的控件存放到复制列表中,并删除选中列表中的控件
        /// </summary>
        static public void cutOperator()
        {
            ///如果没有任何控件选中,就什么都不会执行
            if (set.Count == 0)
            {
                return;
            }

            ///存放到复制列表中
            copyList.Clear();
            foreach (Control ctrl in set)
            {
                SVPanel svPanel = ctrl as SVPanel;
                copyList.Add(svPanel);
            }

            //删除当前选中项
            removeOperator();
        }
Ejemplo n.º 14
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);
            }
        }
Ejemplo n.º 15
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);
            }
        }