C# 中 在窗体上用gdi+画个圆点,我想利用timer实现圆点的移动,结果出现的是一条粗线,不知道该怎么做

 我来答
百度网友cc2f160de
2010-06-05 · 超过77用户采纳过TA的回答
知道小有建树答主
回答量:359
采纳率:0%
帮助的人:220万
展开全部
每移动一次刷新(Refresh)就可以了,
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
我欲弑神
2010-06-05 · TA获得超过912个赞
知道小有建树答主
回答量:1247
采纳率:0%
帮助的人:1038万
展开全部
移动的时候要擦掉之前的圆!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
最后的仙人
2010-06-05 · TA获得超过1961个赞
知道大有可为答主
回答量:1509
采纳率:0%
帮助的人:1400万
展开全部
给你一个我编的例子吧,不过是按按钮移动的
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace WindowsFormsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Graphics g;
GraphicsPath gp, gpOld;
Matrix RotationTransform, TranslationTransform;
PointF TheRotationPoint;
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
g = Graphics.FromImage(this.pictureBox1.Image);
gp = new GraphicsPath();
gp.AddBezier(110, 110, 110, 115, 120, 115, 125, 130);
gp.AddEllipse(125, 130, 8, 8);
gpOld = gp.Clone() as GraphicsPath;
RotationTransform = new Matrix(1, 0, 0, 1, 0, 0);
TranslationTransform = new Matrix(1, 0, 0, 1, 0, 0);
TheRotationPoint = new PointF(110.0f, 110.0f);
for (float f = 0.0f; f < 359.0f; f += 45.0f)
{

gp.Transform(TranslationTransform);
RotationTransform.RotateAt(f, TheRotationPoint);
gp.Transform(RotationTransform);
g.FillPath(Brushes.Orange, gp);
g.DrawPath(Pens.Green, gp);
RotationTransform.Dispose();
RotationTransform = new Matrix(1, 0, 0, 1, 0, 0);
gp = gpOld.Clone() as GraphicsPath;
}

}

private void button1_Click(object sender, EventArgs e)
{

}
//int iCount = 1;
private void button2_Click(object sender, EventArgs e)
{
//iCount++;

//pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
//g = Graphics.FromImage(this.pictureBox1.Image);
//RotationTransform = new Matrix(1, 0, 0, 1, 0, 0);
//TranslationTransform = new Matrix(1, 0, 0, 1, 0, 0);
//TheRotationPoint = new PointF(110.0f, 110.0f);
//for (int i = 0; i < iCount; i++)
//{
// for (float f = 0.0f; f < 359.0f; f += 45.0f)
// {
// gp.Transform(TranslationTransform);
// RotationTransform.RotateAt(f, TheRotationPoint);
// gp.Transform(RotationTransform);
// g.FillPath(Brushes.Orange, gp);
// g.DrawPath(Pens.Green, gp);
// RotationTransform.Dispose();
// RotationTransform = new Matrix(1, 0, 0, 1, 0, 0);
// gp = gpOld.Clone() as GraphicsPath;
// }
// TheRotationPoint.X = TheRotationPoint.X + 100;
// TranslationTransform.Translate(100, 0);
//}
}
bool leftDown = false;
bool rightDown = false;
bool upDown = false;
bool downDown = false;
private void button2_MouseDown(object sender, MouseEventArgs e)
{
rightDown = true;
while (rightDown)
{
Application.DoEvents();
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
g = Graphics.FromImage(this.pictureBox1.Image);
TheRotationPoint.X += 2;
TranslationTransform.Translate(2, 0);
for (float f = 0.0f; f < 359.0f; f += 45.0f)
{
//Application.DoEvents();
gp.Transform(TranslationTransform);
RotationTransform.RotateAt(f, TheRotationPoint);
gp.Transform(RotationTransform);
g.FillPath(Brushes.Orange, gp);
g.DrawPath(Pens.Green, gp);
RotationTransform.Dispose();
RotationTransform = new Matrix(1, 0, 0, 1, 0, 0);
gp = gpOld.Clone() as GraphicsPath;
}
}
}

private void button2_MouseUp(object sender, MouseEventArgs e)
{
rightDown = false;
}

private void button1_MouseDown(object sender, MouseEventArgs e)
{
leftDown = true;
while (leftDown)
{
Application.DoEvents();
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
g = Graphics.FromImage(this.pictureBox1.Image);
TheRotationPoint.X -= 2;
TranslationTransform.Translate(-2, 0);
for (float f = 0.0f; f < 359.0f; f += 45.0f)
{
//Application.DoEvents();
gp.Transform(TranslationTransform);
RotationTransform.RotateAt(f, TheRotationPoint);
gp.Transform(RotationTransform);
g.FillPath(Brushes.Orange, gp);
g.DrawPath(Pens.Green, gp);
RotationTransform.Dispose();
RotationTransform = new Matrix(1, 0, 0, 1, 0, 0);
gp = gpOld.Clone() as GraphicsPath;
}
}
}

private void button1_MouseUp(object sender, MouseEventArgs e)
{
leftDown = false;
}

private void button3_MouseDown(object sender, MouseEventArgs e)
{
upDown = true;
while (upDown)
{
Application.DoEvents();
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
g = Graphics.FromImage(this.pictureBox1.Image);
TheRotationPoint.Y -= 1;
TranslationTransform.Translate(0, -1);
for (float f = 0.0f; f < 359.0f; f += 45.0f)
{
//Application.DoEvents();
gp.Transform(TranslationTransform);
RotationTransform.RotateAt(f, TheRotationPoint);
gp.Transform(RotationTransform);
g.FillPath(Brushes.Orange, gp);
g.DrawPath(Pens.Green, gp);
RotationTransform.Dispose();
RotationTransform = new Matrix(1, 0, 0, 1, 0, 0);
gp = gpOld.Clone() as GraphicsPath;
}
}
}

private void button3_MouseUp(object sender, MouseEventArgs e)
{
upDown = false;
}

private void button4_MouseDown(object sender, MouseEventArgs e)
{
downDown = true;
while (downDown)
{
Application.DoEvents();
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
g = Graphics.FromImage(this.pictureBox1.Image);
TheRotationPoint.Y += 1;
TranslationTransform.Translate(0, 1);
for (float f = 0.0f; f < 359.0f; f += 45.0f)
{
//Application.DoEvents();
gp.Transform(TranslationTransform);
RotationTransform.RotateAt(f, TheRotationPoint);
gp.Transform(RotationTransform);
g.FillPath(Brushes.Orange, gp);
g.DrawPath(Pens.Green, gp);
RotationTransform.Dispose();
RotationTransform = new Matrix(1, 0, 0, 1, 0, 0);
gp = gpOld.Clone() as GraphicsPath;
}
}
}

private void button4_MouseUp(object sender, MouseEventArgs e)
{
downDown = false;
}

}
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
LIFEXX
2010-06-05 · 超过39用户采纳过TA的回答
知道小有建树答主
回答量:148
采纳率:0%
帮助的人:105万
展开全部
invalidate()
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 2条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式