コード例 #1
0
 protected virtual Size GetRowSize(GridViewRowInfo row, HtmlViewRowLayout rowLayout)
 {
     if (this.rowSize == Size.Empty)
     {
         int width1 = 0;
         int height = rowLayout.GetRowHeight(row) + this.GridView.TableElement.RowSpacing;
         foreach (GridViewColumn renderColumn in (IEnumerable <GridViewColumn>)rowLayout.RenderColumns)
         {
             if (!(renderColumn is GridViewRowHeaderColumn) && !(renderColumn is GridViewIndentColumn))
             {
                 HtmlViewCellArrangeInfo arrangeInfo = rowLayout.GetArrangeInfo(renderColumn);
                 if (arrangeInfo != null)
                 {
                     int width2 = (int)arrangeInfo.Bounds.Width;
                     if ((double)width1 < (double)arrangeInfo.Bounds.X + (double)width2)
                     {
                         width1 = (int)arrangeInfo.Bounds.X + width2;
                     }
                 }
             }
         }
         this.rowSize = new Size(width1, height);
     }
     return(this.rowSize);
 }
コード例 #2
0
        public override void DrawPage(
            PrintGridTraverser traverser,
            Rectangle drawArea,
            Graphics graphics,
            GridPrintSettings settings,
            int pageNumber)
        {
            bool flag1  = this.currentPage != pageNumber;
            int  x      = drawArea.X;
            int  y      = drawArea.Y;
            int  height = drawArea.Height;
            HtmlViewRowLayout rowLayout = new HtmlViewRowLayout(this.GridView.ViewDefinition as HtmlViewDefinition);

            rowLayout.IgnoreColumnVisibility = settings.PrintHiddenColumns;
            rowLayout.Context = GridLayoutContext.Printer;
            rowLayout.Initialize(this.GridView.TableElement);
            int num1 = 0;

            foreach (GridViewColumn renderColumn in (IEnumerable <GridViewColumn>)rowLayout.RenderColumns)
            {
                if (renderColumn is GridViewRowHeaderColumn || renderColumn is GridViewIndentColumn)
                {
                    num1 += rowLayout.GetColumnWidth(renderColumn);
                }
            }
            if (settings.FitWidthMode == PrintFitWidthMode.FitPageWidth)
            {
                this.GridView.BeginUpdate();
                GridViewAutoSizeColumnsMode autoSizeColumnsMode = rowLayout.ViewTemplate.AutoSizeColumnsMode;
                rowLayout.ViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
                rowLayout.MeasureRow(new SizeF((float)drawArea.Width, (float)drawArea.Height));
                rowLayout.ViewTemplate.AutoSizeColumnsMode = autoSizeColumnsMode;
                this.GridView.EndUpdate(false);
            }
            else
            {
                this.GridView.BeginUpdate();
                GridViewAutoSizeColumnsMode autoSizeColumnsMode = rowLayout.ViewTemplate.AutoSizeColumnsMode;
                rowLayout.ViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None;
                rowLayout.MeasureRow(new SizeF((float)this.GridView.Width, (float)this.GridView.Height));
                rowLayout.ViewTemplate.AutoSizeColumnsMode = autoSizeColumnsMode;
                this.GridView.EndUpdate(false);
            }
            int num2 = (int)rowLayout.DesiredSize.Width - num1;

            if (settings.FitWidthMode == PrintFitWidthMode.NoFitCentered)
            {
                x += (drawArea.Width - num2) / 2;
            }
            if (this.firstPage && pageNumber == 1 || settings.PrintHeaderOnEachPage)
            {
                this.firstPage = false;
                this.PrintRow((GridViewRowInfo)this.GridView.MasterView.TableHeaderRow, rowLayout, settings, x, y, graphics);
                int num3 = rowLayout.GetRowHeight((GridViewRowInfo)this.GridView.MasterView.TableHeaderRow) + this.GridView.TableElement.RowSpacing;
                y      += num3;
                height -= num3;
            }
            int  num4  = y;
            bool flag2 = true;

            while (traverser.MoveNext())
            {
                int rowHeight = rowLayout.GetRowHeight(traverser.Current);
                if (traverser.Current is GridViewGroupRowInfo || traverser.Current is GridViewDataRowInfo || traverser.Current is GridViewSummaryRowInfo)
                {
                    if ((y + rowHeight >= drawArea.Bottom || num4 + rowHeight >= drawArea.Bottom) && !flag2)
                    {
                        traverser.MovePrevious();
                        num4 = y;
                        bool flag3 = this.currentPage != pageNumber;
                        ++this.currentPage;
                        if (!flag3)
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (traverser.Current is GridViewGroupRowInfo)
                        {
                            if (settings.PrintGrouping)
                            {
                                if (this.currentPage == pageNumber)
                                {
                                    this.PrintRowWideCell(traverser.Current, rowLayout, settings, x, y, graphics);
                                    y += rowHeight + this.GridView.TableElement.RowSpacing;
                                }
                                else
                                {
                                    num4 += rowHeight + this.GridView.TableElement.RowSpacing;
                                }
                            }
                        }
                        else if (!(traverser.Current is GridViewSummaryRowInfo) || settings.PrintSummaries)
                        {
                            if (this.currentPage == pageNumber)
                            {
                                this.PrintRow(traverser.Current, rowLayout, settings, x, y, graphics);
                                y += rowHeight + this.GridView.TableElement.RowSpacing;
                            }
                            else
                            {
                                num4 += rowHeight + this.GridView.TableElement.RowSpacing;
                            }
                        }
                        else
                        {
                            continue;
                        }
                        if (height < rowHeight && flag2)
                        {
                            ++this.currentPage;
                            break;
                        }
                        flag2 = false;
                    }
                }
            }
        }