Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- // MyPrintEvent2.cs Split out 16-Mar-2019
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- // v5.0.6.01 22-Feb-2019 Dialing all in Now!
- // v5.0.6.01 02-Mar-2019 FixedWell with 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.
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- // v5.0.6.04 25-Mar-2019 FixedWell & nearly
- // done. This is really working great now &
- // with SomePages2! Design ready: CurrentPage
- // PrintDialog Option to go into Selection.
- // Nearly all of that Logic will have to be
- // in ME. Since that's where BOTH
- // CurrentPage & Selection are or are going
- // to have to come from. And at some point
- // I will have to ReRoute or Mod or ReTest
- // the 2nd Instance Code in PrintForm2.cs
- // in PrintBlaster Deluxe. Or Call Print
- // Functions directly:
- // from Smesa to MCPL eventually maybe.
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- // v5.0.6.04 29-Mar-2019 Tested & Clean!
- // v5.1.6.06 13-Apr Sel & CurPag detail.
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- using System.Drawing;
- using System.Drawing.Printing;
- 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
- {
- private static void MyPrintEvent2(
- ref PrintPageEventArgs e)
- {
- if (_firstPage)
- {
- _firstPage = false;
- if (e.PageSettings
- .PrinterSettings.PrintRange
- .Equals(PrintRange.SomePages))
- SomePages1(ref e);
- }
- if (e.PageSettings.PrinterSettings
- .PrintRange.Equals(
- PrintRange.SomePages))
- SomePages2(ref e);
- if (e.PageSettings.PrinterSettings
- .PrintRange.Equals(
- PrintRange.AllPages))
- PrintThisPageNow(e);
- if (!e.PageSettings.PrinterSettings
- .PrintRange.Equals(
- PrintRange.CurrentPage)
- && !e.PageSettings.PrinterSettings
- .PrintRange.Equals(
- PrintRange.Selection)) return;
- // else is Selection, do till done.
- if (!string.IsNullOrEmpty(
- StrToPrint)) PrintThisPageNow(e);
- // or CurrentPage. (when applicable)
- if (e.PageSettings.PrinterSettings
- .PrintRange.Equals(
- PrintRange.CurrentPage))
- StrToPrint = "";
- // CurrentPage ^ Exits cut it short.
- }
- // Perfected v5.0.6.04 25-Mar-2019 -JpE-
- private static void SomePages2(
- ref PrintPageEventArgs e)
- {
- // Skip ahead to the FromPage if needed.
- while (++CurrentPage < e.PageSettings
- .PrinterSettings.FromPage)
- StrToPrint = StrToPrint
- .Substring(GetCharsNum(
- e, StrToPrint));
- PrintThisPageNow(e);
- // Print ^ from FromPage to ToPage only.
- if (CurrentPage >= e.PageSettings
- .PrinterSettings.ToPage)
- StrToPrint = "";
- // After ToPage cut it short. (Exits)
- }
- private static int GetCharsNum(
- PrintPageEventArgs e, string str2Prnt)
- {
- int charsOnPage, linesPerPage;
- // Atypical
- e.Graphics.MeasureString(str2Prnt,
- MFC.MyFontDialog.Font,
- e.MarginBounds.Size,
- StringFormat.GenericTypographic,
- out charsOnPage, out linesPerPage);
- return charsOnPage;
- }
- private static void PrintThisPageNow(
- PrintPageEventArgs e)
- {
- var customBrush = new SolidBrush(
- MFC.MyFontDialog.Color);
- try
- {
- e.Graphics.DrawString(
- StrToPrint,
- MFC.MyFontDialog.Font,
- customBrush,
- e.MarginBounds,
- StringFormat.GenericTypographic);
- }
- finally { customBrush.Dispose(); }
- }
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- #region Other Available EventHandlers
- //public static void
- // MyBeginPrintEventHandler(
- // object sender, PrintEventArgs e)
- //{
- // // todos BeginPrint if needed.
- // const string txt =
- // "Print Job Started.";
- // MessageBox.Show(txt);
- //}
- //public static void
- // MyEndPrintEventHandler(
- // object sender,
- // PrintEventArgs printEventArgs)
- //{
- // // todos EndPrint if needed.
- // // what do sender and event-args
- // // contain at this point?
- // const string txt =
- // "Print Job Completed.";
- // MessageBox.Show(txt);
- //}
- #endregion Other Available Events
- //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement