Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- // MyCustomPrintLibrary.MyPrintClass.cs
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- // Global Access Software InTernational
- // Copyrighted (c) 2019 by John P. Edwards
- // First Created December 02, 2014 2:53 AM
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- // Split this section out to simplify PMP
- // v2.5.0.61 Nov 05 2016 05:52 AM
- // v2.5.0.79 Nov 12 2016 05:52 AM
- // Custom Brush below fixes that!
- // v3.6.4.81 Jan 02 2017 Final:
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- // Brought this one in from MyLilBlackBook:
- // v4.9.5.95 20-Dec-2018 PB.MyPrintEvent1
- // v4.9.5.96 31-Dec Revision simplifies.
- // v4.9.5.98 12-Jan-2019 Moved to Project.
- // v5.0.5.98 12-Jan-2019 Integrate to Beta.
- // v5.0.5.99 15-Jan-2019 MCPL Design change.
- // v5.0.6.01 22-Feb-2019 Dialing it all in Now!
- // v5.0.6.01 02-Mar-2019 Fixedwell w/MPP Menu
- // items calling back across, etc.
- // v5.0.6.02 08-Mar-2019 Batch Stuff & Debug
- // v5.0.6.03 14-Mar-2019 ReSetPages Call.
- // v5.0.6.03 16-Mar-2019 Split to simplify.
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- using System.Drawing.Printing;
- using System.Threading;
- using MCC = MyCustomControls.CustomControl;
- using MPC = MyCustomPrintLibrary.MyPrintClass;
- using MFC = MyCustomPrintLibrary.MyFontClass;
- using MPR = MyCustomPrintLibrary
- .Properties.Resources;
- using MPS = MyCustomPrintLibrary
- .Properties.Settings;
- namespace MyCustomPrintLibrary
- {
- public static partial class MyPrintEvent
- {
- internal static string
- DocContents { get; set; }
- private static string
- StrToPrint { get; set; }
- private static int
- CurrentPage { get; set; }
- private static bool
- _firstPage = true;
- private static readonly Mutex
- Mini = new Mutex(false, MPR.Mini);
- /// <summary> Each & Every Page Printed
- /// Passes thru here! PrintBlaster
- /// v4.9.5.95 23-Dec-2018 by -JpE- 100%
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="eventP"></param>
- public static void
- PrintPageEventHandler(object sender,
- PrintPageEventArgs eventP)
- {
- var pd = sender as PrintDocument;
- if (eventP == null
- || pd == null
- || string.IsNullOrEmpty(
- DocContents)) return;
- Mini.WaitOne();
- eventP.PageSettings // trickit
- .PrinterSettings =
- pd.PrinterSettings;
- if(_firstPage)
- StrToPrint = DocContents;
- var charsOnPage = GetCharsNum(
- eventP, StrToPrint);
- MyPrintEvent2(ref eventP);
- if (!string.IsNullOrEmpty(
- StrToPrint)) StrToPrint =
- StrToPrint.Substring(
- charsOnPage);
- eventP.HasMorePages =
- StrToPrint.Length > 0;
- if (!eventP.HasMorePages)
- {
- _firstPage = true;
- CurrentPage = 0;
- StrToPrint = DocContents; }
- Mini.ReleaseMutex();
- }
- private static void SomePages1(
- ref PrintPageEventArgs p)
- {
- if (string.IsNullOrEmpty(
- DocContents)) return;
- var page = CalculatePages(p);
- if (p.PageSettings.PrinterSettings
- .FromPage > page) p.PageSettings
- .PrinterSettings.FromPage = 1;
- // Correct ^v either or both if over.
- if (p.PageSettings.PrinterSettings
- .ToPage > page) p.PageSettings
- .PrinterSettings.ToPage = page;
- }
- private static int CalculatePages(
- PrintPageEventArgs p)
- {
- var pages = 0;
- var text = DocContents;
- do
- {
- var chars = GetCharsNum(p, text);
- ++pages;
- text = text.Substring(chars);
- }
- while (!string.IsNullOrEmpty(text));
- return pages;
- }
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement