请高手帮下忙pen自定义变色
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 绘图pen
{
public partial class F : Form
{
public F()
{
InitializeComponent();
}
string sun = "";
//F
private void F_Load(object sender, EventArgs e)
{
}
private Point mypen;
bool l = false;
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (sun == "")
{
}
if (l)
{
Graphics g = p1.CreateGraphics();
g.DrawLine(new Pen(new SolidBrush(Color.Red)), mypen, new Point(e.X, e.Y));
mypen = new Point(e.X, e.Y);
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
l = true;
mypen = new Point(e.X, e.Y);
}
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
l = false;
}
//pi1
private void pi1_Click(object sender, EventArgs e)
{
sun = "go1";
}
private void pictureBox1_Click(object sender, EventArgs e)
{
DialogResult result = colorDialog1.ShowDialog();
if (result == DialogResult.OK)//确定事件响应
{
}
if (result == DialogResult.Cancel)//取消事件响应
{
}
}
}
}