Chapter 12.

Write a program that prints an ellipse on the left half of a page, and a rectangle on the right hand side. Choose appropriate colours for visibility.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Printing;

namespace WinAssignment
{

class Class1
{

private void pd_PrintPage(object sender, PrintPageEventArgs e)
{

e.Graphics.FillEllipse(Brushes.LightGreen,

e.MarginBounds.X,
e.MarginBounds.Y,
e.MarginBounds.Width / 2,
e.MarginBounds.Height);

e.Graphics.FillRectangle(Brushes.LightSalmon,

e.MarginBounds.X + (e.MarginBounds.Width /2),
e.MarginBounds.Y,
e.MarginBounds.Width / 2,
e.MarginBounds.Height);

}

[STAThread]
static void Main()
{

Class1 mc = new Class1();
PrintDocument pd =
new PrintDocument();
pd.PrintPage +=
new PrintPageEventHandler(mc.pd_PrintPage);
pd.Print();

}

}

}

 

u