日期:2014-05-17 浏览次数:21058 次
public abstract class DrawObject
{
public int Width { get; set; }
public Color Color { get; set; }
public float X { get; set; }
public float Y { get; set; }
public DrawObject()
{
Width = 1;
Color = Color.Black;
}
public abstract void Render(Graphics g);
}
public class DrawDot : DrawObject
{
public override void Render(Graphics g)
{
g.FillRectangle(new SolidBrush(Color), X, Y, Width, Width);
}
}
public class DrawLine : DrawObject
{
public Point StartPoint { get; set; }
public Point EndPoint { get; set; }
public override void Render(Graphics g)
{
g.DrawLine(new Pen(Color, Width), StartPoint, EndPoint);
}
}
public abstract class DrawTool
{
protected DrawCanvas canvas;
public DrawTool(DrawCanvas canvas)
{
this.canvas = canvas;
}
public abstract void MouseMove(MouseEventArgs e);
public abstract void MouseDown(MouseEventArgs e);
public abstract void MouseUp(MouseEventArgs e);
}
public class DrawDotTool : DrawTool
{
public DrawDotTool(DrawCanvas canvas)
: base(canvas)