67 lines
2.1 KiB
C#
67 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Paint_2
|
|
{
|
|
internal class Pencil : PaintTool
|
|
{
|
|
private List<List<Point>> _drawings;
|
|
private List<Color> _colors;
|
|
private List<int> _widths;
|
|
private Color _color;
|
|
private int _width;
|
|
public List<List<Point>> Drawings { get => _drawings; set => _drawings = value; }
|
|
public List<Color> Colors { get => _colors; set => _colors = value; }
|
|
public List<int> Widths { get => _widths; set => _widths = value; }
|
|
public Color Color { get => _color; set => _color = value; }
|
|
public int Width { get => _width; set => _width = value; }
|
|
public Pencil()
|
|
{
|
|
Drawings = new List<List<Point>>();
|
|
Colors = new List<Color>();
|
|
Widths = new List<int>();
|
|
}
|
|
public void Add(Point point)
|
|
{
|
|
Drawings[Drawings.Count -1].Add(point);
|
|
}
|
|
public void Paint(Bitmap canvas)
|
|
{
|
|
Graphics gr = Graphics.FromImage(canvas);
|
|
int drawingCounter = 0;
|
|
foreach (List<Point> drawing in Drawings)
|
|
{
|
|
int pointCounter = 0;
|
|
foreach (Point p in drawing)
|
|
{
|
|
if (pointCounter > 0)
|
|
{
|
|
gr.DrawLine(new Pen(Colors[drawingCounter],Widths[drawingCounter]),drawing[pointCounter -1],p);
|
|
}
|
|
|
|
pointCounter += 1;
|
|
}
|
|
drawingCounter += 1;
|
|
}
|
|
}
|
|
public void Start(Point point, Color color, int width)
|
|
{
|
|
Color = color;
|
|
Width = width;
|
|
List<Point> points = new List<Point>();
|
|
points.Add(point);
|
|
Drawings.Add(points);
|
|
Colors.Add(Color);
|
|
Widths.Add(Width);
|
|
}
|
|
public void Stop(Point point)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|