예제 #1
0
        //private void PreviewModeChanged(bool PreviewMode) => IsPreview = PreviewMode;
        //private void PrnDoc_BeginPrint(object sender, PrintEventArgs e)
        //{
        //	if (e.PrintAction == PrintAction.PrintToPrinter) IsPreview = false; else IsPreview = true;
        //}
        //private void doc_EndPrint(object sender, PrintEventArgs e)
        //{
        //	PageNumber = 0;
        //	for (int i = 0; i < Offset.GetLength(0); i++)
        //	{
        //		Offset[i] = 0;
        //	}
        //}
        private void doc_PrintPage(object sender, PrintPageEventArgs e)
        {
            #region -------------------------- Print variables definitions -----------------------
            PH.G = e.Graphics;
            PrintDocument Doc      = (PrintDocument)sender;
            float         x        = PH.IsPreview ? UserSession.User.Settings.LeftMargin : UserSession.User.Settings.LeftMargin - e.PageSettings.PrintableArea.Left;
            float         y        = PH.IsPreview ? UserSession.User.Settings.TopMargin : UserSession.User.Settings.TopMargin - e.PageSettings.PrintableArea.Top;
            float         y0       = y;
            Font          TextFont = UserSession.User.Settings.TextFont;

            float LineHeight = TextFont.GetHeight(e.Graphics);

            int PrintWidth  = e.MarginBounds.Width / 2;
            int PrintHeight = e.MarginBounds.Bottom;
            int ColOffset   = (PrintWidth + (int)x) * -1;
            #endregion

            PH.PageNumber += 1;

            #region --------------------------- Document header and footer -----------------------
            PH.DrawHeader(x, y, PrintWidth * 2);
            PH.DrawFooter(x, PrintHeight, PrintWidth * 2);
            PH.DrawPageNumber("- " + PH.PageNumber.ToString() + " -", x, PrintHeight, PrintWidth * 2, PageNumberLocation.Footer);
            #endregion

            PH.DrawLine(x + PrintWidth, y, x + PrintWidth, PrintHeight - LineHeight);
            #region ---------------------------- Document body -----------------------------------
            while (y + LineHeight * 4 < PrintHeight && PH.Offset[0] < UsersToPrint.Count())
            {
                PrintObjectData(UsersToPrint[PH.Offset[0]], x, ref y, PrintWidth, TextFont, LineHeight);
                ColOffset *= -1;
                x         += ColOffset;
                if (ColOffset > 0)
                {
                    y = y0;
                }
                else
                {
                    y0 = y;
                }
                PH.Offset[0]++;
            }
            if (PH.Offset[0] < UsersToPrint.Count())
            {
                PH.PrintNextPage(Doc, e);
            }
            #endregion
        }
