// 在撤消操作中,如果碰到删除的操作,需要在撤消时重新增加回来
        public void Add(IList pObjList)
        {
            DesignControl last         = null;
            int           selectHeight = this.Section.DataObj.Height;

            for (int i = 0; i < pObjList.Count; i++)
            {
                DIYReport.Interface.IRptSingleObj data = pObjList[i] as DIYReport.Interface.IRptSingleObj;
                data = data.Clone() as DIYReport.Interface.IRptSingleObj;

                if (data.Location.Y + data.Size.Height > selectHeight)
                {
                    selectHeight = data.Location.Y + data.Size.Height;
                }

                DesignControl ctl = new DesignControl(data as DIYReport.Interface.IRptSingleObj);

                data.EndUpdate();

                ctl.IsSelected = true;
                //ctl.IsMainSelected = true;
                this._DataObj.Add(data);
                this.Add(ctl);
                last = ctl;
            }
            if (last != null)
            {
                SetMainSelected(last);
                ShowFocusHandle(true);
            }
            if (selectHeight > this.Section.DataObj.Height)
            {
                this.Section.DataObj.Height = selectHeight;
            }
        }
        //在撤消操作中,如果碰到增加的操作,需要在撤消时删除掉
        public void Remove(IList pObjList)
        {
            int i = 0;

            while (i < this.Count)
            {
                if (this[i] == null)
                {
                    break;
                }
                bool          b   = false;
                DesignControl ctl = this[i] as DesignControl;
                for (int j = 0; j < pObjList.Count; j++)
                {
                    DIYReport.Interface.IRptSingleObj data = pObjList[j] as DIYReport.Interface.IRptSingleObj;
                    if (data != null && ctl.DataObj.Name == data.Name)
                    {
                        removeCtl(ctl);
                        b = true;
                    }
                }
                if (!b)
                {
                    i++;
                }
            }
        }
        /// <summary>
        /// 通过鼠标选择控件 ,
        /// </summary>
        /// <param name="pRect"></param>
        public void SelectCtlByMouseRect(Rectangle pRect)
        {
            Rectangle     mousRect      = _Section.RectangleToClient(pRect);
            DesignControl lastSelectCtl = null;

            foreach (DesignControl ctl in this)
            {
                Rectangle rect = Rectangle.Intersect(mousRect, new Rectangle(ctl.Location, ctl.Size));
                bool      b    = rect != Rectangle.Empty;
                if (b)
                {
                    ctl.IsMainSelected = false;
                    ctl.IsSelected     = b;
                    lastSelectCtl      = ctl;
                }
                else
                {
                    if (DesignEnviroment.PressCtrlKey != true && DesignEnviroment.PressShiftKey != true)
                    {
                        ctl.IsSelected = false;
                    }
                }
            }
            if (lastSelectCtl != null)
            {
                lastSelectCtl.IsMainSelected = true;

                DesignEnviroment.CurrentRptObj = lastSelectCtl.DataObj;
            }
        }
        int IComparer.Compare(Object x, Object y)
        {
            DesignControl xObj = x as DesignControl;
            DesignControl yObj = y as DesignControl;

            return((new CaseInsensitiveComparer()).Compare(xObj.Top, yObj.Top));
        }
 /// <summary>
 /// 设置当前鼠标下的控件
 /// </summary>
 /// <param name="pCtl"></param>
 public void SetMainSelected(DesignControl pCtl)
 {
     foreach (DesignControl ctl in this)
     {
         ctl.IsMainSelected = false;
     }
     pCtl.IsMainSelected = true;
 }
Example #6
0
        public FocusHandleList(DesignControl pControl)
        {
            _DesignCtl = pControl;

            //再增加焦点边框
            //_CtlRect = new Rectangle(rect.X - FUDGER ,rect.Y -FUDGER  ,rect.Width + 2*FUDGER  ,rect.Height + 2*FUDGER  );
            create8Focus();
        }
        /// <summary>
        /// 格式化选择的控件
        /// </summary>
        /// <param name="pCurrentCtl"></param>
        /// <param name="pType"></param>
        public void FormatCtl(FormatCtlType pType)
        {
            DesignControl ctl = GetMainSelectedCtl();

            if (ctl != null)
            {
                FormatCtl(new Rectangle(ctl.Location, ctl.Size), pType);
            }
        }
 public DesignControl Add(DesignControl pControl)
 {
     pControl.DeControlList = this;
     //增加到要处理的集合中
     base.Add(pControl);
     //这个是增加到界面上
     _Section.DeControls.Add(pControl);
     return(pControl);
 }
