前些日子在論壇上發了個帖子,100分尋求“橡皮條”法繪圖的代碼。效果不是很好,於是自己參照網友給的代碼重新寫了一個,解決了繪圖與重繪的問題。由於只寫了部分,所以功能有限,同時可能算法不是很好,希望大家指點!!窗體中僅包含一個pictrueBox1,先將代碼付諸於下: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Drawing.Drawing2D;
namespace GDI_練習 { /// <summary> /// Form1 的摘要說明。 /// </summary> public class Form1 : System.Windows.Forms.Form { public System.Windows.Forms.PictureBox pictureBox1; private Point p1 = Point.Empty, p2 = Point.Empty; private bool isMouseDown = false, isMouseUp = false;
ArrayList addArray = new ArrayList(); public struct SharpType { public string type; public Point p1, p2; public Color foreColor, backColor; public Brush brush; public SharpType( string type, Point p1, Point p2, Color foreColor, Color backColor, Brush brush ) { this.type = type; this.p1 = p1; this.p2 = p2; this.foreColor = foreColor; this.backColor = backColor; this.brush = brush; }