C#一个画图简单功能问题 我在picturebox1建立坐标轴,并画了一幅4个同心圆图,现在我想用button实现对图形的刷新、平移、变大、变小功能,但是不知道怎么入手,望各位高手给予帮助,在此谢过各位啦! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 去看看 WPF 或者GDI+绘图部分的文章吧,给你一个链接http://blog.csdn.net/johnsuna/archive/2008/04/20/2309520.aspx public partial class Form1 : Form { Graphics g; public Form1() { InitializeComponent(); g = panel1.CreateGraphics(); } /// <summary> /// 移动 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { g.TranslateTransform(50, 0); panel1.Invalidate(); } /// <summary> /// 刷新画圆 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void panel1_Paint(object sender, PaintEventArgs e) { g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(10, 10), new Size(40, 40))); g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(10, 110), new Size(40, 40))); g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(160, 10), new Size(40, 40))); g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(160, 110), new Size(40, 40))); } /// <summary> /// 变大 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { g.ScaleTransform(2, 2); panel1.Invalidate(); } /// <summary> /// 变小 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button4_Click(object sender, EventArgs e) { g.ScaleTransform((float)0.5, (float)0.5); panel1.Invalidate(); } } [code=C#]public partial class Form1 : Form { Graphics g; public Form1() { InitializeComponent(); g = panel1.CreateGraphics(); } /// <summary> /// 移动 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { g.TranslateTransform(50, 0); panel1.Invalidate(); } /// <summary> /// 刷新画圆 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void panel1_Paint(object sender, PaintEventArgs e) { g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(10, 10), new Size(40, 40))); g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(10, 110), new Size(40, 40))); g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(160, 10), new Size(40, 40))); g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(160, 110), new Size(40, 40))); } /// <summary> /// 变大 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { g.ScaleTransform(2, 2); panel1.Invalidate(); } /// <summary> /// 变小 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button4_Click(object sender, EventArgs e) { g.ScaleTransform((float)0.5, (float)0.5); panel1.Invalidate(); } }[/code] Press the button and refresh the picture box. Press the button and refresh the picture box. http://download.csdn.net/source/961479 给你个例子,看看能不能帮到你! http://zzk.cnblogs.com/s?w=c%23+%e7%94%bb%e5%9b%be http://download.csdn.net/source/775720可以下载这个看看 这个CSDN上有的 自己搜一下. 使用.net的GDI+画图会比较死板,交互性不够强,建议LZ采用winapi接口画图,会得到更好的效果,会更灵活,交互性会更强 C#如何读取txt里的数据并显示在dgv中? 数据库查询问题!寻找最佳解决方案! 学习正则,想写一个可以把一段试题分解为 题目名称、选项的正则表达式。想请大家帮帮忙。 如何引用控件里的控件 请教下面代码中的,谢谢! 怎么描述一个路由器,比如被攻击了会有那些异常 关于LinkButton页面刷新后重复执行的问题 100分,求在listbox中显示无级分类中遇到的一个问题 关于接口继承问题!谁能给我举一个多接口继承的实例呀? 告别csdn,告别c#——情不要再给我删掉 DataReceived事件只触发一次!急!急!急! VS2005奇怪的工具箱
public partial class Form1 : Form
{
Graphics g;
public Form1()
{
InitializeComponent();
g = panel1.CreateGraphics();
} /// <summary>
/// 移动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
g.TranslateTransform(50, 0);
panel1.Invalidate();
} /// <summary>
/// 刷新画圆
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void panel1_Paint(object sender, PaintEventArgs e)
{
g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(10, 10), new Size(40, 40))); g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(10, 110), new Size(40, 40))); g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(160, 10), new Size(40, 40))); g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(160, 110), new Size(40, 40)));
} /// <summary>
/// 变大
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
g.ScaleTransform(2, 2);
panel1.Invalidate();
} /// <summary>
/// 变小
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button4_Click(object sender, EventArgs e)
{
g.ScaleTransform((float)0.5, (float)0.5);
panel1.Invalidate();
}
}
[code=C#]
public partial class Form1 : Form
{
Graphics g;
public Form1()
{
InitializeComponent();
g = panel1.CreateGraphics();
} /// <summary>
/// 移动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
g.TranslateTransform(50, 0);
panel1.Invalidate();
} /// <summary>
/// 刷新画圆
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void panel1_Paint(object sender, PaintEventArgs e)
{
g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(10, 10), new Size(40, 40))); g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(10, 110), new Size(40, 40))); g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(160, 10), new Size(40, 40))); g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(160, 110), new Size(40, 40)));
} /// <summary>
/// 变大
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
g.ScaleTransform(2, 2);
panel1.Invalidate();
} /// <summary>
/// 变小
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button4_Click(object sender, EventArgs e)
{
g.ScaleTransform((float)0.5, (float)0.5);
panel1.Invalidate();
}
}[/code]
可以下载这个看看