Example #9
0
        //格式化选择的控件
        private void FormatCtl(CommandID cmdID)
        {
            DesignControl ctl = DesignerHost.SectionList.GetActiveSection().DesignControls.GetMainSelectedCtl();

            if (ctl != null)
            {
                FormatCtl(new Rectangle(ctl.Location, ctl.Size), cmdID);
            }
        }
 public DesignControlList(DIYReport.UserDIY.DesignSection pSection)
 {
     _Section = pSection;
     _DataObj = pSection.DataObj.RptObjList;
     foreach (DIYReport.Interface.IRptSingleObj obj in _DataObj)
     {
         DesignControl ctl = new DesignControl(obj);
         this.Add(ctl);
     }
 }
        public void CreateControl(string pDispText, bool pChangeRect, DIYReport.ReportModel.RptObjType pType, Point pFirst, Point pLast)
        {
            Rectangle rect = PublicFun.ChangeMousePointToRect(pFirst, pLast);

            Rectangle mousRect = pChangeRect?_Section.RectangleToClient(rect):rect;

            DIYReport.Interface.IRptSingleObj data = _DataObj.AddByType(pType, pDispText, _Section.DataObj);
            if (data == null)
            {
                return;
            }

            DesignControl ctl = new DesignControl(data);

            ctl.BringToFront();

            data.BeginUpdate();
            data.Location = new Point(mousRect.Left, mousRect.Top);
            data.Size     = mousRect.Size;
            data.EndUpdate();

            ctl.IsSelected     = true;
            ctl.IsMainSelected = true;
            this.Add(ctl);
            //判断是否通过鼠标来创建
            if (pChangeRect)
            {
                //ArrayList unList = new ArrayList();
                //object cUnData = data.Clone();
                //DIYReport.TrackEx.Write(cUnData!=null,"由于程序特殊的需要,该报表对象需要提供Clone() 的方法。");
                //if(cUnData!=null){
                //    unList.Add(cUnData);
                //    _UndoMgr.Store("新建报表控件",unList,this,DIYReport.UndoManager.ActionType.Add);
                //}
            }
            DesignEnviroment.CurrentRptObj = data;
        }
 private void removeCtl(DesignControl pCtl)
 {
     //判断是否为图片文件并销毁图片
     if (pCtl.DataObj.Type == DIYReport.ReportModel.RptObjType.Image)
     {
         DIYReport.ReportModel.RptObj.RptPictureBox pic = pCtl.DataObj  as DIYReport.ReportModel.RptObj.RptPictureBox;
         if (pic.Image != null)
         {
             pic.Image.Dispose();
         }
     }
     //删除控件数据集合中的
     _DataObj.Remove(pCtl.DataObj);
     //从Section界面中删除8个热点
     foreach (FocusHandleCTL focus in pCtl.FocusList)
     {
         _Section.DeControls.Remove(focus);
     }
     pCtl.FocusList.Clear();
     //删除Section 上的控件集合(界面上的控件)
     _Section.DeControls.Remove(pCtl);
     //删除当前集合中的对该对象的引用
     base.Remove(pCtl);
 }
        /// <summary>
        /// 把当前选择的控件删除掉
        /// </summary>
        public void RemoveSelectedControl()
        {
            int       i      = 0;
            ArrayList unList = new ArrayList();

            while (i < this.Count)
            {
                if (this[i] == null)
                {
                    break;
                }
                DesignControl ctl = this[i] as DesignControl;
                if (ctl.IsSelected)
                {
                    //unList.Add( ctl.DataObj.Clone());
                    removeCtl(ctl);
                }
                else
                {
                    i++;
                }
            }
            //_UndoMgr.Store("移除报表控件",unList,this,DIYReport.UndoManager.ActionType.Remove);
        }