Example #1
0
        /// <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;
        }
Example #2
0
        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;
        }