// 重新布置Design Section 的显示 public void RefreshDesignLayout() { int height = 0; int drawY = 0; int paperWidth = _Report.DataObj.IsLandscape?_Report.DataObj.PaperSize.Height:_Report.DataObj.PaperSize.Width; int width = paperWidth - _Report.DataObj.Margins.Left - _Report.DataObj.Margins.Right; foreach (DIYReport.ReportModel.RptSection rptSection in this.DataObj) { DesignSection section = getDesignSectionByDataSection(rptSection); if (section == null) { continue; } //DIYReport.TrackEx.Write(section!=null,"在调整DesignLayout是时候出现根据rptsection 获取 designsection 为空的情况。"); bool b = section.IsDisplay; section.Visible = b; section.CaptionCtl.Visible = b; section.DataObj.DrawLocationY = drawY; if (b) { section.BringToFront(); section.CaptionCtl.BringToFront(); section.CaptionCtl.Location = new Point(0, height); section.Location = new Point(0, height + SectionCaption.CAPTION_HEIGHT); section.Width = width; section.CaptionCtl.Width = width; height += section.Height + SectionCaption.CAPTION_HEIGHT; drawY += section.Height; } // } OnAfterRefreshLayout((DesignSectionEventArgs)null); }
private void labBack_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { DesignEnviroment.CurrentRptObj = _DataObj; DesignEnviroment.UICmidExecutor.ExecCommand(UICommands.SetObjProperty); DesignSection section = this.DeControlList.Section; if (section.IsActive == false) { section.SectionList.SetOtherSectionAllNotSelected(section); section.SectionList.SetActiveSection(section); } _DeControlList.SetMainSelected(this); if (e.Button == MouseButtons.Left && e.Button != MouseButtons.Right) { isdown = true; this.Capture = true; p1 = new Point(this.Left + e.X, this.Top + e.Y); } //判断用户是否按下shift 或者ctrl 键 if (DesignEnviroment.PressCtrlKey != true && DesignEnviroment.PressShiftKey != true && this.IsSelected == false) { _DeControlList.SetAllNotSelected(); } this.IsSelected = true; _isMove = false; }
/// <summary> /// 设置Section 是否在选择的状态 /// </summary> /// <param name="pSection"></param> public void SetActiveSection(DesignSection pSection) { foreach (DesignSection section in this) { if ((int)section.SectionType == (int)pSection.SectionType) { if (pSection.SectionType == DIYReport.SectionType.GroupFooter || pSection.SectionType == DIYReport.SectionType.GroupHead) { if (pSection.DataObj.GroupField == section.DataObj.GroupField) { section.IsActive = true; continue; } } else { section.IsActive = true; continue; } } if (section.IsActive) { section.DesignControls.SetAllNotSelected(); } section.IsActive = false; } }
/// <summary> /// 删除当前选中的报表控件 /// </summary> public void DeleteSelectedControls() { DesignSection section = _SectionList.GetActiveSection(); if (section != null) { section.DesignControls.RemoveSelectedControl(); } }
/// <summary> /// 让其它Section 的所有控件在不选择状态 /// </summary> public void SetOtherSectionAllNotSelected(DesignSection pSection) { foreach (DesignSection section in this) { if ((int)section.SectionType != (int)pSection.SectionType) { section.DesignControls.SetAllNotSelected(); } } }
public void Past() { DesignSection section = _SectionList.GetActiveSection(); if (section == null) { return; } IList dataLst = DIYReport.UserDIY.ClipboardEx.GetFromClipBoard(); section.DesignControls.Add(dataLst); }
/// <summary> /// 通过Data Section List 设置 Design Section List 的数据信息 /// </summary> /// <param name="pDataSectionList"></param> public void SetDataSectionList(DIYReport.ReportModel.RptSectionList pDataSectionList) { foreach (DIYReport.ReportModel.RptSection section in pDataSectionList) { DesignSection dse = GetSectionByType(section.SectionType); if (dse != null) { dse.SetDataSection(section); } } //ReizeSectionsLocation( (DesignSection)null ); RefreshDesignLayout(); }
/// <summary> /// 复制操作 /// </summary> public void Copy() { DesignSection section = _SectionList.GetActiveSection(); if (section == null) { return; } IList dataLst = section.DesignControls.GetSelectedCtlsData(); DIYReport.UserDIY.ClipboardEx.CopyToClipBoard(dataLst); }
/// <summary> /// 创建一个新的Section List /// </summary> public void CreateNewSectionList() { _DataObj = _Report.DataObj.SectionList; foreach (DIYReport.ReportModel.RptSection dataSection in _DataObj) { DesignSection section = new DesignSection(dataSection); section.IsDisplay = true; SectionCaption caption = new SectionCaption(); section.CaptionCtl = caption; this.Add(section); } RefreshDesignLayout(); _DataObj.BeforeRemoveSection += new DIYReport.ReportModel.RptSectionEventHandler(_DataObj_BeforeRemoveSection); _DataObj._fterCreateNewSection += new System.EventHandler(_DataObj_AfterCreateNewSection); }
private void copyCtl(bool isCopy) { DesignSection section = _SectionList.GetActiveSection(); if (section == null) { return; } IList dataLst = section.DesignControls.GetSelectedCtlsData(); DIYReport.UserDIY.ClipboardEx.CopyToClipBoard(dataLst); if (!isCopy) { System.Threading.Thread.CurrentThread.Join(200); section.DesignControls.RemoveSelectedControl(); } }
private void _DataObj_BeforeRemoveSection(object sender, DIYReport.ReportModel.RptSection e) { DesignSection deSection = null; foreach (DesignSection section in this) { if (section.DataObj.Equals(e)) { deSection = section; break; } } if (deSection != null) { OnBeforeRemoveSection(new DesignSectionEventArgs(-1, deSection)); this.Remove(deSection); } //在删除Section 后重新布置 RefreshDesignLayout(); }
// 重新刷新报表设计中所有Section 的显示 private void createDesignSection() { //检查 DataSection 在DesignSectionList 中是否已经创建,如果不存在,就创建它 int i = 0; foreach (DIYReport.ReportModel.RptSection dataSection in _DataObj) { if (!dataSection.HasCreateViewDesign) { DesignSection section = new DesignSection(dataSection); SectionCaption caption = new SectionCaption(); section.IsDisplay = true; section.CaptionCtl = caption; section.SectionList = this; this.Add(section); OnAfterInsertSection(new DesignSectionEventArgs(i, section)); } i++; } RefreshDesignLayout(); }
/// <summary> /// 删除当前选中的报表控件 /// </summary> public void DeleteSelectedControls(bool delByKey) { object obj = DesignEnviroment.CurrentRptObj; DesignSection section = _SectionList.GetActiveSection(); if (obj == null || section == null) { return; } if (string.Compare(obj.GetType().Name, "RptSection", true) == 0) { if (delByKey) { if (section.DataObj.BackgroundImage != null) { section.DataObj.BackgroundImage = null; } } else { if (section.DesignControls.Count > 0) { DialogResult re = MessageBox.Show("删除Section ,Section 上包含的控件也一起被删除。是否继续?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (re == DialogResult.No) { return; } } this.SectionList.DataObj.RemoveSection(section.DataObj); } } else { section.DesignControls.RemoveSelectedControl(); } }
/// <summary> /// Add /// </summary> /// <param name="pSection"></param> /// <returns></returns> public DesignSection Add(DesignSection pSection) { base.Add(pSection); pSection.SectionList = this; return(pSection); }
private void tlbTopBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { //e.Button.Tag 的0-5为存储格式控件操作样式的 this.Cursor = Cursors.WaitCursor; if (e.Button.Tag != null) { int index = int.Parse(e.Button.Tag.ToString()); if (index < 6) { DesignSection section = _SectionList.GetActiveSection(); section.DesignControls.FormatCtl((DIYReport.UserDIY.FormatCtlType)index); } switch (index) { case 6: //向左边靠齐 _SectionList.GetActiveSection().DesignControls.DockToLeft(); break; case 7: //向右边靠齐 _SectionList.GetActiveSection().DesignControls.DockToTop(); break; case 8: //显示方向控制盘 FrmArrowOperate.ShowArrowForm(_SectionList, this.ParentForm); break; case 16: //显示属性窗口 DesignEnviroment.ShowPropertyForm(this.ParentForm, true); break; case 17: //删除控件 DeleteSelectedControls(); break; case 18: //打印 using (DIYReport.Print.SwPrintView print = new DIYReport.Print.SwPrintView(DIYReport.UserDIY.DesignEnviroment.DataSource, _DataObj)){ print.Printer(); } break; case 19: //打印预览 using (DIYReport.Print.SwPrintView printView = new DIYReport.Print.SwPrintView(DIYReport.UserDIY.DesignEnviroment.DataSource, _DataObj)){ printView.ShowPreview(); } break; case 20: //打印页面设置 DIYReport.Print.RptPageSetting.ShowPageSetupDialog(_DataObj); break; case 21: //保存报表 _ReportIO.SaveReport(_DataObj, null); DIYReport.UserDIY.DesignEnviroment.DesignHasChanged = false; break; case 22: //打开报表 DIYReport.ReportModel.RptReport report = _ReportIO.Open(); if (report != null) { OpenReport(report); } break; case 23: //新增报表 //CreateNewReport(); //MessageBox.Show("当前不支持从这里新建一张报表摸板.","操作提示"); //暂时把它修改为打印摸板的导出功能。 _ReportIO.Save(_DataObj); break; case 24: //Undo _UndoMgr.Undo(); break; case 25: //Redo _UndoMgr.Redo(); break; case 26: //显示分组和排序 IList fieldsList = DIYReport.UserDIY.DesignEnviroment.CurrentReport.DesignField; DIYReport.GroupAndSort.frmSortAndGroup frm = new DIYReport.GroupAndSort.frmSortAndGroup(fieldsList); frm.AfterSortAndGroup += new DIYReport.GroupAndSort.SortAndGroupEventHandler(frm_AfterSortAndGroup); frm.ShowDialog(); break; default: break; } } this.Cursor = Cursors.Arrow; }
public DesignSectionEventArgs(int pInsertPosition, DesignSection pSection) { _InsertPosition = pInsertPosition; _Section = pSection; }
/// <summary> /// 执行命令 /// </summary> /// <param name="cmdID"></param> public override void ExecCommand(CommandID cmdID) { DesignSection designSe = this.DesignerHost.SectionList.GetActiveSection(); //this.DesignerHost.Cursor = Cursors.WaitCursor ; //switch(cmdID){ if (cmdID.Equals(StandardCommands.HorizSpaceConcatenate)) //向左边靠齐 { designSe.DesignControls.DockToLeft(); } else if (cmdID.Equals(StandardCommands.VertSpaceConcatenate)) { //向右边靠齐 designSe.DesignControls.DockToTop(); } else if (cmdID.Equals(UICommands.ControlHandle)) //显示方向控制盘 { FrmArrowOperate.ShowArrowForm(this.DesignerHost.SectionList, this.DesignerHost.ParentForm); } else if (cmdID.Equals(UICommands.SetObjProperty)) { //显示属性窗口 OnSetObjProperty(); } else if (cmdID.Equals(UICommands.ShowProperty)) { //显示属性窗口 //DesignEnviroment.ShowPropertyForm(this.DesignerHost.ParentForm,true); //Debug.Assert(false,"ShowProperty "); } else if (cmdID.Equals(StandardCommands.Delete)) { //删除控件 this.DesignerHost.DeleteSelectedControls(); } else if (cmdID.Equals(UICommands.Print)) //打印 { using (DIYReport.Print.SwPrintView print = new DIYReport.Print.SwPrintView(this.DesignerHost.DataObj.DataSource, this.DesignerHost.DataObj)){ print.Printer(); } } else if (cmdID.Equals(UICommands.Preview)) //打印预览 { using (DIYReport.Print.SwPrintView printView = new DIYReport.Print.SwPrintView(this.DesignerHost.DataObj.DataSource, this.DesignerHost.DataObj)){ printView.ShowPreview(); } } else if (cmdID.Equals(UICommands.PageSetup)) //打印页面设置 { DIYReport.Print.RptPageSetting.ShowPageSetupDialog(this.DesignerHost.DataObj); } else if (cmdID.Equals(UICommands.SaveFile)) //保存报表 { DIYReport.ReportXmlHelper.Save(this.DesignerHost.DataObj); //this.DesignerHost.ReportIO.SaveReport(,this.DesignerHost.DataObj.RptFilePath); DIYReport.UserDIY.DesignEnviroment.DesignHasChanged = false; } else if (cmdID.Equals(UICommands.OpenFile)) //打开报表 { DIYReport.ReportModel.RptReport report = DIYReport.ReportXmlHelper.Open(); if (report != null) { this.DesignerHost.OpenReport(report); } } else if (cmdID.Equals(UICommands.Output)) //导出 { bool b = DIYReport.ReportXmlHelper.Save(this.DesignerHost.DataObj); if (b) { MessageBox.Show("打印模板导出成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (cmdID.Equals(UICommands.Import)) //导入 { DialogResult re = MessageBox.Show("导入打印模板将会清空当前模板,是否继续?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information); DIYReport.ReportModel.RptReport oldCurrentReport = DIYReport.UserDIY.DesignEnviroment.CurrentReport; DIYReport.ReportModel.RptReport report = DIYReport.ReportXmlHelper.Open(); if (report != null) { report.IDEX = System.Guid.NewGuid(); if (oldCurrentReport != null) { if (oldCurrentReport.DataSource != null) { report.Tag = oldCurrentReport.Tag; report.UserParamList = oldCurrentReport.UserParamList; report.DataSource = oldCurrentReport.DataSource; report.DesignField = oldCurrentReport.DesignField; } else { report.DataSource = DIYReport.UserDIY.DesignEnviroment.DataSource; report.DesignField = DIYReport.UserDIY.DesignEnviroment.DesignField; } report.SubReportCommand = oldCurrentReport.SubReportCommand; foreach (DIYReport.ReportModel.RptReport subReport in oldCurrentReport.SubReports.Values) { report.SubReports.Add(subReport.Name, subReport); } } this.DesignerHost.OpenReport(report); } } else if (cmdID.Equals(UICommands.NewReport)) //新增报表 { DIYReport.ReportModel.RptReport report = DIYReport.ReportModel.RptReport.NewReport(); this.DesignerHost.OpenReport(report); } else if (cmdID.Equals(StandardCommands.Undo)) //Undo { this.DesignerHost.UndoMgr.Undo(); } else if (cmdID.Equals(StandardCommands.Redo)) //Redo { this.DesignerHost.UndoMgr.Redo(); } else if (cmdID.Equals(StandardCommands.Cut)) { this.DesignerHost.Cut(); } else if (cmdID.Equals(StandardCommands.Copy)) //Redo { this.DesignerHost.Copy(); } else if (cmdID.Equals(StandardCommands.Paste)) //Redo { this.DesignerHost.Past(); } else if (cmdID.Equals(UICommands.SortAndGroup)) //显示分组和排序 { IList fieldsList = this.DesignerHost.DataObj.DesignField; DIYReport.GroupAndSort.frmSortAndGroup frm = new DIYReport.GroupAndSort.frmSortAndGroup(fieldsList); frm.AfterSortAndGroup += new DIYReport.GroupAndSort.SortAndGroupEventHandler(frm_AfterSortAndGroup); frm.ShowDialog(); } else { Debug.Assert(false, "Command" + cmdID.ID.ToString() + "没有处理。"); } //this.DesignerHost.Cursor = Cursors.Arrow; }
public override void ExecCommand(CommandID cmdID) { DesignSection designSe = this.DesignerHost.SectionList.GetActiveSection(); if (cmdID.Equals(RptDesignCommands.InsertTopMarginBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.TopMargin); } else if (cmdID.Equals(RptDesignCommands.InsertReportHeaderBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.ReportTitle); } else if (cmdID.Equals(RptDesignCommands.InsertPageHeaderBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.PageHead); } else if (cmdID.Equals(RptDesignCommands.InsertGroupHeaderBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.GroupHead); } else if (cmdID.Equals(RptDesignCommands.InsertDetailBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.Detail); } else if (cmdID.Equals(RptDesignCommands.InsertGroupFooterBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.GroupFooter); } else if (cmdID.Equals(RptDesignCommands.InsertPageFooterBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.PageFooter); } else if (cmdID.Equals(RptDesignCommands.InsertReportFooterBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.ReportBottom); } else if (cmdID.Equals(RptDesignCommands.InsertBottomMarginBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.BottomMargin); } else if (cmdID.Equals(StandardCommands.Delete)) { this.DesignerHost.DeleteSelectedControls(); } else if (cmdID.Equals(StandardCommands.Cut)) { this.DesignerHost.Cut(); } else if (cmdID.Equals(StandardCommands.Copy)) //Redo { this.DesignerHost.Copy(); } else if (cmdID.Equals(StandardCommands.Paste)) //Redo { this.DesignerHost.Past(); } else { Debug.Assert(false, "该命令" + cmdID.ToString() + "目前还没有进行处理。"); } }