示例#1
0
        public void SetHeadGridLine(WebbTable table, Webb.Collections.Int32Collection HeaderRowsArray)
        {
            int rows = table.GetRows();
            int cols = table.GetColumns();

            if (this.GridLine || HeaderRowsArray.Count <= 0 || cols <= 0 || rows <= 0)
            {
                return;
            }
            int maxH = (int)HeaderRowsArray[0], minH = (int)HeaderRowsArray[0];

            foreach (int hrow in HeaderRowsArray)                //Get the Max rowindex and min rowindex of HeaderRows
            {
                maxH = Math.Max(maxH, hrow);
                minH = Math.Min(minH, hrow);
            }
            for (int i = minH; i <= maxH; i++)
            {
                if (i >= rows)
                {
                    return;
                }
                for (int j = 0; j < cols; j++)
                {
                    IWebbTableCell bordercell = table.GetCell(i, j);
                    bordercell.CellStyle.Sides = DevExpress.XtraPrinting.BorderSide.None;
                    if (i == minH)
                    {
                        bordercell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Top;
                    }
                    if (j == 0)
                    {
                        bordercell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Left;
                    }
                    if (j == cols - 1)
                    {
                        bordercell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Right;
                    }
                    if (i == maxH)
                    {
                        bordercell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Bottom;
                    }
                    if (i == minH && this.ColsToMerge.Contains(j))
                    {
                        bordercell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Bottom;;
                    }
                    if (j < this.ColCount && i < maxH)
                    {
                        HeaderCell hc = GetCell(i, j);
                        if (j + hc.MergerdCount - 1 == cols - 1)
                        {
                            bordercell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Right;
                        }
                        ;
                    }
                }
            }
        }
        private void CreateTableColumnStyle(DataTable m_Table, Views.ExControlView i_View)
        {
            //Columns width
            WebbTable i_PrintTable = i_View.PrintingTable;

            if (i_PrintTable == null)
            {
                return;
            }

            DataGridColumnStyle m_ColStyle = null;

            this.dataGrid1.TableStyles.Clear();

            DataGridTableStyle m_TableStyle = new DataGridTableStyle();

            m_TableStyle.AllowSorting = false;

            m_TableStyle.MappingName = m_Table.TableName;

            int m_cols = i_PrintTable.GetColumns();

            int m_rows = i_PrintTable.GetRows();

            //System.Diagnostics.Debug.Assert(m_Table.Rows.Count == m_rows && m_Table.Columns.Count == m_cols);

            for (int m_col = 0; m_col < m_cols; m_col++)
            {
                m_ColStyle = new DataGridTextBoxColumn();

                WebbTableCell cell = i_PrintTable.GetCell(0, m_col) as WebbTableCell;

                if (cell != null)                       //Modified at 2008-11-11 11:09:29@Scott
                {
                    m_ColStyle.Width = i_PrintTable.GetCell(0, m_col).CellStyle.Width;

                    m_ColStyle.MappingName = m_Table.Columns[m_col].ColumnName;

                    m_ColStyle.HeaderText = string.Empty;

                    m_TableStyle.GridColumnStyles.Add(m_ColStyle);
                }
            }

            this.dataGrid1.TableStyles.Add(m_TableStyle);
        }
示例#3
0
        //public void SetHeaders(WebbTable table,ref int nRow)
        //{
        //    int cols=table.GetColumns();
        //    if(cols<=0)return;
        //    for(int i=0;i<this.RowCount;i++)
        //    {
        //        for(int j=0;j<this._ColCount;j++)
        //        {
        //            if(i>=table.GetRows()||j>=cols)continue;
        //            HeaderCell hc=GetCell(i,j);
        //              IWebbTableCell tablecell=table.GetCell(i+nRow,j);
        //            if(hc.MergerdCount>0)
        //            {
        //                int StartIndex=j;
        //                int EndIndex=j+hc.MergerdCount-1;
        //                if(EndIndex>=cols)EndIndex=cols-1;
        //                if(EndIndex>StartIndex)
        //                {
        //                    table.MergeCells(i,i,StartIndex,EndIndex);
        //                }
        //                if(hc.Text!="")tablecell.Text=hc.Text;
        //                j=EndIndex;
        //            }
        //            else
        //            {
        //                if(hc.Text!="")tablecell.Text=hc.Text;
        //            }

        //        }

        //    }
        //    nRow+=this.RowCount;
        //}
        #endregion


        public void SetHeaders(WebbTable table, ref int nRow, Views.ExControlView i_View)
        {
            int totalColumnsInTable = table.GetColumns();

            if (totalColumnsInTable <= 0)
            {
                return;
            }

            for (int i = 0; i < this.RowCount; i++)
            {
                for (int j = 0; j < this._ColCount; j++)
                {
                    if (i >= table.GetRows() || j >= totalColumnsInTable)
                    {
                        continue;
                    }

                    HeaderCell hc = GetCell(i, j);

                    IWebbTableCell tablecell = table.GetCell(i + nRow, j);

                    if (hc == null || tablecell == null)
                    {
                        continue;
                    }

                    string strHeaderText = hc.Text;

                    strHeaderText = strHeaderText.Replace("[onevalue]", i_View.OneValueScFilter.FilterName);

                    strHeaderText = strHeaderText.Replace("[repeat]", i_View.RepeatFilter.FilterName);

                    strHeaderText = strHeaderText.Replace("[ONEVALUE]", i_View.OneValueScFilter.FilterName);

                    strHeaderText = strHeaderText.Replace("[REPEAT]", i_View.RepeatFilter.FilterName);

                    if (hc.MergerdCount > 0)
                    {
                        int StartIndex = j;

                        int EndIndex = j + hc.MergerdCount - 1;

                        if (EndIndex >= totalColumnsInTable)
                        {
                            EndIndex = totalColumnsInTable - 1;
                        }

                        if (EndIndex > StartIndex)
                        {
                            table.MergeCells(i, i, StartIndex, EndIndex);
                        }

                        tablecell.Text = strHeaderText;

                        j = EndIndex;
                    }
                    else
                    {
                        tablecell.MergeType = MergeTypes.None;

                        tablecell.Text = strHeaderText;
                    }
                }
            }
            nRow += this.RowCount;
        }
