// 在撤消操作中,如果碰到删除的操作,需要在撤消时重新增加回来 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; } }
/// <summary> /// 当用户点击焦点拖动时候改变控件的大小 /// </summary> /// <param name="pFocus"></param> /// <param name="pPoint"></param> public void MoveByDragFocus(FocusHandleCTL pFocus, Point pFirst, Point pLast) { int width = pLast.X - pFirst.X, height = pLast.Y - pFirst.Y; foreach (DesignControl ctl in this) { if (ctl.IsSelected) { Rectangle dt = new Rectangle(new Point(ctl.Left, ctl.Top), ctl.Size); dt = ReSetCtlDragFrame(pFocus.FocusType, dt, width, height); // if(dt.Left <=0) dt.Location = new Point(0,dt.Top); // if(dt.Top <=0) dt.Location = new Point(dt.Left ,0); // if(dt.Right >=_Section.Width) dt.Width = _Section.Width - dt.Left ; // if(dt.Bottom >=_Section.Height)dt.Height = _Section.Height -dt.Top ; DIYReport.Interface.IRptSingleObj dataObj = ctl.DataObj; dataObj.BeginUpdate(); dataObj.Location = dt.Location; dataObj.Size = dt.Size; dataObj.EndUpdate(); } } }
/// <summary> /// 转换为Diyreport 设计需要的控件格式。 /// </summary> /// <returns></returns> public IList DataToIList() { TrackEx.Write("正在加载自定义报表组件:" + ReportXmlHelper.REPORT_ASSEMBLY); System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(DIYReport.ReportXmlHelper.REPORT_ASSEMBLY); TrackEx.Write("自定义报表组件加载成功!"); ArrayList ctlList = new ArrayList(); foreach (MySingleRptCtlData ctl in _Ctls) { DIYReport.Interface.IRptSingleObj rptObj = asm.CreateInstance(ctl.CtrlFullName) as DIYReport.Interface.IRptSingleObj; if (rptObj == null) { continue; } rptObj.BeginUpdate(); setRptCtlProperties(rptObj, ctl.PropertyList); rptObj.EndUpdate(); ctlList.Add(rptObj); } return(ctlList); }
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; }