using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace zhengxianxian
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double distance = 200.0;
System.Drawing.Graphics g = Graphics.FromHwnd(this.Handle);
g.Clear(this.BackColor);
Pen pn = new Pen(Color.Green, 2);
int maxY = this.Height;//获取窗体的高
int maxX = this.Width;//获取窗体的宽
double n = 2.0 * Math.PI / 200.0;
int lmin = 0;
int rmax = 200;
int count = rmax - lmin;
PointF[] mypoint = new PointF[count + 1];
int x = 0;
for (int i = lmin; i <= rmax; i++)
{
double temp = 0.5 * (maxY - maxY * Math.Sin(n * i));
mypoint[x] = new PointF((float)i, (float)temp);
x++;
}
g.DrawCurve(pn, mypoint);
pn.Dispose();
g.Dispose();
}
}
}
这是一个画正弦线的程序!在windows平台下运行很正常!但是移植到wince平台下时就出了问题!
一个是System.Drawing.Graphics g = Graphics.FromHwnd(this.Handle);系统说不包含FromHwnd的定义!
还有就是找不到PointF的命名空间!
请指教
System.Drawing.Graphics g = this.CreateGraphics();