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;
|
||||
bool drawing = false;
|
||||
Random rnd;
|
||||
|
||||
int debugCounter = 0;
|
||||
public PaintForm()
|
||||
{
|
||||
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);
|
||||
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)
|
||||
{
|
||||
tmrRefresh.Enabled = false;
|
||||
sketch.AddDrawingPoint(MousePositionToCanvasPosition());
|
||||
sketch.Paint();
|
||||
canvas.Image = sketch.Drawing;
|
||||
canvas.Image = sketch.Paint();
|
||||
drawing = false;
|
||||
}
|
||||
|
||||
@@ -58,8 +59,7 @@ namespace Paint_2
|
||||
if (drawing)
|
||||
{
|
||||
sketch.AddDrawingPoint(MousePositionToCanvasPosition());
|
||||
sketch.Paint();
|
||||
canvas.Image = sketch.Drawing;
|
||||
canvas.Image = sketch.Paint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Paint_2
|
||||
void Start(Point point,Color color,int width);
|
||||
void Stop(Point point);
|
||||
void Add(Point point);
|
||||
List<Color> GetLastColors(int colorNumber);
|
||||
void Paint(Bitmap canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,5 +66,25 @@ namespace Paint_2
|
||||
{
|
||||
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);
|
||||
}
|
||||
public void Paint()
|
||||
public Bitmap Paint()
|
||||
{
|
||||
foreach (PaintTool tool in ToolList)
|
||||
{
|
||||
tool.Paint(Drawing);
|
||||
}
|
||||
return Drawing;
|
||||
}
|
||||
public Color GetColor(Point location)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user