Exemple #1
0
        private void method_5(Graphics graphics_1, MultiHeader multiHeader_1, Body body_1)
        {
            int width = body_1.Rectangle.Width;
            int num   = body_1.Rectangle.Height;
            int x;
            int y;

            if (multiHeader_1 != null)
            {
                x    = multiHeader_1.Rectangle.X;
                y    = multiHeader_1.Rectangle.Y;
                num += multiHeader_1.Rectangle.Height;
            }
            else
            {
                x = body_1.Rectangle.X;
                y = body_1.Rectangle.Y;
            }
            if (this.IsSubTotalPerPage)
            {
                MultiHeader multiHeader = new MultiHeader(1, 1);
                num += multiHeader.RowHeight;
            }
            Rectangle     rectangle     = new Rectangle(x, y, width, num);
            Pen           pen           = new Pen(Color.Black, 1f);
            DrawRectangle drawRectangle = new DrawRectangle();

            drawRectangle.Graphics  = graphics_1;
            drawRectangle.Rectangle = rectangle;
            drawRectangle.Pen       = pen;
            switch (this.GridBorder)
            {
            case GridBorderFlag.Single:
                drawRectangle.Draw();
                break;

            case GridBorderFlag.SingleBold:
                drawRectangle.Pen.Width = 2f;
                drawRectangle.Draw();
                if (multiHeader_1 != null)
                {
                    drawRectangle.Rectangle = body_1.Rectangle;
                    drawRectangle.DrawTopLine();
                }
                break;

            case GridBorderFlag.Double:
                drawRectangle.Draw();
                rectangle = new Rectangle(x - 2, y - 2, width + 4, num + 4);
                drawRectangle.Rectangle = rectangle;
                drawRectangle.Draw();
                break;

            case GridBorderFlag.DoubleBold:
                drawRectangle.Draw();
                rectangle = new Rectangle(x - 2, y - 2, width + 4, num + 4);
                drawRectangle.Rectangle = rectangle;
                drawRectangle.Pen.Width = 2f;
                drawRectangle.Draw();
                break;
            }
        }