示例#4
0
        private int GetMatrixMergedCount(WebbTable table)
        {
            if (MatrixInfo != null)
            {
                if (!MatrixInfo.ShowInOneCol)
                {
                    if (MatrixInfo.CellTotal.ShowTotal)
                    {
                        return(2);
                    }
                    else
                    {
                        return(1);
                    }
                }
            }

            int count = 1;               //RowGroup Result

            int index = 0;

            if (this.ShowRowIndicators)
            {
                index = 1;
            }

            int MaxRows = table.GetRows();

            if (index >= table.GetColumns() || table.HeaderCount >= MaxRows)
            {
                return(1);
            }

            int row = table.HeaderCount;

            IWebbTableCell cell = table.GetCell(row, index);

            while ((cell.MergeType & MergeTypes.Down) != MergeTypes.Down)
            {
                row++;

                if (row >= MaxRows)
                {
                    break;
                }

                cell = table.GetCell(row, index);
            }

            if (row >= MaxRows - 1)
            {
                return(1);
            }

            row++;

            cell = table.GetCell(row, index);

            while ((cell.MergeType & MergeTypes.Merged) == MergeTypes.Merged)
            {
                count++;

                row++;

                if (row >= MaxRows || (cell.MergeType & MergeTypes.End) == MergeTypes.End)
                {
                    break;
                }

                cell = table.GetCell(row, index);
            }
            return(count);
        }
        private void PaintTable(Panel paintControl, Rectangle rect, Rectangle gridlineArea)
        {
            Label drawlabel;

            if (_ExControlView == null || _ExControlView.PrintingTable == null)
            {
                drawlabel             = new Label();
                drawlabel.Bounds      = rect;
                drawlabel.Text        = "There isn't any report data here!";
                drawlabel.BorderStyle = BorderStyle.FixedSingle;
                drawlabel.TextAlign   = System.Drawing.ContentAlignment.MiddleCenter;
                drawlabel.Name        = "cell";
                paintControl.Controls.Add(drawlabel);
                lblHeight = 30;
                return;
            }
            WebbTable table = _ExControlView.PrintingTable;

            if (table == null || table.GetColumns() <= 0 || table.GetRows() <= 0)
            {
                drawlabel             = new Label();
                drawlabel.Bounds      = rect;
                drawlabel.Text        = "No Data!";
                drawlabel.BorderStyle = BorderStyle.FixedSingle;
                drawlabel.TextAlign   = System.Drawing.ContentAlignment.MiddleCenter;
                drawlabel.Name        = "cell";
                paintControl.Controls.Add(drawlabel);
                lblHeight = 30;
                return;
            }


            ArrayList prnHeaders = new ArrayList();
            ArrayList formats    = new ArrayList();

            IMultiHeader mainView = _ExControlView as IMultiHeader;

            prnHeaders = mainView.GetPrnHeader(out formats);


            int tempHeight = 0;

            if (mainView.HaveHeader)              //Modified at 2008-10-20 11:24:01@Simon
            {
                int lblWidth = rect.Width / prnHeaders.Count;

                ArrayList lblhigharr = new ArrayList();                //Added this code at 2008-11-5 9:33:39@Simon

                bool b_ver = false;

                Bitmap bmpmemory = new Bitmap(rect.Width, rect.Height);                //Added this code at 2008-11-7 17:23:35@Simon

                Graphics g0 = Graphics.FromImage(bmpmemory);                           //Added this code at 2008-11-7 17:23:31@Simon

                drawlabel = new Label();

                MergedHeader = false;

                for (int i = 0; i < prnHeaders.Count; i++)
                {
                    string text = (string)prnHeaders[i];

                    tempHeight = lblHeight;

                    Rectangle lblrect = new Rectangle(rect.X + i * lblWidth, rect.Y, lblWidth, tempHeight);

                    if (text == "\n")
                    {
                        drawlabel.Width += lblrect.Width;

                        MergedHeader = true;
                        continue;
                    }

                    StringFormatFlags strflags = (StringFormatFlags)formats[i];                    //Added this code at 2008-11-5 8:53:15@Simon

                    drawlabel = new Label();

                    if (Headers.ColsToMerge.Contains(i))
                    {
                        drawlabel.Name = "cell0|" + text;
                    }
                    else
                    {
                        drawlabel.Name = "cell1|" + text;
                    }
                    drawlabel.Tag = strflags;

                    #region Modify codes at 2008-11-5 16:02:24@Simon
                    if (this.Headers.GridLine)
                    {
                        drawlabel.BorderStyle = BorderStyle.FixedSingle;
                        if (Headers.ColsToMerge.Contains(i))
                        {
                            drawlabel.Location = new Point(lblrect.X, gridlineArea.Y);
                            drawlabel.Size     = new Size(lblrect.Width, lblrect.Height + gridlineArea.Height);
                        }
                        else
                        {
                            drawlabel.Bounds = lblrect;
                        }
                    }
                    else
                    {
                        drawlabel.BorderStyle = BorderStyle.None;
                        if (Headers.ColsToMerge.Contains(i))
                        {
                            drawlabel.Location = new Point(lblrect.X + 1, gridlineArea.Y + 1);
                            drawlabel.Size     = new Size(lblrect.Width - 2, lblrect.Height + gridlineArea.Height - 2);
                        }
                        else
                        {
                            drawlabel.Location = new Point(lblrect.X + 1, lblrect.Y + 1);
                            drawlabel.Size     = new Size(lblrect.Width - 2, lblrect.Height - 2);
                        }
                    }
                    #endregion                            //End Modify

                    drawlabel.Paint    += new PaintEventHandler(DrawLabelPaint);
                    drawlabel.BackColor = Control.DefaultBackColor;
                    drawlabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                    paintControl.Controls.Add(drawlabel);

                    #region add codes at 2008-11-5 9:44:30@Simon

                    lblhigharr.Add(drawlabel);
                    if (strflags == StringFormatFlags.DirectionVertical)
                    {
                        this.TestMaxlblheight(g0, drawlabel.Font, text);
                        if (!Headers.ColsToMerge.Contains(i) || Headers.RowCount == 0)
                        {
                            b_ver = true;
                        }
                    }

                    #endregion                            //End Modify
                }

                #region Modify codes at 2008-11-5 9:54:22@Simon
                MaxlblHeight = Math.Min(rect.Height - 10, MaxlblHeight);
                if (b_ver && MaxlblHeight > 0)
                {
                    tempHeight = MaxlblHeight;
                    foreach (object objtext in lblhigharr)
                    {
                        if ((objtext as Label).Name.Substring(4, 1) == "0")
                        {
                            (objtext as Label).Height = this.Headers.GridLine?gridlineArea.Height + MaxlblHeight:gridlineArea.Height + MaxlblHeight - 2;
                        }
                        else
                        {
                            (objtext as Label).Height = this.Headers.GridLine?MaxlblHeight:MaxlblHeight - 2;
                        }
                    }
                }
                MaxlblHeight = 0;
                g0.Dispose();
                bmpmemory.Dispose();
                #endregion                        //End Modify

                rect.Y              += tempHeight;
                rect.Width           = lblWidth * prnHeaders.Count;
                rect.Height         -= tempHeight;
                gridlineArea.Height += tempHeight;
                if (gridlineArea.Width <= 0)
                {
                    gridlineArea.X     = rect.X;
                    gridlineArea.Width = rect.Width;
                }
            }
            if (!this.Headers.GridLine)
            {
                drawlabel             = new Label();
                drawlabel.Bounds      = gridlineArea;
                drawlabel.Text        = "";
                drawlabel.TextAlign   = System.Drawing.ContentAlignment.MiddleCenter;
                drawlabel.BorderStyle = BorderStyle.FixedSingle;
                drawlabel.BackColor   = Control.DefaultBackColor;
                drawlabel.Name        = "cell";
                paintControl.Controls.Add(drawlabel);
                drawlabel.SendToBack();
            }
            drawlabel             = new Label();
            drawlabel.Bounds      = rect;
            drawlabel.Text        = "Table Data";
            drawlabel.TextAlign   = System.Drawing.ContentAlignment.MiddleCenter;
            drawlabel.BorderStyle = BorderStyle.FixedSingle;
            drawlabel.Name        = "cell";
            paintControl.Controls.Add(drawlabel);
            lblHeight = 30;
        }