我的程序就是在pictureBox里画画,最小化后画的东西没有了,程序如下:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace TestBoard
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool pen = true;
bool f;
int x, y;
Graphics g;
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
if (pen)
{
f = false;
}
} private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (pen)
{
if (f == true)
{
Graphics gx = pictureBox1.CreateGraphics();
gx.DrawLine(new Pen(Color.Black), x, y, e.X, e.Y);
x = e.X;
y = e.Y;
}
}
} private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (pen)
{
f = true;
x = e.X;
y = e.Y; }
}
}
}求高手改我的程序让它实现吧,就是怎么重绘
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace TestBoard
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool pen = true;
bool f;
int x, y;
Graphics g;
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
if (pen)
{
f = false;
}
} private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (pen)
{
if (f == true)
{
Graphics gx = pictureBox1.CreateGraphics();
gx.DrawLine(new Pen(Color.Black), x, y, e.X, e.Y);
x = e.X;
y = e.Y;
}
}
} private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (pen)
{
f = true;
x = e.X;
y = e.Y; }
}
}
}求高手改我的程序让它实现吧,就是怎么重绘
解决方案 »
- WPF的Dock的问题
- VS2005web程序能正常运行,但不能单步调试
- VS2005中C#代码自动完成功能怎么配置?
- 求助!! .net 线程、方法、类基础
- 神啊,救救我吧。又是微软惹的祸
- 看到一些代码。abstract方法用override重写,virtual方法也用override重写,两者有什么区别?另外,用NEW隐藏父类方法时,父类方法要什么
- C#!~ 我爱上了你,请大家给我指条路吧,用C#做哪个领域的软件开发工资比较高?
- 100分送解决“Datagird的分页栏加字”
- 求助:并发冲突
- 跪求一正则表达式写法
- 使用HttpWebRequest抓取google搜索结果遇到的问题!
- 分治法写算法!!!
最小化后 屏幕不再保存窗口图形的 重新打开后 需要刷新重绘 你用鼠标原先绘的图没了
解决:
先保存绘图数据
接收pictureBox控件的Paint事件
在事件处理方法中 重新绘图
gx.DrawLine(new Pen(Color.Black), x, y, e.X, e.Y);要卸载onpaint事件里
如果你觉得内存有问题,可以写在一个文件里面,作为临时的记录。