Exemple #1
0
        //Added this code at 2008-11-5 14:35:18@Simon
        public void HideHeaderColumns()
        {
            if (this.SelCount != 1 || this._CurCell == null)
            {
                MessageBox.Show("Please select the cell whose column should be hidden!", "Failed");
                return;
            }
            int  col       = this._CurCell.Col;
            bool b_FitHide = true;

            if (this.ColsToMerge.Contains(col))
            {
                return;
            }
            for (int i = 0; i < this.RowCount; i++)
            {
                HeaderCell hc = this.GetCell(i, col);
                if (hc.MergerdCount > 1)
                {
                    b_FitHide = false;
                }
            }
            if (!b_FitHide)
            {
                MessageBox.Show("Couldnn't merge cells whose column contains merged cells!", "Failed");
                return;
            }
            this.ColsToMerge.Add(col);
        }
Exemple #2
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;
                        }
                        ;
                    }
                }
            }
        }
Exemple #3
0
        public HeadersData(SerializationInfo info, StreamingContext context)
        {
            try
            {
                this._RowCount = info.GetInt32("_RowCount");
            }
            catch
            {
                this._RowCount = 0;
            }
            try
            {
                this._ColCount = info.GetInt32("_ColCount");
            }
            catch
            {
                this._ColCount = 0;
            }
            try
            {
                this._Rows = info.GetValue("_Rows", typeof(ArrayList)) as ArrayList;
            }
            catch
            {
                this._Rows = new ArrayList();
            }
            try
            {
                this._CurCell = info.GetValue("_CurCell", typeof(HeaderCell)) as HeaderCell;
            }
            catch
            {
                this._CurCell = null;
            }

            try
            {
                this._GridLine = info.GetBoolean("_GridLine");
            }
            catch
            {
                this._GridLine = true;
            }

            //Added this code at 2008-11-5 14:13:58@Simon
            try
            {
                this._ColsToMerge = info.GetValue("_ColsToMerge", typeof(ArrayList)) as ArrayList;
            }
            catch
            {
                this._ColsToMerge = new ArrayList();
            }
        }
Exemple #4
0
        public void CopyHeaderFromField(ArrayList prnHeaders)
        {
            if (prnHeaders.Count != this.ColCount)
            {
                return;
            }
            int row = this._CurCell.Row;

            ArrayList MergedGroup = new ArrayList();

            int nCount = 1;

            for (int i = 0; i < prnHeaders.Count; i++)
            {
                HeaderCell hc = this.GetCell(row, i);
                hc.MergerdCount = 0;
                hc.MergerdIndex = 0;

                string text = (string)prnHeaders[i];

                if (text == "\n")
                {
                    nCount++;
                }
                else
                {
                    if (i != 0)
                    {
                        MergedGroup.Add(nCount);
                    }

                    nCount = 1;

                    this.SetText(row, i, text);
                }
            }
            MergedGroup.Add(nCount);
            int startCol = 0;

            foreach (int nCol in MergedGroup)
            {
                for (int k = startCol; k < startCol + nCol; k++)
                {
                    if (nCol > 1)
                    {
                        HeaderCell hc = this.GetCell(row, k);
                        hc.MergerdCount = nCol;
                        hc.MergerdIndex = k - startCol;
                    }
                }

                startCol += nCol;
            }
        }
Exemple #5
0
        public HeaderCell[] GetMergedCells(LabelInfo info)
        {
            int count = info.MergedColMax - info.MergedColMin + 1;

            HeaderCell[] MergedCells = new HeaderCell[count];
            for (int i = 0; i < count; i++)
            {
                HeaderCell cell = GetCell(info.RowIndex, i + info.MergedColMin);
                MergedCells[i] = cell;
            }
            return(MergedCells);
        }
Exemple #6
0
        public HeaderRow Copy()
        {
            HeaderRow hr = new HeaderRow(this._RowIndex, this._ColCount);

            hr.Cells.Clear();
            foreach (object obj in this._Cells)
            {
                HeaderCell hc = (obj as HeaderCell).Copy();
                hr.Cells.Add(hc);
            }
            return(hr);
        }
Exemple #7
0
 private void Resize()
 {
     for (int i = 0; i < this._Rows.Count; i++)
     {
         HeaderRow hr = this.GetRow(i);
         for (int j = 0; j < hr.ColCount; j++)
         {
             HeaderCell hc = hr.GetCell(j);
             hc.Row = i;
             hc.Col = j;
         }
     }
 }
