コード例 #1
0
        private bool CreateMatrixPrintingTable()
        {
            if (MatrixInfo == null || !_HaveData || this.RootGroupInfo == null)
            {
                this.PrintingTable = null;
                return(false);
            }

            int m_Rows = MatrixInfo.GetMatrixGroupedRows(this);

            if (this.TableHeaders != null && this.TableHeaders.RowCount > 0 && this.TableHeaders.ColCount > 0) //2008-8-29 9:12:31@simon
            {
                m_Rows += this.TableHeaders.RowCount;                                                          //2008-8-29 9:12:37@simon
            }

            int m_Column = MatrixInfo.GetMatrixGroupedColumns(this.ShowRowIndicators);

            if (m_Rows <= 0 || m_Column <= 0)
            {
                this.PrintingTable = null;
                return(false);
            }

            System.Diagnostics.Debug.WriteLine(string.Format("Begin Create print table:{0}X{1}", m_Rows, m_Column));

            this.PrintingTable = new WebbTable(m_Rows, m_Column);

            MatrixInfo.SetMatrixColumnWidthAtFirst(this.PrintingTable, this.ShowRowIndicators);

            //Set value
            this.HeaderRows.Clear();
            this.SectionRows.Clear();
            this.TotalRows.Clear();
            this.BreakRows.Clear();
            this.ColumnStyleRows.Clear();

            this.SetTableValue();

            StyleBuilder.StyleRowsInfo m_StyleInfo = new Styles.StyleBuilder.StyleRowsInfo(this._HeaderRows, this._SectionRows, this._TotalRows, this.ShowRowIndicators, this.HaveHeader);
            Int32Collection            ignoreRows  = this.HeaderRows.Combine(this.HeaderRows, this.SectionRows, this.TotalRows);
            StyleBuilder styleBuilder = new StyleBuilder();


            #region Modify codes at 2008-11-4 15:45:04@Simon

            styleBuilder.BuildMatrixGroupStyle(this.PrintingTable, m_StyleInfo, this.MatrixInfo, this.Styles, ignoreRows);

            if (this.TableHeaders != null && this.TableHeaders.RowCount > 0 && this.TableHeaders.ColCount > 0)                    //Added this code at 2008-11-6 10:22:40@Simon
            {
                int minh         = 0;
                int i_Titleindex = 0;
                if (this.HeaderRows.Count > 0)
                {
                    foreach (int tl in this.HeaderRows)
                    {
                        if (i_Titleindex < tl)
                        {
                            i_Titleindex = tl;
                        }
                    }
                }
                if (i_Titleindex > minh)
                {
                    foreach (int col in this.TableHeaders.ColsToMerge)
                    {
                        IWebbTableCell Mergedcell = PrintingTable.GetCell(i_Titleindex, col);
                        this.PrintingTable.MergeCells(minh, i_Titleindex, col, col);
                        IWebbTableCell bordercell = PrintingTable.GetCell(minh, col);
                        if (this.HaveHeader)
                        {
                            bordercell.Text = Mergedcell.Text;
                            bordercell.CellStyle.StringFormat = Mergedcell.CellStyle.StringFormat;
                            if ((bordercell.CellStyle.StringFormat & StringFormatFlags.DirectionVertical) != 0)
                            {
                                bordercell.CellStyle.HorzAlignment = HorzAlignment.Far;
                                bordercell.CellStyle.VertAlignment = VertAlignment.Center;
                            }
                        }
                    }
                }
            }

            if (this.TableHeaders != null)
            {
                this.TableHeaders.SetHeadGridLine(this.PrintingTable, this.HeaderRows);
            }

            #endregion                                    //End Modify

            this.ApplyColumnWidthStyle(m_Column);
            this.ApplyRowHeightStyle(m_Rows);

            switch (this.CellSizeAutoAdapting)
            {
            case CellSizeAutoAdaptingTypes.NotUse:
                break;

            case CellSizeAutoAdaptingTypes.WordWrap:
                this.PrintingTable.AutoAdjustMatrixSize(this.ExControl.CreateGraphics(), true, false, this.MatrixInfo, this.ShowRowIndicators);
                break;

            case CellSizeAutoAdaptingTypes.OneLine:
                this.PrintingTable.AutoAdjustMatrixSize(this.ExControl.CreateGraphics(), false, false, this.MatrixInfo, this.ShowRowIndicators);
                break;
            }


            System.Diagnostics.Debug.WriteLine("Create print table completely");

            return(true);
        }