예제 #2
0
        private void doc_PrintPage(object sender, PrintPageEventArgs e)
        {
            #region -------------------------- Print variables definitions -----------------------
            PH.G = e.Graphics;
            PrintDocument Doc        = (PrintDocument)sender;
            float         x          = PH.IsPreview ? UserSession.User.Settings.LeftMargin : UserSession.User.Settings.LeftMargin - e.PageSettings.PrintableArea.Left;
            float         y          = PH.IsPreview ? UserSession.User.Settings.TopMargin : UserSession.User.Settings.TopMargin - e.PageSettings.PrintableArea.Top;
            float         y0         = y;
            Font          TextFont   = UserSession.User.Settings.TextFont;
            Font          HeaderFont = UserSession.User.Settings.HeaderFont;

            float LineHeight       = TextFont.GetHeight(e.Graphics);
            float HeaderLineHeight = HeaderFont.GetHeight(e.Graphics);

            int PrintWidth  = e.MarginBounds.Width;
            int PrintHeight = e.MarginBounds.Bottom;
            //int ColOffset = (PrintWidth + (int)x) * -1;
            #endregion

            PH.PageNumber += 1;

            #region --------------------------- Document header and footer -----------------------
            PH.DrawHeader(x, y, PrintWidth);
            PH.DrawFooter(x, PrintHeight, PrintWidth);
            PH.DrawPageNumber("- " + PH.PageNumber.ToString() + " -", x, PrintHeight, PrintWidth, PageNumberLocation.Footer);
            #endregion

            #region ------------------------------ Report header -----------------------------------
            if (PH.PageNumber == 1)
            {
                y += LineHeight;
                PH.DrawText(PH.ReportHeader[0], HeaderFont, x, y, PrintWidth, HeaderLineHeight, StringAlignment.Center, Brushes.Black, false);
                y += HeaderLineHeight * 2;
            }
            #endregion
            #region ------------------------------- Column Settings --------------------------
            List <TableCellWithAlignment> Kolumna = new List <TableCellWithAlignment>();
            foreach (OLVColumn Col in olvObsada.AllColumns.Where(c => c.AspectName != "ID"))
            {
                var Align = StringAlignment.Near;
                Enum.TryParse <StringAlignment>(Col.TextAlign.ToString(), out Align);
                Kolumna.Add(new TableCellWithAlignment {
                    Name = Col.AspectName, Label = Col.Text, Size = Col.Width, Alignment = Align
                });
            }
            int SpaceWidth = PrintWidth - Kolumna.Sum(K => K.Size);
            int Space      = SpaceWidth / Kolumna.Count;
            foreach (var col in Kolumna)
            {
                col.Size += Space;
            }
            #endregion

            #region ------------------------------- Table header --------------------------------
            float MultiplyLine = 3;
            int   ColOffset    = 0;
            if (PH.PageNumber == 1)
            {
                for (int i = 0; i < Kolumna.Count(); i++)
                {
                    PH.DrawText(Kolumna[i].Label, new Font(TextFont, FontStyle.Bold), x + ColOffset, y, Kolumna[i].Size, LineHeight * MultiplyLine, StringAlignment.Center, Brushes.Black);
                    ColOffset += Kolumna[i].Size;
                }
                y += LineHeight * MultiplyLine;
            }

            #endregion
            y += LineHeight;
            #region ---------------------------- Document body -----------------------------------
            while (y + HeaderLineHeight * 2 < PrintHeight && PH.Offset[0] < olvObsada.Groups.Count)
            {
                if (PH.Offset[1] == 0)
                {
                    PH.DrawText(olvObsada.Groups[PH.Offset[0]].ToString(), HeaderFont, x, y, PrintWidth, HeaderLineHeight, 0, Brushes.Black, false);
                    y += HeaderLineHeight;
                    PH.DrawLine(x, y, x + PrintWidth, y);
                    y += HeaderLineHeight;
                }

                while (y + LineHeight < PrintHeight && PH.Offset[1] < olvObsada.Groups[PH.Offset[0]].Items.Count)
                {
                    PrintObjectData(olvObsada.OLVGroups[PH.Offset[0]].Items[PH.Offset[1]].RowObject as SubjectSchemeModel, x, ref y, Kolumna, TextFont, LineHeight);
                    PH.Offset[1]++;
                }
                if (PH.Offset[1] < olvObsada.OLVGroups[PH.Offset[0]].Items.Count)
                {
                    PH.PrintNextPage(Doc, e);
                }
                else
                {
                    y           += LineHeight;
                    PH.Offset[1] = 0;
                    PH.Offset[0]++;
                }
            }
            if (PH.Offset[0] < olvObsada.Groups.Count)
            {
                PH.PrintNextPage(Doc, e);
            }
            #endregion
        }
