Beispiel #1
0
        protected virtual CellPrintElement CreateGroupCellPrintElement(
            GridViewGroupRowInfo row)
        {
            CellPrintElement cellPrintElement1 = new CellPrintElement();

            cellPrintElement1.BackColor   = this.GridView.PrintStyle.GroupRowBackColor;
            cellPrintElement1.BorderColor = this.GridView.PrintStyle.BorderColor;
            Color backColor = cellPrintElement1.BackColor;

            if (cellPrintElement1.BackColor != Color.Transparent && cellPrintElement1.BackColor != Color.Empty)
            {
                cellPrintElement1.DrawFill = true;
            }
            string summary = row.GetSummary();

            cellPrintElement1.Text = row.HeaderText;
            if (summary.Length > 0)
            {
                CellPrintElement cellPrintElement2 = cellPrintElement1;
                cellPrintElement2.Text = cellPrintElement2.Text + " | " + summary;
            }
            if (this.GridView.RightToLeft == RightToLeft.Yes)
            {
                cellPrintElement1.StringFormatFlags |= StringFormatFlags.DirectionRightToLeft;
            }
            cellPrintElement1.TextAlignment = ContentAlignment.MiddleLeft;
            return(cellPrintElement1);
        }
        protected virtual void PrintRowWideCell(
            GridViewRowInfo row,
            ColumnGroupRowLayout rowLayout,
            GridPrintSettings settings,
            int currentX,
            int currentY,
            Graphics graphics)
        {
            Size             rowSize   = this.GetRowSize(row, rowLayout);
            Rectangle        rectangle = new Rectangle(new Point(currentX, currentY), rowSize);
            CellPrintElement printCell = new CellPrintElement();

            if (row is GridViewGroupRowInfo)
            {
                printCell = this.CreateGroupCellPrintElement(row as GridViewGroupRowInfo);
                if (printCell.Font != settings.GroupRowFont)
                {
                    if (settings.GroupRowFont != null)
                    {
                        printCell.Font = settings.GroupRowFont;
                    }
                    else
                    {
                        settings.GroupRowFont = printCell.Font;
                    }
                }
            }
            printCell.TextPadding = this.GridView.PrintStyle.CellPadding;
            printCell.RightToLeft = this.GridView.RightToLeft == RightToLeft.Yes;
            PrintCellFormattingEventArgs e = new PrintCellFormattingEventArgs(row, (GridViewColumn)null, printCell);

            this.OnPrintCellFormatting(e);
            e.PrintCell.Paint(graphics, rectangle);
            this.OnPrintCellPaint(new PrintCellPaintEventArgs(graphics, row, (GridViewColumn)null, rectangle));
        }
Beispiel #3
0
        protected virtual CellPrintElement CreateHeaderCellPrintElement(
            GridViewColumn column)
        {
            CellPrintElement cellPrintElement = new CellPrintElement();

            cellPrintElement.BackColor   = this.GridView.PrintStyle.HeaderCellBackColor;
            cellPrintElement.BorderColor = this.GridView.PrintStyle.BorderColor;
            Color backColor = cellPrintElement.BackColor;

            if (cellPrintElement.BackColor != Color.Transparent && cellPrintElement.BackColor != Color.Empty)
            {
                cellPrintElement.DrawFill = true;
            }
            cellPrintElement.Text            = column.HeaderText;
            cellPrintElement.TextAlignment   = column.HeaderTextAlignment;
            cellPrintElement.StringTrimming |= StringTrimming.EllipsisCharacter;
            if (this.GridView.RightToLeft == RightToLeft.Yes)
            {
                cellPrintElement.StringFormatFlags |= StringFormatFlags.DirectionRightToLeft;
            }
            if (!column.WrapText)
            {
                cellPrintElement.StringFormatFlags |= StringFormatFlags.NoWrap;
            }
            return(cellPrintElement);
        }
Beispiel #4
0
        protected virtual CellPrintElement CreateImageCellPrintElement(
            GridViewCellInfo cellInfo)
        {
            CellPrintElement cellPrintElement = new CellPrintElement();
            object           obj = cellInfo.Value;

            if (obj == null || obj == DBNull.Value)
            {
                cellPrintElement.Image = (Image)null;
                return(cellPrintElement);
            }
            if (obj is byte[])
            {
                cellPrintElement.Image = ImageHelper.GetImageFromBytes((byte[])obj);
            }
            else if (obj is Image)
            {
                cellPrintElement.Image = obj as Image;
            }
            if (cellPrintElement.Image != null)
            {
                GridViewImageColumn columnInfo = cellInfo.ColumnInfo as GridViewImageColumn;
                cellPrintElement.ImageLayout    = columnInfo != null ? columnInfo.ImageLayout : ImageLayout.Stretch;
                cellPrintElement.ImageAlignment = columnInfo != null ? columnInfo.ImageAlignment : ContentAlignment.MiddleCenter;
            }
            return(cellPrintElement);
        }
Beispiel #5
0
 public PrintCellFormattingEventArgs(
     GridViewRowInfo row,
     GridViewColumn column,
     CellPrintElement printCell)
 {
     this.row       = row;
     this.column    = column;
     this.printCell = printCell;
 }
