新手求助,弄了个画图的。。发现线是连着的

Shazam9 Shazam9 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如图,只能画一条线,如何让它们不连着?从而达到画多条线写字的效果。。





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;

namespace 写字板
{
public partial class Form1 : Form
{
bool drawflag = false;
bool down = false;
int X1;
int Y1;
List<Point> list;
public Form1()
{
InitializeComponent();
list = new List<Point>();
}

private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen p = new Pen(Color.Red, 4);
if (list.Count > 2)
{
g.DrawLines(p, list.ToArray());
}
}

private void Form1_MouseDown(object sender, MouseEventArgs e)
{
drawflag = true;
down = true;
}

private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (drawflag == false)
return;
else if (down == true)
{
X1 = e.X;
Y1 = e.Y;
list.Add(new Point(e.X, e.Y));
}
this.Invalidate();
}

private void Form1_MouseUp(object sender, MouseEventArgs e)
{
drawflag = false;
}
}
}
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
Shazam9
C# 111,129 成员 642,539 内容