Exemple #8
0
        private void MyClick(object sender, System.EventArgs e)
        {
            Label     lctl    = sender as Label;
            LabelInfo lblinfo = (LabelInfo)lctl.Tag;

            if (_CurCell == null || this.SelCount == 0)
            {
                _SelCells.Clear();
                _SelCells.Add(lctl);
            }
            else
            {
                int row = _CurCell.Row;
                int col = _CurCell.Col;

                if (row == lblinfo.RowIndex && this.SelCount == 1)
                {
                    int mincol = Math.Min(col, lblinfo.MergedColMax);
                    int maxcol = Math.Max(col, lblinfo.MergedColMax);
                    for (int i = mincol; i <= maxcol; i++)
                    {
                        if (this.ColsToMerge.Contains(i))
                        {
                            _SelCells.Clear();
                            _SelCells.Add(lctl);
                            _CurCell = GetCell(lblinfo.RowIndex, lblinfo.MergedColMin);
                            if (this.txtEdit != null)
                            {
                                this.txtEdit.Text = this._CurCell.Text;
                            }
                            this.DrawSelCells();
                            return;
                        }
                    }

                    _SelCells.Clear();
                    this.AddLabelToArray(row, mincol, maxcol);
                }
                else
                {
                    _SelCells.Clear();
                    _SelCells.Add(lctl);
                }
            }
            _CurCell = GetCell(lblinfo.RowIndex, lblinfo.MergedColMin);
            this.DrawSelCells();
            if (this.txtEdit != null)
            {
                this.txtEdit.Text = this._CurCell.Text;
            }
        }
Exemple #9
0
        public void RaiseClickEvents(HeaderCell hc)
        {
            if (hc == null)
            {
                return;
            }
            Label lbl = this.GetLabelByCell(hc);

            if (lbl == null)
            {
                return;
            }
            this.MyClick(lbl, new EventArgs());
        }
Exemple #10
0
        private Label GetLabelByCell(HeaderCell hc)
        {
            string sname = string.Format("{0}", hc.Row * ColCount + hc.Col);

            foreach (Control ctrl in this._HeaderContainer.Controls)
            {
                System.Diagnostics.Debug.WriteLine(ctrl.Name);
                if (ctrl.Name == sname)
                {
                    return(ctrl as Label);
                }
            }
            return(null);
        }
Exemple #11
0
        public HeaderCell Copy()
        {
            HeaderCell newHeaderCell = new HeaderCell(Row, Col);

            newHeaderCell._MergerdIndex      = this._MergerdIndex;
            newHeaderCell._MergerdCount      = this._MergerdCount;
            newHeaderCell.Text               = this.Text;
            newHeaderCell.NeedChangeStyle    = this.NeedChangeStyle;
            newHeaderCell._updateAllRowstyle = this._updateAllRowstyle;
            if (CellStyle != null)
            {
                newHeaderCell.CellStyle = this.CellStyle.Copy();
            }
            return(newHeaderCell);
        }
Exemple #12
0
        public HeaderCell MergeCells()
        {
            if (this.SelCount <= 1)
            {
                return(null);
            }
            int count = this.SelCount;

            for (int i = 0; i < this.SelCount; i++)
            {
                Label     SelLbl  = this._SelCells[i] as Label;
                LabelInfo lblinfo = (LabelInfo)SelLbl.Tag;
                if (lblinfo.MergedColMax - lblinfo.MergedColMin > 0)
                {
                    count += lblinfo.MergedColMax - lblinfo.MergedColMin;
                }
            }

            int row = 0;
            int col = -1;

            for (int i = 0; i < this.SelCount; i++)
            {
                Label     SelLbl  = this._SelCells[i] as Label;
                LabelInfo lblinfo = (LabelInfo)SelLbl.Tag;
                row = lblinfo.RowIndex;
                if (col < 0)
                {
                    col = lblinfo.MergedColMin;
                }
                else
                {
                    col = Math.Min(col, lblinfo.MergedColMin);
                }
                for (int k = lblinfo.MergedColMin; k <= lblinfo.MergedColMax; k++)
                {
                    HeaderCell hc = GetCell(lblinfo.RowIndex, k);
                    hc.MergerdCount = count;
                    hc.MergerdIndex = i + k - lblinfo.MergedColMin;
                }
            }
            if (col < 0 || col >= this.ColCount || row < 0 || row >= this.RowCount)
            {
                return(null);
            }
            return(GetCell(row, col));
        }
Exemple #13
0
        public void RemoveCol()
        {
            int ColIndex = this.ColCount - 1;

            if (ColIndex < 0)
            {
                return;
            }
            for (int i = 0; i < this._RowCount; i++)
            {
                GetRow(i).RemoveCol(ColIndex);
            }
            this.ColCount--;
            this.Resize();
            this._SelCells.Clear();
            this._CurCell = null;
        }