예제 #3
0
        private void tlvAnaliza_PrintPage(object sender, PrintPageEventArgs e)
        {
            #region -------------------------- Print variables definitions -----------------------
            PH.G = e.Graphics;
            PrintDocument Doc                 = (PrintDocument)sender;
            float         x                   = IsPreview ? UserSession.User.Settings.LeftMargin : UserSession.User.Settings.LeftMargin - e.PageSettings.PrintableArea.Left;
            float         y                   = IsPreview ? UserSession.User.Settings.TopMargin : UserSession.User.Settings.TopMargin - e.PageSettings.PrintableArea.Top;
            Font          TextFont            = UserSession.User.Settings.TextFont;
            Font          SubHeaderFont       = UserSession.User.Settings.SubHeaderFont;
            Font          HeaderFont          = UserSession.User.Settings.HeaderFont;
            float         LineHeight          = TextFont.GetHeight(e.Graphics);
            float         SubHeaderLineHeight = SubHeaderFont.GetHeight(e.Graphics);
            float         HeaderLineHeight    = HeaderFont.GetHeight(e.Graphics);
            int           PrintWidth          = e.MarginBounds.Width;
            int           PrintHeight         = e.MarginBounds.Bottom;
            #endregion

            PageNumber += 1;

            #region --------------------------- Document header and footer -----------------------
            PH.DrawHeader(x, y, PrintWidth);
            PH.DrawFooter(x, PrintHeight, PrintWidth);
            PH.DrawPageNumber("- " + PageNumber.ToString() + " -", x, PrintHeight, PrintWidth, PageNumberLocation.Footer);
            #endregion
            #region ------------------------------ Report header -----------------------------------
            if (PageNumber == 1)
            {
                y += LineHeight;
                PH.DrawText(ReportHeader[0], HeaderFont, x, y, PrintWidth, HeaderLineHeight, StringAlignment.Center, Brushes.Black, false);
                y += HeaderLineHeight * 2;
            }
            #endregion
            #region ------------------------------- Column Settings --------------------------
            List <TableCell> Kolumna = new List <TableCell>();
            foreach (OLVColumn Col in tlvStudent.Columns)
            {
                Kolumna.Add(new TableCell {
                    Name = Col.AspectName, Label = Col.Text, Size = Col.Width - 20
                });
            }
            int FirstColWidth = PrintWidth - Kolumna.Where(K => K.Name != "Label").Sum(K => K.Size);
            if (FirstColWidth > 0)
            {
                Kolumna.Where(K => K.Name == "Label").First().Size = FirstColWidth;
            }
            #endregion

            #region ------------------------------- Table header --------------------------------
            float MultiplyLine = 3;
            int   ColOffset    = 0;
            if (PageNumber == 1)
            {
                for (int i = 0; i < Kolumna.Count(); i++)
                {
                    PH.DrawText(Kolumna[i].Label, new Font(TextFont, FontStyle.Bold), x + ColOffset, y, Kolumna[i].Size, LineHeight * MultiplyLine, StringAlignment.Center, Brushes.Black);
                    ColOffset += Kolumna[i].Size;
                }
                y += LineHeight * MultiplyLine;
            }
            ColOffset = 0;
            for (int i = 0; i < Kolumna.Count(); i++)
            {
                PH.DrawText((i + 1).ToString(), new Font(TextFont, FontStyle.Bold | FontStyle.Italic), x + ColOffset, y, Kolumna[i].Size, LineHeight, StringAlignment.Center, Brushes.Black);
                ColOffset += Kolumna[i].Size;
            }
            y += LineHeight * 1.5F;
            #endregion

            #region ------------------------ Table body --------------------------------
            int  index     = 0;
            int  Indent    = 0;
            bool Shade     = false;
            Font PrintFont = null;
            var  ListItems = tlvStudent.FilteredObjects.Cast <ScoreBranch>();
            while (y + LineHeight * 2 < PrintHeight && Offset[0] < ListItems.Count())
            {
                var ListItem = ListItems.ToArray()[Offset[0]];
                y        += LineHeight * 0.5f;
                PrintFont = new Font(TextFont, FontStyle.Bold);
                switch (ListItem.Level)
                {
                case 0:
                    Indent       = 0;
                    MultiplyLine = 2;
                    Shade        = true;
                    index        = 0;
                    break;

                case 1:
                    Indent       = 20;
                    MultiplyLine = 2;
                    Shade        = false;
                    index        = 0;
                    break;

                case 2:
                    Indent       = 40;
                    MultiplyLine = 1;
                    Shade        = false;
                    PrintFont    = TextFont;
                    if (index > 0)
                    {
                        y -= LineHeight * 0.5f;
                    }
                    index++;
                    break;
                }
                PrintModelObjectData(ListItem, x, ref y, Kolumna, PrintFont, LineHeight * MultiplyLine, Indent, Shade);
                Offset[0]++;
            }
            if (Offset[0] < ListItems.Count())
            {
                PrintNextPage(Doc, e);
            }

            #endregion
        }
