使用Manged DirectX 9.0 --- Part II

新建一个项目, 引用上一节的项目, 调用DXEngine 来做一个DirectX应用程序.

 

[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();
}
}
}

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值