Exemple #14
0
        public HeaderRow(int iRow, ArrayList dataList)
        {
            this._RowIndex = iRow;

            this._ColCount = dataList.Count;

            _Cells = new ArrayList();

            for (int i = 0; i < _ColCount; i++)
            {
                HeaderCell hc = new HeaderCell(iRow, i);

                hc.Text = dataList[i].ToString();

                _Cells.Add(hc);
            }
        }
Exemple #15
0
        public void RemoveRow()
        {
            if (this.SelCount <= 0 || _CurCell == null)
            {
                //MessageBox.Show("Please select the cells you want to Unmerge!","Select cells",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }

            if (this._RowCount > 0)
            {
                int index = _CurCell.Row;
                this._Rows.RemoveAt(index);
                this._RowCount--;
                this.Resize();
                this._SelCells.Clear();
                this._CurCell = null;
            }
        }
Exemple #16
0
        public HeaderRow(int Row, int nCols, string[] strRow)
        {
            this._RowIndex = Row;

            this._ColCount = nCols;

            _Cells = new ArrayList();

            for (int i = 0; i < nCols; i++)
            {
                HeaderCell hc = new HeaderCell(Row, i);

                if (i < strRow.Length)
                {
                    hc.Text = strRow[i];
                }

                _Cells.Add(hc);
            }
        }
Exemple #17
0
        public void RemoveCol(int ColIndex)
        {
            if (ColIndex >= 0 && ColIndex < this.ColCount)
            {
                HeaderCell hc = this.GetCell(ColIndex);

                //Adjust the cells' Properties of "MergerdCount'and "MergerdIndex"
                int count = hc.MergerdCount;

                if (count > 0)
                {
                    count = count - 2 > 0 ? count - 1: 0;
                    int MergeStartIndex = ColIndex - hc.MergerdIndex;
                    int MergeEndIndex   = MergeStartIndex + hc.MergerdCount - 1;
                    for (int i = MergeStartIndex; i < ColIndex; i++)
                    {
                        if (i < 0 || i >= ColCount)
                        {
                            break;
                        }
                        GetCell(i).MergerdCount = count;
                    }
                    for (int i = ColIndex + 1; i < MergeEndIndex; i++)
                    {
                        if (i < 0 || i >= ColCount)
                        {
                            break;
                        }
                        GetCell(i).MergerdCount = count;
                        GetCell(i).MergerdIndex--;
                    }
                }

                this._Cells.RemoveAt(ColIndex);
                this.ColCount--;
            }
        }
Exemple #18
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;
        }
Exemple #19
0
        public void PaintCells(Control Ctrl, Rectangle rect, IMultiHeader HeaderView)
        {
            ArrayList formats = new ArrayList();

            HeaderView.GetPrnHeader(out formats);

            this._HeaderContainer = Ctrl;
            if (this.ColCount <= 0)
            {
                return;
            }
            int lblWidth  = rect.Width / this.ColCount;
            int lblHeight = rect.Height / this.RowCount;

            this._SelCells.Clear();
            this._CurCell = null;
            #region add Controls
            for (int i = 0; i < this.RowCount; i++)
            {
                int lblLocX = rect.X;
                int lblLocY = rect.Y + i * lblHeight;
                for (int j = 0; j < GetRow(i).ColCount; j++)
                {
                    HeaderCell hc = GetCell(i, j);

                    Rectangle LabelRect = new Rectangle(lblLocX, lblLocY, lblWidth, lblHeight);

                    LabelInfo info = new LabelInfo();
                    info.RowIndex = i;
                    string Lbltext = hc.Text;

                    info.MergedColMax = info.MergedColMin = j;

                    string LblName = string.Format("{0}", i * ColCount + j);
                    if (hc.MergerdCount > 0)
                    {
                        LabelRect.Width = hc.MergerdCount * lblWidth;
                        j += hc.MergerdCount - 1;
                        info.MergedColMax = j;
                    }

                    #region Modify codes at 2008-11-5 15:16:51@Simon
                    if (this.ColsToMerge.Contains(j) && (HeaderView.HaveHeader || i > 0))
                    {
                        lblLocX += LabelRect.Width;
                        continue;
                    }
                    #endregion                            //End Modify

                    info.LblLoc  = LabelRect.Location;
                    info.LblSize = LabelRect.Size;
                    Label lblcell = new Label();
                    lblcell.Name      = LblName;
                    lblcell.Text      = Lbltext;
                    lblcell.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

                    lblcell.BackColor = Control.DefaultBackColor;

                    if (i == 0 && !HeaderView.HaveHeader && j < formats.Count)
                    {
                        StringFormatFlags strflags = (StringFormatFlags)formats[j];                        //Added this code at 2008-11-5 8:53:15@Simon

                        if ((strflags & StringFormatFlags.DirectionVertical) == StringFormatFlags.DirectionVertical)
                        {
                            lblcell.Paint += new PaintEventHandler(DrawLabelVertical);
                        }
                    }


                    info.DefaultBackColor = lblcell.BackColor;

                    lblcell.Tag = info;

                    if (this.GridLine)
                    {
                        lblcell.BorderStyle = BorderStyle.FixedSingle;
                        lblcell.Location    = LabelRect.Location;
                        if (this.ColsToMerge.Contains(j))
                        {
                            lblcell.Size = new Size(lblWidth, rect.Height);
                            Ctrl.Controls.Add(lblcell);
                            lblLocX += LabelRect.Width;
                            continue;
                        }
                        else
                        {
                            lblcell.Size = LabelRect.Size;
                        }
                    }
                    else
                    {
                        lblcell.BorderStyle = BorderStyle.None;
                        lblcell.Location    = new Point(LabelRect.X + 1, LabelRect.Y + 1);
                        if (this.ColsToMerge.Contains(j))
                        {
                            lblcell.Size = new Size(LabelRect.Width - 2, rect.Height - 2);
                            lblLocX     += LabelRect.Width;
                            Ctrl.Controls.Add(lblcell);
                            continue;
                        }
                        else
                        {
                            lblcell.Size = new Size(LabelRect.Width - 2, LabelRect.Height - 2);
                        }
                    }



                    lblLocX += LabelRect.Width;

                    lblcell.Click += new System.EventHandler(MyClick);
                    Ctrl.Controls.Add(lblcell);
                }
            }
            #endregion
        }