Beispiel #6
0
        protected virtual void PrintRowWideCell(
            GridViewRowInfo row,
            TableViewRowLayout rowLayout,
            GridPrintSettings settings,
            int currentX,
            int currentY,
            Graphics graphics)
        {
            int              num1      = row.Group != null ? row.Group.Level + 1 : 0;
            int              num2      = row.HierarchyLevel + 1 - num1;
            Size             rowSize   = this.GetRowSize(row, rowLayout);
            Rectangle        rectangle = new Rectangle(currentX + num2 * settings.HierarchyIndent, currentY, rowSize.Width - num2 * settings.HierarchyIndent, rowSize.Height);
            CellPrintElement printCell = new CellPrintElement();

            if (row is GridViewGroupRowInfo)
            {
                if (this.PrintPages.Count > 0 && !settings.PrintHierarchy)
                {
                    rectangle.Width -= this.PrintPages[this.CurrentPrintPage].Count - 1;
                }
                printCell = this.CreateGroupCellPrintElement(row as GridViewGroupRowInfo);
                if (printCell.Font != settings.GroupRowFont)
                {
                    if (settings.GroupRowFont != null)
                    {
                        printCell.Font = settings.GroupRowFont;
                    }
                    else
                    {
                        settings.GroupRowFont = printCell.Font;
                    }
                }
            }
            printCell.TextPadding = this.GridView.PrintStyle.CellPadding;
            printCell.RightToLeft = this.GridView.RightToLeft == RightToLeft.Yes;
            PrintCellFormattingEventArgs e = new PrintCellFormattingEventArgs(row, (GridViewColumn)null, printCell);

            this.OnPrintCellFormatting(e);
            e.PrintCell.Paint(graphics, rectangle);
            this.OnPrintCellPaint(new PrintCellPaintEventArgs(graphics, row, (GridViewColumn)null, rectangle));
        }
Beispiel #7
0
        protected virtual CellPrintElement CreateSummaryCellPrintElement(
            GridViewCellInfo cellInfo)
        {
            CellPrintElement cellPrintElement = new CellPrintElement();

            cellPrintElement.BackColor   = this.GridView.PrintStyle.SummaryCellBackColor;
            cellPrintElement.BorderColor = this.GridView.PrintStyle.BorderColor;
            Color backColor = cellPrintElement.BackColor;

            if (cellPrintElement.BackColor != Color.Transparent && cellPrintElement.BackColor != Color.Empty)
            {
                cellPrintElement.DrawFill = true;
            }
            cellPrintElement.Text = cellInfo.Value != null?cellInfo.Value.ToString() : string.Empty;

            if (this.GridView.RightToLeft == RightToLeft.Yes)
            {
                cellPrintElement.StringFormatFlags |= StringFormatFlags.DirectionRightToLeft;
            }
            return(cellPrintElement);
        }
Beispiel #8
0
        protected virtual CellPrintElement CreateDataCellPrintElement(
            GridViewCellInfo cellInfo)
        {
            CellPrintElement cellPrintElement;

            if (cellInfo.ColumnInfo is GridViewImageColumn)
            {
                cellPrintElement          = this.CreateImageCellPrintElement(cellInfo);
                cellPrintElement.DrawText = false;
            }
            else
            {
                cellPrintElement = new CellPrintElement();
            }
            if (this.GridView.PrintStyle.PrintAlternatingRowColor && this.GridView.PrintStyle.PrintTraverser.Current.Index % 2 == 1)
            {
                cellPrintElement.BackColor = this.GridView.PrintStyle.AlternatingRowColor;
            }
            else
            {
                cellPrintElement.BackColor = this.GridView.PrintStyle.CellBackColor;
            }
            cellPrintElement.BorderColor = this.GridView.PrintStyle.BorderColor;
            Color backColor = cellPrintElement.BackColor;

            if (cellPrintElement.BackColor != Color.Transparent && cellPrintElement.BackColor != Color.Empty)
            {
                cellPrintElement.DrawFill = true;
            }
            GridViewDataColumn     columnInfo1 = cellInfo.ColumnInfo as GridViewDataColumn;
            object                 lookupValue = cellInfo.Value;
            GridViewComboBoxColumn columnInfo2 = cellInfo.ColumnInfo as GridViewComboBoxColumn;

            if (columnInfo2 != null && columnInfo2.HasLookupValue)
            {
                lookupValue = columnInfo2.GetLookupValue(lookupValue);
            }
            if (columnInfo1 != null && !string.IsNullOrEmpty(columnInfo1.FormatString))
            {
                if (cellInfo.ColumnInfo is GridViewComboBoxColumn)
                {
                    GridViewComboBoxColumn columnInfo3 = (GridViewComboBoxColumn)cellInfo.ColumnInfo;
                    columnInfo1.DataType          = columnInfo3.DisplayMemberDataType;
                    columnInfo1.DataTypeConverter = TypeDescriptor.GetConverter(columnInfo3.DisplayMemberDataType);
                    cellPrintElement.Text         = RadDataConverter.Instance.Format(lookupValue, typeof(string), (IDataConversionInfoProvider)columnInfo1) as string;
                }
                else
                {
                    cellPrintElement.Text = RadDataConverter.Instance.Format(lookupValue, typeof(string), (IDataConversionInfoProvider)columnInfo1) as string;
                }
            }
            else
            {
                cellPrintElement.Text = lookupValue != null?lookupValue.ToString() : string.Empty;
            }
            cellPrintElement.TextAlignment  = cellInfo.ColumnInfo.TextAlignment;
            cellPrintElement.StringTrimming = StringTrimming.EllipsisCharacter;
            if (this.GridView.RightToLeft == RightToLeft.Yes)
            {
                cellPrintElement.StringFormatFlags |= StringFormatFlags.DirectionRightToLeft;
            }
            if (!cellInfo.ColumnInfo.WrapText)
            {
                cellPrintElement.StringFormatFlags |= StringFormatFlags.NoWrap;
            }
            return(cellPrintElement);
        }