forked from fdorg/flashdevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintingManager.cs
More file actions
64 lines (58 loc) · 2.27 KB
/
Copy pathPrintingManager.cs
File metadata and controls
64 lines (58 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Drawing;
using System.Drawing.Printing;
using PluginCore;
using PluginCore.Localization;
namespace FlashDevelop.Managers
{
class PrintingManager
{
public static Int32 PrintPageNumber = 0;
public static Int32 PrintPageLastChar = 0;
public static PrinterSettings PrinterSettings = null;
/// <summary>
/// Gets the global printer settings
/// </summary>
public static PrinterSettings GetPrinterSettings()
{
if (PrinterSettings == null)
{
PrinterSettings = new PrinterSettings();
}
return PrinterSettings;
}
/// <summary>
/// Creates a new print document
/// </summary>
public static PrintDocument CreatePrintDocument()
{
PrintPageNumber = 0;
PrintPageLastChar = 0;
PrintDocument printDocument = new PrintDocument();
printDocument.DocumentName = Globals.CurrentDocument.Text;
printDocument.PrintPage += new PrintPageEventHandler(OnPrintDocumentPrintPage);
return printDocument;
}
/// <summary>
/// Handles the PrintPage event
/// </summary>
public static void OnPrintDocumentPrintPage(Object sender, PrintPageEventArgs e)
{
PrintPageNumber++;
ITabbedDocument document = Globals.CurrentDocument;
String page = TextHelper.GetString("Info.PrintFooterPage");
String footer = page + PrintPageNumber + " - " + document.FileName;
PrintPageLastChar = document.SciControl.FormatRange(false, e, PrintPageLastChar, document.SciControl.Length);
e.Graphics.DrawLine(new Pen(Color.Black), 35, e.PageBounds.Height - 60, e.PageBounds.Width - 35, e.PageBounds.Height - 60);
e.Graphics.DrawString(footer, new Font("Arial", 7), Brushes.Black, 35, e.PageBounds.Height - 55, StringFormat.GenericDefault);
if (PrintPageLastChar < document.SciControl.Length) e.HasMorePages = true;
else
{
e.HasMorePages = false;
document.SciControl.FormatRangeDone();
PrintPageLastChar = 0;
PrintPageNumber = 0;
}
}
}
}