예제 #1
0
파일: Main.cs 프로젝트: dptetc/Vegapad
 private Main.HeaderOrFooterInfo FormatHeaderFooterText(string pText, int PageIndex)
 {
     Main.HeaderOrFooterInfo HeaderOrFooterInfo = Main.GetHeaderOrFooterInfo(pText);
     HeaderOrFooterInfo.Left   = this.FormatSingleHeaderFooterText(HeaderOrFooterInfo.Left, PageIndex);
     HeaderOrFooterInfo.Center = this.FormatSingleHeaderFooterText(HeaderOrFooterInfo.Center, PageIndex);
     HeaderOrFooterInfo.Right  = this.FormatSingleHeaderFooterText(HeaderOrFooterInfo.Right, PageIndex);
     return(HeaderOrFooterInfo);
 }
예제 #2
0
파일: Main.cs 프로젝트: dptetc/Vegapad
        private void menuitemFilePrint_Click(object IGNORE_sender, EventArgs IGNORE_e)
        {
            PrintDialog PrintDialog = new PrintDialog();

            if (Main.Settings.MoreSettings.PrinterSettings != null)
            {
                PrintDialog.PrinterSettings = Main.Settings.MoreSettings.PrinterSettings;
            }
            if (PrintDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            Main.Settings.MoreSettings.PrinterSettings = PrintDialog.PrinterSettings;
            Main.Settings.Save();
            PrintDocument printDocument = new PrintDocument();

            printDocument.DefaultPageSettings = this.PageSettings;
            printDocument.PrinterSettings     = Main.Settings.MoreSettings.PrinterSettings;
            printDocument.DocumentName        = this.DocumentName + " - Vegapad";
            string RemainingContentToPrint = this.Content;
            int    PageIndex = 0;

            printDocument.PrintPage += delegate(object sender, PrintPageEventArgs e)
            {
                Main.HeaderOrFooterInfo HeaderText = this.FormatHeaderFooterText(Main.Settings.Header, PageIndex);
                int Top = this.PageSettings.Margins.Top;
                this.DrawStringAtPosition(e.Graphics, HeaderText.Left, Top, Main.DrawStringPosition.Left);
                this.DrawStringAtPosition(e.Graphics, HeaderText.Center, Top, Main.DrawStringPosition.Center);
                this.DrawStringAtPosition(e.Graphics, HeaderText.Right, Top, Main.DrawStringPosition.Right);
                int        CharactersFitted = 0;
                int        LinesFilled      = 0;
                RectangleF MarginBounds     = new RectangleF((float)e.MarginBounds.X, (float)(e.MarginBounds.Y + this.CurrentFont.Height), (float)e.MarginBounds.Width, (float)(e.MarginBounds.Height - this.CurrentFont.Height * 2));
                e.Graphics.MeasureString(RemainingContentToPrint, this.CurrentFont, MarginBounds.Size, StringFormat.GenericTypographic, out CharactersFitted, out LinesFilled);
                e.Graphics.DrawString(RemainingContentToPrint, this.CurrentFont, Brushes.Black, MarginBounds, StringFormat.GenericTypographic);
                RemainingContentToPrint = RemainingContentToPrint.Substring(CharactersFitted);
                e.HasMorePages          = (RemainingContentToPrint.Length > 0);
                Main.HeaderOrFooterInfo FooterText = this.FormatHeaderFooterText(Main.Settings.Footer, PageIndex);
                int Top2 = this.PageSettings.Bounds.Bottom - this.PageSettings.Margins.Bottom - this.CurrentFont.Height;
                this.DrawStringAtPosition(e.Graphics, FooterText.Left, Top2, Main.DrawStringPosition.Left);
                this.DrawStringAtPosition(e.Graphics, FooterText.Center, Top2, Main.DrawStringPosition.Center);
                this.DrawStringAtPosition(e.Graphics, FooterText.Right, Top2, Main.DrawStringPosition.Right);
                int pageIndex = PageIndex;
                PageIndex = pageIndex + 1;
            };
            printDocument.Print();
        }
예제 #3
0
파일: Main.cs 프로젝트: dptetc/Vegapad
        private static Main.HeaderOrFooterInfo GetHeaderOrFooterInfo(string pText)
        {
            IEnumerable <int> indexes       = Helper.GetIndexes(pText, "&l", false);
            List <int>        CenterIndexes = Helper.GetIndexes(pText, "&c", false);
            List <int>        RightIndexes  = Helper.GetIndexes(pText, "&r", false);
            var SideInfos = (from o in (from o in indexes
                                        select new
            {
                Side = "Left",
                Index = o
            }).Union(from o in CenterIndexes
                     select new
            {
                Side = "Center",
                Index = o
            }).Union(from o in RightIndexes
                     select new
            {
                Side = "Right",
                Index = o
            })
                             orderby o.Index
                             select o).ToList();

            Main.HeaderOrFooterInfo HeaderOrFooterInfo = new Main.HeaderOrFooterInfo();
            if (SideInfos.Count == 0)
            {
                HeaderOrFooterInfo.Center = pText;
                return(HeaderOrFooterInfo);
            }
            for (int i = 0; i < SideInfos.Count; i++)
            {
                var  SideInfo       = SideInfos[i];
                bool flag           = i == 0;
                bool IsLastSideInfo = i == SideInfos.Count - 1;
                if (flag && SideInfo.Index != 0)
                {
                    HeaderOrFooterInfo.Center = pText.Substring(0, SideInfo.Index - 1);
                }
                int StartIndex = SideInfo.Index + 2;
                int EndIndex;
                if (IsLastSideInfo)
                {
                    EndIndex = pText.Length - 1;
                }
                else
                {
                    EndIndex = SideInfos[i + 1].Index - 1;
                }
                int    Length = EndIndex - StartIndex + 1;
                string Text   = pText.Substring(StartIndex, Length);
                string side   = SideInfo.Side;
                if (!(side == "Left"))
                {
                    if (!(side == "Center"))
                    {
                        if (!(side == "Right"))
                        {
                            throw new Exception();
                        }
                        Main.HeaderOrFooterInfo headerOrFooterInfo = HeaderOrFooterInfo;
                        headerOrFooterInfo.Right += Text;
                    }
                    else
                    {
                        Main.HeaderOrFooterInfo headerOrFooterInfo2 = HeaderOrFooterInfo;
                        headerOrFooterInfo2.Center += Text;
                    }
                }
                else
                {
                    Main.HeaderOrFooterInfo headerOrFooterInfo3 = HeaderOrFooterInfo;
                    headerOrFooterInfo3.Left += Text;
                }
            }
            return(HeaderOrFooterInfo);
        }