[code]
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using DXEngine;
namespace DirectxApp
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
string titlescreen="title.bmp";
Picture title,charactor;
public Form1()
{
try
{
InitializeComponent();
Graphics2D g=new Graphics2D(this,800,600);
title=g.CreateBitmapFromBMP(titlescreen);
charactor=g.CreateBitmapFromBMP("characterblack.bmp",Color.Black);
//charactor=g.CreateBitmapFromBMP("characterred.bmp",Color.Red);
g.OnDraw+=new DrawFunc(this.drawpic);
while(this.Created)
{
g.Draw();
Application.DoEvents();
}
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
}
void drawpic(Graphics2D g)
{
g.DrawBitmapBMP(0,0,title);
g.DrawBitmapBMP(400,250,charactor);
g.DrawText(20,40,"Maganed DirectX 9.0 Part I",Color.White);
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form1";
this.Text = "Form1";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Form1 app=new Form1();
Application.Exit();
}
private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode==Keys.Escape)
this.Close();
}
}
}