using System;
using System.Drawing;
using System.Windows.Forms;
class BetterImageFromFile:Form
{
Image image;
public static void Main()
{
Application.Run(new BetterImageFromFile());
}
protected override void OnPaint(PaintEventArgs pea)
{
DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
}
public BetterImageFromFile()
{
string strFileName = "Color.jpg";
ResizeRedraw = true;
try
{
image = Image.FromFile(strFileName);
}catch {
MessageBox.Show("Cannot find file " + strFileName + "!",
Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
}
protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
{
if (image == null)
return;
grfx.DrawImage(image, 0, 0);
}
}
|