示例#1
0
        public void Group(object sender, EventArgs e)
        {
            if (_selectedObjs.Count > 1)
            {
                //需要排序,否则绘图的先后顺序会发生改变
                int[] indexA = new int[_selectedObjs.Count];
                for (int i = 0; i < indexA.Length; i++)
                {
                    indexA[i] = Objs.IndexOf(_selectedObjs[i]);
                }
                Array.Sort(indexA);
                List <IDrawObj> groupL = indexA.Select(t => Objs[t]).ToList();
                DrawGroup       group  = new DrawGroup(groupL);
                _nameManager.CreateName(group);
                group.Layer = DefaultLayer;
                group.LoadInitializationEvent();

                foreach (IDrawObj obj in _selectedObjs)
                {
                    Objs.Remove(obj);
                }
                Objs.Insert(indexA[0], group);
                _selectedObjs.Clear();
                if (group.CanSelect())
                {
                    _selectedObjs.Add(group);
                }

                _controlPoint.ChangeSelectObj(_selectedObjs);
                Container.Invalidate();
            }
        }
示例#2
0
        /// <summary>
        /// 合并
        /// </summary>
        public void Combine()
        {
            if (_selectedObjs.Count > 1)
            {
                //需要排序,否则绘图的先后顺序会发生改变
                int[] indexA = new int[_selectedObjs.Count];
                for (int i = 0; i < indexA.Length; i++)
                {
                    indexA[i] = Objs.IndexOf(_selectedObjs[i]);
                }
                Array.Sort(indexA);

                DrawCombine draw = new DrawCombine(_selectedObjs)
                {
                    Parant = Container
                };
                _nameManager.CreateName(draw);
                draw.Layer = DefaultLayer;
                draw.LoadInitializationEvent();

                foreach (IDrawObj obj in _selectedObjs)
                {
                    Objs.Remove(obj);
                }
                Objs.Insert(indexA[0], draw);
                _selectedObjs.Clear();
                if (draw.CanSelect())
                {
                    _selectedObjs.Add(draw);
                }

                _controlPoint.ChangeSelectObj(_selectedObjs);
                Container.Invalidate();
            }
        }
示例#3
0
        public void Back(object sender, EventArgs e)
        {
            IDrawObj obj   = _selectedObjs[0];
            int      index = Objs.IndexOf(obj);

            if (index > 0)
            {
                Objs.Remove(obj);
                Objs.Insert(index - 1, obj);
                obj.Invalidate();
            }
        }
示例#4
0
        public void Front(object sender, EventArgs e)
        {
            IDrawObj obj   = _selectedObjs[0];
            int      index = Objs.IndexOf(obj);

            if (index != Objs.Count - 1)
            {
                Objs.Remove(obj);
                Objs.Insert(index + 1, obj);
                obj.Invalidate();
            }
        }
示例#5
0
        public void UnGroup(object sender, EventArgs e)
        {
            DrawGroup group = null;

            foreach (IDrawObj obj in _selectedObjs)
            {
                if (obj.Type != DrawType.Group)
                {
                    continue;
                }

                group = (DrawGroup)obj;
                group.Ungroup();
                int index = Objs.IndexOf(group);
                Objs.Remove(group);
                Objs.InsertRange(index, group.ObjList);
            }

            if (group != null)
            {
                //去除锁定的控件
                int count = group.ObjList.Count;
                for (int i = count - 1; i >= 0; i--)
                {
                    IDrawObj obj = group.ObjList[i];
                    if (!group.ObjList[i].CanSelect())
                    {
                        group.ObjList.Remove(obj);
                    }
                }

                _selectedObjs.Clear();
                _selectedObjs.AddRange(group.ObjList);

                _controlPoint.ChangeSelectObj(_selectedObjs);
                Container.Invalidate();
            }
        }