Added color history (but only after using at least 4 different)
This commit is contained in:
@@ -17,8 +17,6 @@ namespace Paint_2
|
|||||||
List<PaintTool> toolList;
|
List<PaintTool> toolList;
|
||||||
bool drawing = false;
|
bool drawing = false;
|
||||||
Random rnd;
|
Random rnd;
|
||||||
|
|
||||||
int debugCounter = 0;
|
|
||||||
public PaintForm()
|
public PaintForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -42,14 +40,17 @@ namespace Paint_2
|
|||||||
sketch.StartDrawing(MousePositionToCanvasPosition(), Color.FromArgb(rnd.Next(0,256), rnd.Next(0, 256), rnd.Next(0, 256)), (int)nupPencilWidth.Value);
|
sketch.StartDrawing(MousePositionToCanvasPosition(), Color.FromArgb(rnd.Next(0,256), rnd.Next(0, 256), rnd.Next(0, 256)), (int)nupPencilWidth.Value);
|
||||||
tmrRefresh.Enabled = true;
|
tmrRefresh.Enabled = true;
|
||||||
|
|
||||||
//new Thread((sketch) => { (sketch as Sketch).AddDrawingPoint(this.PointToClient(MousePosition)); }).Start();
|
List<Color> colorHistory = sketch.CurrentTool.GetLastColors(4);
|
||||||
|
btnColorHistory1.BackColor = colorHistory[0];
|
||||||
|
btnColorHistory2.BackColor = colorHistory[1];
|
||||||
|
btnColorHistory3.BackColor = colorHistory[2];
|
||||||
|
btnColorHistory4.BackColor = colorHistory[3];
|
||||||
}
|
}
|
||||||
private void canvas_MouseUp(object sender, MouseEventArgs e)
|
private void canvas_MouseUp(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
tmrRefresh.Enabled = false;
|
tmrRefresh.Enabled = false;
|
||||||
sketch.AddDrawingPoint(MousePositionToCanvasPosition());
|
sketch.AddDrawingPoint(MousePositionToCanvasPosition());
|
||||||
sketch.Paint();
|
canvas.Image = sketch.Paint();
|
||||||
canvas.Image = sketch.Drawing;
|
|
||||||
drawing = false;
|
drawing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,8 +59,7 @@ namespace Paint_2
|
|||||||
if (drawing)
|
if (drawing)
|
||||||
{
|
{
|
||||||
sketch.AddDrawingPoint(MousePositionToCanvasPosition());
|
sketch.AddDrawingPoint(MousePositionToCanvasPosition());
|
||||||
sketch.Paint();
|
canvas.Image = sketch.Paint();
|
||||||
canvas.Image = sketch.Drawing;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace Paint_2
|
|||||||
void Start(Point point,Color color,int width);
|
void Start(Point point,Color color,int width);
|
||||||
void Stop(Point point);
|
void Stop(Point point);
|
||||||
void Add(Point point);
|
void Add(Point point);
|
||||||
|
List<Color> GetLastColors(int colorNumber);
|
||||||
void Paint(Bitmap canvas);
|
void Paint(Bitmap canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,5 +66,25 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
public List<Color> GetLastColors(int colorNumber)
|
||||||
|
{
|
||||||
|
List<Color> result = new List<Color>();
|
||||||
|
if (Colors.Count <= colorNumber)
|
||||||
|
{
|
||||||
|
//We need to fill with black color
|
||||||
|
for (int i = colorNumber; i >= 0; i--)
|
||||||
|
{
|
||||||
|
result.Add(Color.FromArgb(0x00,0x00,0x00));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(int i = colorNumber; i > 0; i--)
|
||||||
|
{
|
||||||
|
result.Add(Colors[(Colors.Count)-i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,12 +56,13 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
CurrentTool.Add(location);
|
CurrentTool.Add(location);
|
||||||
}
|
}
|
||||||
public void Paint()
|
public Bitmap Paint()
|
||||||
{
|
{
|
||||||
foreach (PaintTool tool in ToolList)
|
foreach (PaintTool tool in ToolList)
|
||||||
{
|
{
|
||||||
tool.Paint(Drawing);
|
tool.Paint(Drawing);
|
||||||
}
|
}
|
||||||
|
return Drawing;
|
||||||
}
|
}
|
||||||
public Color GetColor(Point location)
|
public Color GetColor(Point location)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user