mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
//
|
|
// System.Drawing.StandardPrintController.cs
|
|
//
|
|
// Author:
|
|
// Dennis Hayes ([email protected])
|
|
// Herve Poussineau ([email protected])
|
|
//
|
|
// (C) 2002 Ximian, Inc
|
|
//
|
|
using System;
|
|
|
|
namespace System.Drawing.Printing {
|
|
/// <summary>
|
|
/// Summary description for StandardPrintController.
|
|
/// </summary>
|
|
public class StandardPrintController : PrintController {
|
|
private int page;
|
|
private Image image;
|
|
|
|
public StandardPrintController() {
|
|
}
|
|
[MonoTODO("StandardPrintController.OnEndPage")]
|
|
public override void OnEndPage(PrintDocument document, PrintPageEventArgs e){
|
|
//TODO: print current page
|
|
// - image to print is this.image
|
|
// - page settings are in e.PageSettings
|
|
// - printer settings are in document.PrinterSettings
|
|
// - don't forget to use document.OriginAtMargins (only if .NET 1.1)
|
|
|
|
// actually, "print" == "save to a file"
|
|
try
|
|
{
|
|
string fileName = document.DocumentName + " " + page.ToString("D4") + ".jpg";
|
|
Console.WriteLine("StandardPrintController: Print page \"{0}\"", fileName);
|
|
image.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
|
|
}
|
|
catch (Exception) {}
|
|
|
|
if (e.Graphics != null)
|
|
e.Graphics.Dispose();
|
|
}
|
|
[MonoTODO("StandardPrintController.OnStartPrint")]
|
|
public override void OnStartPrint(PrintDocument document, PrintEventArgs e){
|
|
page = 0;
|
|
}
|
|
//[MonoTODO("StandardPrintController.OnEndPrint")]
|
|
//public override void OnEndPrint(PrintDocument document, PrintEventArgs e){
|
|
// throw new NotImplementedException ();
|
|
//}
|
|
[MonoTODO("StandardPrintController.OnStartPage")]
|
|
public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e){
|
|
//FIXME: I'm not sure of what I'm doing
|
|
// I don't know what size to give to image
|
|
// and why I have to clear it
|
|
page++;
|
|
// returns a new (empty) graphics
|
|
image = new Bitmap(e.MarginBounds.Width, e.MarginBounds.Height);
|
|
Graphics g = Graphics.FromImage(image);
|
|
g.Clear(Color.White);
|
|
return g;
|
|
}
|
|
}
|
|
}
|