I have copied your code and used the syntax highlighter so that the C# expert can better understand the code. You can also do the same using the
bbcode
Code: csharp
using System;
using System.Timers;
using System.Drawing.Printing;
using System.Drawing;
class MainClass
{
PrintDocument pd = new PrintDocument();
private Timer timer = new Timer();
private void MyHandler(object sender, ElapsedEventArgs args)
{
pd.Print();
}
private void pd_PrintPage(object sender, PrintPageEventArgs args)
{
args.Graphics.FillEllipse(Brushes.Aquamarine,
args.MarginBounds.X,
args.MarginBounds.Y,
args.MarginBounds.Width / 2,
args.MarginBounds.Height);
}
static void Main(string[] args)
{
MainClass mc = new MainClass();
double Interval = 5000;
mc.timer.Interval = Interval;
mc.timer.Elapsed +=new ElapsedEventHandler(mc.MyHandler);
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
mc.timer.Start();
//pause for user input
Console.WriteLine("Press ENTER to end timer\n");
Console.ReadLine();
}
}