예제 #4
0
        private void prnDoc_PrintPage(object sender, PrintPageEventArgs e)
        {
            #region -------------------------- Print variables definitions -----------------------
            PH.G = e.Graphics;
            PrintDocument Doc                 = (PrintDocument)sender;
            float         x                   = IsPreview ? UserSession.User.Settings.LeftMargin : UserSession.User.Settings.LeftMargin - e.PageSettings.PrintableArea.Left;
            float         y                   = IsPreview ? UserSession.User.Settings.TopMargin : UserSession.User.Settings.TopMargin - e.PageSettings.PrintableArea.Top;
            Font          TextFont            = UserSession.User.Settings.TextFont;
            Font          SubHeaderFont       = UserSession.User.Settings.SubHeaderFont;
            Font          HeaderFont          = UserSession.User.Settings.HeaderFont;
            float         LineHeight          = TextFont.GetHeight(e.Graphics);
            float         SubHeaderLineHeight = SubHeaderFont.GetHeight(e.Graphics);
            float         HeaderLineHeight    = HeaderFont.GetHeight(e.Graphics);
            int           PrintWidth          = e.MarginBounds.Width;
            int           PrintHeight         = e.MarginBounds.Bottom;
            #endregion

            PageNumber += 1;

            #region --------------------------- Document header and footer -----------------------
            PH.DrawHeader(x, y, PrintWidth);
            PH.DrawFooter(x, PrintHeight, PrintWidth);
            PH.DrawPageNumber("- " + PageNumber.ToString() + " -", x, PrintHeight, PrintWidth, PageNumberLocation.Footer);
            #endregion
            #region ------------------------------ Report header -----------------------------------
            if (PageNumber == 1)
            {
                y += LineHeight;
                PH.DrawText(ReportHeader[0], HeaderFont, x, y, PrintWidth, HeaderLineHeight, StringAlignment.Center, Brushes.Black, false);
                y += HeaderLineHeight * 2;
            }
            #endregion
            #region ------------------------------- Column Settings --------------------------
            List <TableCell> Kolumna = new List <TableCell>();
            foreach (OLVColumn Col in olvStudent.Columns)
            {
                Kolumna.Add(new TableCell {
                    Name = Col.AspectName, Label = Col.Text, Size = Col.Width
                });
            }
            int SpaceWidth = PrintWidth - Kolumna.Sum(K => K.Size);
            int Space      = SpaceWidth / Kolumna.Count;
            foreach (var col in Kolumna)
            {
                col.Size += Space;
            }
            #endregion

            #region ------------------------------- Table header --------------------------------
            float MultiplyLine = 2;
            int   ColOffset    = 0;
            if (PageNumber == 1)
            {
                for (int i = 0; i < Kolumna.Count(); i++)
                {
                    PH.DrawText(Kolumna[i].Label, new Font(TextFont, FontStyle.Bold), x + ColOffset, y, Kolumna[i].Size, LineHeight * MultiplyLine, StringAlignment.Center, Brushes.Black);
                    ColOffset += Kolumna[i].Size;
                }
                y += LineHeight * MultiplyLine;
            }

            #endregion
            y += LineHeight;
            #region ------------------------ Table body --------------------------------
            MultiplyLine = 2.2f;
            while (y + LineHeight * MultiplyLine < PrintHeight && Offset[0] < olvStudent.Groups.Count)
            {
                if (Offset[1] == 0)
                {
                    PH.DrawText(olvStudent.Groups[Offset[0]].Header, SubHeaderFont, x, y, PrintWidth, SubHeaderLineHeight, 0, Brushes.Black, false);
                    y += LineHeight * 1.2f;
                    PH.DrawLine(x, y, x + PrintWidth, y);
                    y += LineHeight * 0.5f;
                }
                MultiplyLine = 1;
                while (y + LineHeight * MultiplyLine < PrintHeight && Offset[1] < olvStudent.Groups[Offset[0]].Items.Count)
                {
                    int colSize = 0;
                    for (int i = 0; i < Kolumna.Count; i++)
                    {
                        PH.DrawText(olvStudent.Groups[Offset[0]].Items[Offset[1]].SubItems[i].Text, TextFont, x + colSize, y, Kolumna[i].Size, LineHeight * MultiplyLine, i == 1 ? StringAlignment.Center : StringAlignment.Near, Brushes.Black, false);
                        colSize += Kolumna[i].Size;
                    }
                    y         += LineHeight;
                    Offset[1] += 1;
                }
                y += LineHeight;

                if (Offset[1] < olvStudent.Groups[Offset[0]].Items.Count)
                {
                    PrintNextPage(Doc, e);
                    return;
                }
                else
                {
                    Offset[1]  = 0;
                    Offset[0] += 1;
                }
            }
            if (Offset[0] < olvStudent.Groups.Count)
            {
                PrintNextPage(Doc, e);
            }

            #endregion
        }