Exemple #20
0
        public void SetCellStyle(Label lblcell, HeaderCell hc)
        {
            if (hc.NeedChangeStyle)
            {
                Color backcolor = hc.CellStyle.BackgroundColor;
                if (backcolor == Color.Empty || backcolor == Color.Transparent)
                {
                    lblcell.BackColor = Control.DefaultBackColor;
                }
                else
                {
                    lblcell.BackColor = hc.CellStyle.BackgroundColor;
                }
                lblcell.ForeColor = hc.CellStyle.ForeColor;
                lblcell.Font      = hc.CellStyle.Font;
                if (hc.CellStyle.Sides == DevExpress.XtraPrinting.BorderSide.None)
                {
                    lblcell.BorderStyle = BorderStyle.None;
                }

                StringFormatFlags strflags = hc.CellStyle.StringFormat;                //Added this code at 2008-11-5 8:53:15@Simon

                if ((strflags & StringFormatFlags.DirectionVertical) == StringFormatFlags.DirectionVertical)
                {
                    lblcell.Paint += new PaintEventHandler(DrawLabelVertical);
                }

                #region Aliginment
                switch (hc.CellStyle.HorzAlignment)
                {
                case HorzAlignment.Default:
                case HorzAlignment.Center:
                {
                    switch (hc.CellStyle.VertAlignment)
                    {
                    case VertAlignment.Default:
                    case VertAlignment.Center:
                        lblcell.TextAlign = ContentAlignment.MiddleCenter;
                        break;

                    case VertAlignment.Top:
                        lblcell.TextAlign = ContentAlignment.TopCenter;
                        break;

                    case VertAlignment.Bottom:
                        lblcell.TextAlign = ContentAlignment.BottomCenter;
                        break;
                    }
                }
                break;

                case HorzAlignment.Near:
                {
                    switch (hc.CellStyle.VertAlignment)
                    {
                    case VertAlignment.Default:
                    case VertAlignment.Center:
                        lblcell.TextAlign = ContentAlignment.MiddleLeft;
                        break;

                    case VertAlignment.Top:
                        lblcell.TextAlign = ContentAlignment.TopLeft;
                        break;

                    case VertAlignment.Bottom:
                        lblcell.TextAlign = ContentAlignment.BottomLeft;
                        break;
                    }
                }
                break;

                case HorzAlignment.Far:
                {
                    switch (hc.CellStyle.VertAlignment)
                    {
                    case VertAlignment.Default:
                    case VertAlignment.Center:
                        lblcell.TextAlign = ContentAlignment.MiddleRight;
                        break;

                    case VertAlignment.Top:
                        lblcell.TextAlign = ContentAlignment.TopRight;
                        break;

                    case VertAlignment.Bottom:
                        lblcell.TextAlign = ContentAlignment.BottomRight;
                        break;
                    }
                }
                break;
                }
                #endregion
            }
            else
            {
                lblcell.BackColor = Control.DefaultBackColor;
            }
        }