private void OnBeforeRemoveSection(RptSection arg) { if (_BeforeRemoveSection != null) { _BeforeRemoveSection(this, arg); } }
/// <summary> /// 绘制报表的Section /// </summary> /// <param name="g"></param> /// <param name="pSectionType"></param> public bool DrawReportSection(object graphicsObject, DIYReport.SectionType pSectionType) { Graphics g = graphicsObject as Graphics; DIYReport.ReportModel.RptSection section = _DataReport.SectionList.GetSectionByType(pSectionType); if (section.Visibled) { //分组的Section 在画 Detail 的时候处理 if (section != null && pSectionType != DIYReport.SectionType.GroupHead && pSectionType != DIYReport.SectionType.GroupFooter) { if (pSectionType == DIYReport.SectionType.Detail) { return(DrawDetail(g, section)); } else { foreach (DIYReport.ReportModel.RptSingleObj obj in section.RptObjList) { DrawRptSimpleObj(g, obj); } } } } return(true); }
//绘制字段分组的脚 //返回 true 表示还没有结束 private bool drawGroupFoot(Graphics g) { if (_GroupFoots.Count > 0) { int count = _GroupFoots.Count; //_HasDrawDetailHeight for (int i = 0; i < count; i++) { DIYReport.ReportModel.RptSection section = _GroupFoots.Peek() as DIYReport.ReportModel.RptSection; if (section.Visibled) { int tempHeight = _HasDrawDetailHeight + section.Height; if (tempHeight > REAL_DETAIL_HEIGHT) { return(true); } section = _GroupFoots.Pop() as DIYReport.ReportModel.RptSection; DrawGroupField groupField = _DrawDetailInfo.GetGroupFieldByName(section.GroupField.FieldName); groupField.HasDrawGroupHead = false; DIYReport.Express.ExSpecial._RowOrderNO = 0; foreach (RptSingleObj obj in section.RptObjList) { DrawRptSimpleObj(g, obj, _Rows[_HasDrawRowCount - 1]); } _HasDrawDetailHeight += section.Height; } } } return(false); }
//判断并插入新的section.... private void insertNewSection(RptSection section) { section.Report = _Report; int position = -1; for (int i = 0; i < this.Count; i++) { int oldIndex = (int)(this[i] as RptSection).SectionType; if (oldIndex == (int)section.SectionType) //如果相等说明是分组的情况。 { if (section.SectionType == SectionType.GroupHead) { position = i; } else { position = i + 1; } break; } if (oldIndex > (int)section.SectionType) { position = i; break; } } if (position == -1 || position == this.Count) { base.Add(section); } else { base.Insert(position, section); } }
/// <summary> /// 创建分组的Data Section /// </summary> /// <param name="pGroupField"> 需要进行分组处理的字段信息 </param> /// <returns></returns> public bool CreateGroupSection() { ArrayList rptFields = DIYReport.UserDIY.DesignEnviroment.CurrentReport.DesignField as ArrayList; //分组排序 rptFields.Sort(new DIYReport.GroupAndSort.FieldSortComparer()); //int width = (this[0] as RptSection).Width ; //先删除不需要的分组 foreach (DIYReport.GroupAndSort.RptFieldInfo info in rptFields) { if (info.IsGroup) { continue; } //判断在分组是否存在,并把已经不作为分组的Data Section删除掉 bool b = deleteGroupSection(info); if (b) { //在删除组页脚 deleteGroupSection(info); } } foreach (DIYReport.GroupAndSort.RptFieldInfo info in rptFields) { if (!info.IsGroup) { continue; } bool hasCreate = false; foreach (RptSection section in this) { if (section.GroupField != null && section.GroupField.Equals(info)) { hasCreate = true; break; } } if (hasCreate) { continue; } //先创建分组的标题 RptSection newSection = new RptSection(DIYReport.SectionType.GroupHead, info); this.Add(newSection); newSection = new RptSection(DIYReport.SectionType.GroupFooter, info); //newSection.Width = width; // newSection.Height = 60; this.Add(newSection); } onAfterCreateNewSection(null); return(true); }
/// <summary> /// 通过Section Type 得到 指定的Section的高度 /// </summary> /// <param name="pType"></param> /// <returns></returns> public int GetSectionHeightByType(DIYReport.SectionType pType) { RptSection section = GetSectionByType(pType); if (section != null && section.Visibled) { return(section.Height); } else { return(0); } }
/// <summary> /// 删除指定的section. /// </summary> /// <param name="section"></param> public void RemoveSection(RptSection section) { if (this.Count == 1) { MessageBox.Show("最后一个Section 不能进行删除。", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (section.SectionType == SectionType.GroupHead || section.SectionType == SectionType.GroupFooter) { MessageBox.Show("分组的 Section 不能进行删除。你可以通过拖动它的高度来达到打印不显示的效果。", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (base.Contains(section)) { OnBeforeRemoveSection(section); base.Remove(section); } }
private bool deleteGroupSection(DIYReport.GroupAndSort.RptFieldInfo pFieldinfo) { RptSection groupSection = null; foreach (RptSection section in this) { if (section.GroupField != null && section.GroupField.Equals(pFieldinfo)) { groupSection = section; break; } } if (groupSection != null) { OnBeforeRemoveSection(groupSection); this.Remove(groupSection); return(true); } return(false); }
/// <summary> /// 创建section /// </summary> public void AddbySectionType(DIYReport.SectionType sectionType) { //检查对应的section 是否已经创建 foreach (RptSection section in this) { if (section.SectionType == sectionType) { MessageBox.Show("需要增加的Section 已经创建,每个Section 只能创建一次。", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } if (sectionType == DIYReport.SectionType.GroupHead || sectionType == DIYReport.SectionType.GroupFooter) { Debug.Assert(false, "创建分组的section 请使用CreateGroupSection"); } RptSection newSection = new RptSection(sectionType); this.Add(newSection); onAfterCreateNewSection(null); }
public DesignSection(DIYReport.ReportModel.RptSection pDataObj) { InitializeComponent(); picMain.Paint += new PaintEventHandler(picMain_Paint); this.Width = pDataObj.Width; this.Height = pDataObj.Height; _DataObj = pDataObj; updateByDataObj(); _DataObj.AfterValueChanged += new RptEventHandler(_DataObj_AfterValueChanged); _DesignControls = new DesignControlList(this); // if(_SectionType == DIYReport.SectionType.Detail){ // //在刚开始设计的时候只有Detail Section 是默认显示的 // _IsDisplay = true; // panBottomMove.Visible = true; // //panTopMove.Visible = false; // } _IsDisplay = pDataObj.Visibled; panBottomMove.Visible = _IsDisplay; pDataObj.HasCreateViewDesign = true; }
//分析字段的Group Section信息,并存储在对应的队列和栈中 private void analyseGroupSection(int pRowIndex) { int rowCount = _Rows.Length; IList fields = _DrawDetailInfo.GroupFields; bool isEnd = false; if (fields != null && fields.Count > 0) { int count = fields.Count; int drawFoot = -1; int iniGroupIndex = 0; if (pRowIndex < rowCount) { DataRow dRow = _Rows[pRowIndex]; bool mustDrawHead = false; for (int i = iniGroupIndex; i < count; i++) { DrawGroupField groupField = fields[i] as DrawGroupField; string fieldName = groupField.GroupFieldName; object val = dRow[fieldName]; DIYReport.ReportModel.RptSection section = _DataReport.SectionList.GetByGroupField(fieldName, true); //判断行的值和已经绘制的grou p section head 中正在分析的字段的值是否相同 bool inTheGroup = !mustDrawHead && DIYReport.GroupAndSort.GroupDataProcess.ValueInTheGroup(section, groupField.CurrGroupValue, val); groupField.CurrGroupValue = val; if (!inTheGroup && !mustDrawHead) { drawFoot = i; mustDrawHead = true; } if (!groupField.HasDrawGroupHead || mustDrawHead) { //把需要绘制的group section 的head 添加到队列的结尾 groupField.PrevFirstRowIndex = groupField.FirstRowIndex == -1?0:groupField.FirstRowIndex; groupField.FirstRowIndex = _HasDrawRowCount; _GroupHeads.Enqueue(section); } } } else { drawFoot = 0; isEnd = true; } if (drawFoot > -1) { for (int i = drawFoot; i < count; i++) { DrawGroupField groupField = fields[i] as DrawGroupField; if (isEnd) { groupField.PrevFirstRowIndex = groupField.FirstRowIndex; } //groupField.FirstRowIndex = groupField.PrevFirstRowIndex; string fieldName = groupField.GroupFieldName; DIYReport.ReportModel.RptSection section = _DataReport.SectionList.GetByGroupField(fieldName, false); //把需要绘制的group section 的footer 压到栈中 _GroupFoots.Push(section); //groupField.HasDrawGroupHead = false; } // end for(int i = drawFoot; i <count;i++){ } //end drawFoot > -1 } // end fields!=null && fields.Count >0 }
/// <summary> /// 画详细信息 /// </summary> /// <param name="g"></param> /// <returns>如果还有下一页,那么返回True,否则 False</returns> private bool DrawDetail(Graphics g, DIYReport.ReportModel.RptSection pSection) { if (_RptData == null || pSection == null || pSection.Height == 0 || pSection.RptObjList.Count == 0) { _IsLastPage = true; return(false); } int initialRow = this.HasDrawRowCount; _RowPoint = 0; _HasDrawDetailHeight = 0; //_BottomRow = 0; _IsLastPage = false; bool reB = false; //判断是否存在剩余的组头或者组脚并绘制它 drawLeaveGroupInfo(g); if (_Rows.Length > 0 && initialRow == 0) { analyseGroupSection(0); reB = drawGroupHead(g); if (reB) { return(true); } } for (int i = initialRow; i < _Rows.Length; i++) { DIYReport.Express.ExSpecial._RowOrderNO++; foreach (RptSingleObj obj in pSection.RptObjList) { DrawRptSimpleObj(g, obj, _Rows[i]); } _HasDrawDetailHeight += pSection.Height; _RowPoint++; _HasDrawRowCount++; //分析下一个分组行的信息,并决定如何来绘制当前行的信息,如果存在那么就绘制 analyseGroupSection(i + 1); reB = drawGroupFoot(g); if (reB) //判断是否绘制完毕 { return(true); } reB = drawGroupHead(g); if (reB) { return(true); } //已经画到的行的高度 int temHeight = _HasDrawDetailHeight + pSection.Height; if (temHeight > REAL_DETAIL_HEIGHT) { return(true); } } int temH = _HasDrawDetailHeight + _RptInfo.BottomHeight; if (temH > REAL_DETAIL_HEIGHT) { return(true); } //_BottomRow = _RowPoint; int mergeCount = REAL_DETAIL_HEIGHT / pSection.Height; mergeCount -= _RowPoint; mergeCount += 1; //判断是否有剩余的空间,画空行 for (int j = 0; j < mergeCount; j++) { if (_DataReport.FillNULLRow) { foreach (RptSingleObj obj in pSection.RptObjList) { drawRect(g, obj); } } _RowPoint++; } // end for(int j =0; j< mergeCount ;j++) _IsLastPage = true; return(false); }
public RptSection Insert(int pIndex, RptSection pParam) { base.Insert(pIndex, pParam); return(pParam); }
/// <summary> /// 通过报表的Data section 设置Design Section 的数据信息 /// </summary> /// <param name="pDataSection"></param> public void SetDataSection(DIYReport.ReportModel.RptSection pDataSection) { this.IsDisplay = pDataSection.Visibled; //this.Location = new Point(0 , SectionCaption.CAPTION_HEIGHT + pDataSection.Location.Y) ; this.Height = pDataSection.Height; }
public RptSingleObjList(RptSection pSection) { _Section = pSection; }
public CreateRptObjParam(RptCssClassList pCssClasss, RptSection pSection) { _CssClasss = pCssClasss; _Section = pSection; }
/// <summary> /// ADD /// </summary> /// <param name="pParam"></param> /// <returns></returns> public RptSection Add(RptSection pParam) { insertNewSection(pParam); return(pParam); }