Exemple #2
0
        private bool method_2(Graphics graphics_1)
        {
            bool flag = false;

            if (this.body_0.Rows < 0)
            {
                throw new System.Exception("打印主要网格不能为空,请用Body设置!");
            }
            this.printer_0.Graphics       = graphics_1;
            this.printer_0.PrintDocument  = this.printDocument_0;
            this.printer_0.Sewing         = this.Sewing;
            this.printer_0.PrinterMargins = this.printerMargins_0;
            this.int_1 = this.printer_0.PrinterMargins.Top;
            this.int_0 = this.printer_0.PrinterMargins.Left;
            this.int_2 = this.printer_0.PrinterMargins.Width;
            this.method_3(this.printer_0);
            this.method_4(this.printer_0);
            if (this.title_0 != null && (this.int_3 == 1 || this.title_0.IsDrawAllPage))
            {
                this.title_0.PrinterMargins = this.printerMargins_0;
                this.method_1(this.title_0);
            }
            if (this.caption_0 != null && (this.int_3 == 1 || this.caption_0.IsDrawAllPage))
            {
                this.caption_0.MoveY = 0;
                if (this.title_0 != null && (this.int_3 == 1 || this.title_0.IsDrawAllPage))
                {
                    this.caption_0.MoveY = this.title_0.Height + 5;
                }
                this.caption_0.PrinterMargins = this.printerMargins_0;
                this.method_1(this.caption_0);
            }
            if (this.title_0 != null || this.caption_0 != null)
            {
                this.int_1 += 20;
            }
            int num = 0;
            int i;

            if (!this.body_0.IsAverageColsWidth)
            {
                for (i = 0; i < this.body_0.ColsWidth.Length; i++)
                {
                    num += this.body_0.ColsWidth[i];
                }
                if (num > this.printerMargins_0.Width)
                {
                    this.float_0 = (float)(this.printerMargins_0.Width / num);
                }
                else
                {
                    this.int_2  = num;
                    this.int_0 += (this.printerMargins_0.Width - this.int_2) / 2;
                }
            }
            if (this.top_0 != null && (this.int_3 == 1 || this.top_0.IsDrawAllPage))
            {
                this.method_1(this.top_0);
            }
            if (this.header_0 != null && (this.int_3 == 1 || this.header_0.IsDrawAllPage))
            {
                this.method_1(this.header_0);
            }
            if ((this.top_0 != null || this.header_0 != null) &&
                (this.int_3 == 1 || (this.top_0 != null && this.top_0.IsDrawAllPage) ||
                 (this.header_0 != null && this.header_0.IsDrawAllPage)))
            {
                this.int_1 += 5;
            }
            if (this.multiHeader_0 != null && (this.int_3 == 1 || this.multiHeader_0.IsDrawAllPage))
            {
                this.method_1(this.multiHeader_0);
            }
            float num2 =
                (float)(this.printer_0.PrinterMargins.Height - (this.int_1 - this.printer_0.PrinterMargins.Top));

            if (this._footer != null && this._footer.IsDrawAllPage)
            {
                num2 -= (float)this._footer.Height;
            }
            if (this.bottom_0 != null && this.bottom_0.IsDrawAllPage)
            {
                num2 -= (float)this.bottom_0.Height;
            }
            if (num2 < 0f)
            {
                throw new System.Exception("预留给打印主要网格的空间太小,请适当调整!");
            }
            int num3 = (int)(num2 / (float)this.body_0.RowHeight);

            if (this.RowsPerPage > 0 && this.RowsPerPage < num3)
            {
                num3 = this.RowsPerPage;
            }
            if (this.IsSubTotalPerPage)
            {
                num3--;
            }
            Body body;

            if (this.RowsPerPage > 0 && this.RowsPerPage < num3)
            {
                body = new Body(num3, this.body_0.Cols);
            }
            else
            {
                if (num3 > this.body_0.Rows - this.int_4)
                {
                    num3 = this.body_0.Rows - this.int_4;
                }
                body = new Body(num3, this.body_0.Cols);
            }
            string[,] array = new string[num3, this.body_0.Cols];
            i = 0;
            while (i < num3 && this.int_4 < this.body_0.Rows)
            {
                for (int j = 0; j < this.body_0.Cols; j++)
                {
                    array[i, j] = this.body_0.GetText(this.int_4, j);
                }
                this.int_4++;
                i++;
            }
            body.GridText           = array;
            body.ColsAlignString    = this.body_0.ColsAlignString;
            body.ColsWidth          = this.body_0.ColsWidth;
            body.IsAverageColsWidth = this.body_0.IsAverageColsWidth;
            body.Font = this.body_0.Font;
            this.method_1(body);
            if (this.int_4 < this.body_0.Rows)
            {
                flag = true;
            }
            if (this.bool_1 && this.string_0 != "")
            {
                try
                {
                    MultiHeader multiHeader = new MultiHeader(1, this.body_0.Cols);
                    multiHeader.ColsWidth     = this.body_0.ColsWidth;
                    multiHeader.Graphics      = graphics_1;
                    multiHeader.PrintDocument = this.printDocument_0;
                    multiHeader.Sewing        = this.sewing_0;
                    multiHeader.Rectangle     = new Rectangle(this.int_0, this.int_1, this.int_2, multiHeader.Height);
                    multiHeader.SetText(0, 0, "本页小计");
                    multiHeader.SetText(0, 1, "本页小计");
                    string[] array2 = this.string_0.Split(new char[]
                    {
                        ';'
                    });
                    double num4 = 0.0;
                    for (i = 0; i < array2.Length; i++)
                    {
                        int num5 = int.Parse(array2[i]);
                        for (int j = 0; j < array.GetLength(0); j++)
                        {
                            num4 += double.Parse(array[j, num5]);
                        }
                        multiHeader.SetText(0, num5, num4.ToString());
                        num4 = 0.0;
                    }
                    multiHeader.Draw();
                    this.int_1 += multiHeader.Height;
                }
                catch
                {
                }
            }
            if ((this._footer != null || this.bottom_0 != null) &&
                (this.int_3 == 1 || (this.top_0 != null && this.top_0.IsDrawAllPage) ||
                 (this.header_0 != null && this.header_0.IsDrawAllPage)))
            {
                this.int_1 += 5;
            }
            if (this._footer != null && (!flag || this._footer.IsDrawAllPage) && this._footer.IsDrawAllPage)
            {
                this.method_1(this._footer);
            }
            if (this.bottom_0 != null && (!flag || this.bottom_0.IsDrawAllPage))
            {
                if (this.bottom_0.IsDrawAllPage)
                {
                    this.method_1(this.bottom_0);
                }
                else
                {
                    num2 =
                        (float)
                        (this.printer_0.PrinterMargins.Height - (this.int_1 - this.printer_0.PrinterMargins.Top));
                    if (num2 < (float)this.bottom_0.Height)
                    {
                        flag = true;
                    }
                    else
                    {
                        this.method_1(this.bottom_0);
                    }
                }
            }
            this.method_5(graphics_1, this.multiHeader_0, body);
            body.Dispose();
            body = null;
            return(flag);
        }