Added new tools and their preview

This commit is contained in:
2022-06-17 13:51:51 +02:00
parent 2dc7035f80
commit dfc8ca24dd
13 changed files with 506 additions and 16 deletions

View File

@@ -2,7 +2,7 @@
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A unique tool that draws Bezier curves /// Brief: A unique tool that draws Bezier curves
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -2,7 +2,7 @@
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A variant of the default tool /// Brief: A variant of the default tool
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -0,0 +1,154 @@
/// file: EllipseBorderPencil.cs
/// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A tool that paints the outline of an ellipse
/// Version: 0.1.0
/// Date: 17/06/2022
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace Paint_2
{
internal class EllipseBorderPencil:PaintTool
{
private List<List<Point>> _drawings;
private List<List<Point>> _drawingsRedo;
private bool _needsFullRefresh;
private PaintToolUtils Utils;
private List<Color> _colors;
private List<Color> _colorsRedo;
private List<int> _widths;
private List<int> _widthsRedo;
private Color _color;
private string _name;
private int _width;
public List<List<Point>> Drawings { get => _drawings; set => _drawings = value; }
public List<List<Point>> DrawingsRedo { get => _drawingsRedo; set => _drawingsRedo = value; }
public bool NeedsFullRefresh { get => _needsFullRefresh; set => _needsFullRefresh = value; }
public List<Color> Colors { get => _colors; set => _colors = value; }
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
public List<int> Widths { get => _widths; set => _widths = value; }
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
public Color Color { get => _color; set => _color = value; }
public string Name { get => _name; set => _name = value; }
public int Width { get => _width; set => _width = value; }
public EllipseBorderPencil(string name)
{
NeedsFullRefresh = true;
Drawings = new List<List<Point>>();
DrawingsRedo = new List<List<Point>>();
Colors = new List<Color>();
ColorsRedo = new List<Color>();
Widths = new List<int>();
WidthsRedo = new List<int>();
Name = name;
Utils = new PaintToolUtils(this);
}
public void Add(Point point)
{
List<Point> myDrawing = Drawings[Drawings.Count - 1];
if (myDrawing.Count == 0 || myDrawing.Count == 1)
{
myDrawing.Add(point);
}
else
{
myDrawing[1] = point;
}
Drawings[Drawings.Count - 1] = myDrawing;
}
public void Paint(Bitmap canvas)
{
Graphics gr = Graphics.FromImage(canvas);
int drawingCounter = 0;
Size pointSize;
foreach (List<Point> drawing in Drawings)
{
if (drawing.Count == 2)
{
Point p1 = drawing[0];
Point p2 = drawing[1];
Point start = new Point(0, 0);
Point end = new Point(0, 0);
if (p2.X > p1.X)
{
start.X = p1.X;
end.X = p2.X;
}
else
{
start.X = p2.X;
end.X = p1.X;
}
if (p2.Y > p1.Y)
{
start.Y = p1.Y;
end.Y = p2.Y;
}
else
{
start.Y = p2.Y;
end.Y = p1.Y;
}
gr.DrawEllipse(new Pen(Colors[drawingCounter], Widths[drawingCounter]), new Rectangle(start, new Size(end.X - start.X, end.Y - start.Y)));
}
drawingCounter++;
}
}
public void Start(Color color, int width)
{
Utils.StandartStart(color, width);
}
public void Clear()
{
Utils.StandartClear();
}
public void Stop()
{
for (int i = 0; i < Drawings.Count; i++)
{
List<Point> Drawing = Drawings[i];
}
}
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
{
return bmp;
}
public List<Color> GetLastColors(int colorNumber)
{
return Utils.SandartGetLastColors(colorNumber);
}
public override string ToString()
{
return Name;
}
public void Undo()
{
Utils.StandartUndo();
}
public void Redo()
{
Utils.StandartRedo();
}
public object Clone()
{
EllipseBorderPencil result = new EllipseBorderPencil(Name);
result.Width = Width;
result.Color = Color;
return (Object)(result);
}
}
}

153
Paint_2/EllipsePencil.cs Normal file
View File

@@ -0,0 +1,153 @@
/// file: EllipsePencil.cs
/// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A tool that paints an ellipse
/// Version: 0.1.0
/// Date: 17/06/2022
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace Paint_2
{
internal class EllipsePencil : PaintTool
{
private List<List<Point>> _drawings;
private List<List<Point>> _drawingsRedo;
private bool _needsFullRefresh;
private PaintToolUtils Utils;
private List<Color> _colors;
private List<Color> _colorsRedo;
private List<int> _widths;
private List<int> _widthsRedo;
private Color _color;
private string _name;
private int _width;
public List<List<Point>> Drawings { get => _drawings; set => _drawings = value; }
public List<List<Point>> DrawingsRedo { get => _drawingsRedo; set => _drawingsRedo = value; }
public bool NeedsFullRefresh { get => _needsFullRefresh; set => _needsFullRefresh = value; }
public List<Color> Colors { get => _colors; set => _colors = value; }
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
public List<int> Widths { get => _widths; set => _widths = value; }
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
public Color Color { get => _color; set => _color = value; }
public string Name { get => _name; set => _name = value; }
public int Width { get => _width; set => _width = value; }
public EllipsePencil(string name)
{
NeedsFullRefresh = true;
Drawings = new List<List<Point>>();
DrawingsRedo = new List<List<Point>>();
Colors = new List<Color>();
ColorsRedo = new List<Color>();
Widths = new List<int>();
WidthsRedo = new List<int>();
Name = name;
Utils = new PaintToolUtils(this);
}
public void Add(Point point)
{
List<Point> myDrawing = Drawings[Drawings.Count - 1];
if (myDrawing.Count == 0 || myDrawing.Count == 1)
{
myDrawing.Add(point);
}
else
{
myDrawing[1] = point;
}
Drawings[Drawings.Count - 1] = myDrawing;
}
public void Paint(Bitmap canvas)
{
Graphics gr = Graphics.FromImage(canvas);
int drawingCounter = 0;
Size pointSize;
foreach (List<Point> drawing in Drawings)
{
if (drawing.Count == 2)
{
Point p1 = drawing[0];
Point p2 = drawing[1];
Point start = new Point(0, 0);
Point end = new Point(0, 0);
if (p2.X > p1.X)
{
start.X = p1.X;
end.X = p2.X;
}
else
{
start.X = p2.X;
end.X = p1.X;
}
if (p2.Y > p1.Y)
{
start.Y = p1.Y;
end.Y = p2.Y;
}
else
{
start.Y = p2.Y;
end.Y = p1.Y;
}
gr.FillEllipse(new SolidBrush(Colors[drawingCounter]), new Rectangle(start, new Size(end.X - start.X, end.Y - start.Y)));
}
drawingCounter++;
}
}
public void Start(Color color, int width)
{
Utils.StandartStart(color, width);
}
public void Clear()
{
Utils.StandartClear();
}
public void Stop()
{
for (int i = 0; i < Drawings.Count; i++)
{
List<Point> Drawing = Drawings[i];
}
}
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
{
return bmp;
}
public List<Color> GetLastColors(int colorNumber)
{
return Utils.SandartGetLastColors(colorNumber);
}
public override string ToString()
{
return Name;
}
public void Undo()
{
Utils.StandartUndo();
}
public void Redo()
{
Utils.StandartRedo();
}
public object Clone()
{
EllipsePencil result = new EllipsePencil(Name);
result.Width = Width;
result.Color = Color;
return (Object)(result);
}
}
}

View File

@@ -2,7 +2,7 @@
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: Class that is controlling the view /// Brief: Class that is controlling the view
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -156,11 +156,14 @@ namespace Paint_2
if (Project.GetCurrentTool(SelectedLayers) != null) if (Project.GetCurrentTool(SelectedLayers) != null)
{ {
PaintTool currentTool = (PaintTool)Project.GetCurrentTool(SelectedLayers).Clone(); PaintTool currentTool = (PaintTool)Project.GetCurrentTool(SelectedLayers).Clone();
Color paint_tool_color = Project.GetCurrentToolColor(SelectedLayers);
int paint_tool_width = Project.GetCurrentToolWidth(SelectedLayers);
//Would have loved to use a switch case but I cant //Would have loved to use a switch case but I cant
if (currentTool is Pencil) if (currentTool is Pencil)
{ {
Pencil pencil = currentTool as Pencil; Pencil pencil = currentTool as Pencil;
pencil.Start(Project.GetCurrentToolColor(SelectedLayers), Project.GetCurrentToolWidth(SelectedLayers)); pencil.Start(paint_tool_color, paint_tool_width);
pencil.Add(new Point(0, size.Height)); pencil.Add(new Point(0, size.Height));
pencil.Add(new Point(size.Width, 0)); pencil.Add(new Point(size.Width, 0));
pencil.Stop(); pencil.Stop();
@@ -171,7 +174,7 @@ namespace Paint_2
if (currentTool is DotPencil) if (currentTool is DotPencil)
{ {
DotPencil pencil = currentTool as DotPencil; DotPencil pencil = currentTool as DotPencil;
pencil.Start(Project.GetCurrentToolColor(SelectedLayers), Project.GetCurrentToolWidth(SelectedLayers)); pencil.Start(paint_tool_color,paint_tool_width);
int precision = 5; int precision = 5;
for (int i = 0; i <= precision; i++) for (int i = 0; i <= precision; i++)
{ {
@@ -186,8 +189,6 @@ namespace Paint_2
if (currentTool is BezierPencil) if (currentTool is BezierPencil)
{ {
BezierPencil pencil = currentTool as BezierPencil; BezierPencil pencil = currentTool as BezierPencil;
Color paint_tool_color = Project.GetCurrentToolColor(SelectedLayers);
int paint_tool_width = Project.GetCurrentToolWidth(SelectedLayers);
Point p1 = new Point(0 - paint_tool_width / 2, 0 - paint_tool_width / 2); Point p1 = new Point(0 - paint_tool_width / 2, 0 - paint_tool_width / 2);
Point p2 = new Point(0 - paint_tool_width / 2, size.Height + paint_tool_width / 2); Point p2 = new Point(0 - paint_tool_width / 2, size.Height + paint_tool_width / 2);
@@ -216,6 +217,18 @@ namespace Paint_2
pencil.Stop(); pencil.Stop();
pencil.Paint(map); pencil.Paint(map);
} }
else
{
if (currentTool is RectanglePencil || currentTool is RectangleBorderPencil || currentTool is EllipsePencil || currentTool is EllipseBorderPencil)
{
currentTool.Start(paint_tool_color,paint_tool_width);
currentTool.Add(new Point(0 + size.Width / 10,0 + size.Height / 10));
currentTool.Add(new Point(size.Width - size.Width / 10, size.Height - size.Height / 10));
currentTool.Stop();
currentTool.Paint(map);
}
}
} }
} }
} }

View File

@@ -2,7 +2,7 @@
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: Interface that is here to define what is a paint tool /// Brief: Interface that is here to define what is a paint tool
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -2,7 +2,7 @@
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A class that groups all the frequently used by painttools methods /// Brief: A class that groups all the frequently used by painttools methods
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -54,6 +54,8 @@
<DependentUpon>ColorPicker.cs</DependentUpon> <DependentUpon>ColorPicker.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="DotPencil.cs" /> <Compile Include="DotPencil.cs" />
<Compile Include="EllipseBorderPencil.cs" />
<Compile Include="EllipsePencil.cs" />
<Compile Include="Form1.cs"> <Compile Include="Form1.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@@ -66,6 +68,7 @@
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Project.cs" /> <Compile Include="Project.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RectangleBorderPencil.cs" />
<Compile Include="RectanglePencil.cs" /> <Compile Include="RectanglePencil.cs" />
<Compile Include="Sketch.cs" /> <Compile Include="Sketch.cs" />
<EmbeddedResource Include="ColorPicker.resx"> <EmbeddedResource Include="ColorPicker.resx">

View File

@@ -2,7 +2,7 @@
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: Paint tool that is kind of the default tool /// Brief: Paint tool that is kind of the default tool
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,4 +1,9 @@
using System; /// file: Project.cs
/// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A controller that manipulates that gives the view all the info it needs and controlls the layers and tools
/// Version: 0.1.0
/// Date: 17/06/2022
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
@@ -46,9 +51,12 @@ namespace Paint_2
AvaibleTools.Add(new Pencil("Default Pencil")); AvaibleTools.Add(new Pencil("Default Pencil"));
AvaibleTools.Add(new DotPencil("Dotted Line")); AvaibleTools.Add(new DotPencil("Dotted Line"));
AvaibleTools.Add(new BezierPencil("Bezier Generator")); AvaibleTools.Add(new BezierPencil("Bezier Generator"));
AvaibleTools.Add(new RectanglePencil("Rectangle tool")); AvaibleTools.Add(new RectanglePencil("Box tool"));
AvaibleTools.Add(new RectangleBorderPencil("Rectangle tool"));
AvaibleTools.Add(new EllipsePencil("Ball tool"));
AvaibleTools.Add(new EllipseBorderPencil("Ellipse tool"));
//We create a single first layer with the default toolSet //We create a single first layer with the default toolSet
Layers = new List<Sketch>(); Layers = new List<Sketch>();
LayersToPrint = new List<string>(); LayersToPrint = new List<string>();

View File

@@ -0,0 +1,154 @@
/// file: RectangleBorderPencil.cs
/// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A tool that paints the outline of a rectangle
/// Version: 0.1.0
/// Date: 17/06/2022
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace Paint_2
{
internal class RectangleBorderPencil:PaintTool
{
private List<List<Point>> _drawings;
private List<List<Point>> _drawingsRedo;
private bool _needsFullRefresh;
private PaintToolUtils Utils;
private List<Color> _colors;
private List<Color> _colorsRedo;
private List<int> _widths;
private List<int> _widthsRedo;
private Color _color;
private string _name;
private int _width;
public List<List<Point>> Drawings { get => _drawings; set => _drawings = value; }
public List<List<Point>> DrawingsRedo { get => _drawingsRedo; set => _drawingsRedo = value; }
public bool NeedsFullRefresh { get => _needsFullRefresh; set => _needsFullRefresh = value; }
public List<Color> Colors { get => _colors; set => _colors = value; }
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
public List<int> Widths { get => _widths; set => _widths = value; }
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
public Color Color { get => _color; set => _color = value; }
public string Name { get => _name; set => _name = value; }
public int Width { get => _width; set => _width = value; }
public RectangleBorderPencil(string name)
{
NeedsFullRefresh = true;
Drawings = new List<List<Point>>();
DrawingsRedo = new List<List<Point>>();
Colors = new List<Color>();
ColorsRedo = new List<Color>();
Widths = new List<int>();
WidthsRedo = new List<int>();
Name = name;
Utils = new PaintToolUtils(this);
}
public void Add(Point point)
{
List<Point> myDrawing = Drawings[Drawings.Count - 1];
if (myDrawing.Count == 0 || myDrawing.Count == 1)
{
myDrawing.Add(point);
}
else
{
myDrawing[1] = point;
}
Drawings[Drawings.Count - 1] = myDrawing;
}
public void Paint(Bitmap canvas)
{
Graphics gr = Graphics.FromImage(canvas);
int drawingCounter = 0;
Size pointSize;
foreach (List<Point> drawing in Drawings)
{
if (drawing.Count == 2)
{
Point p1 = drawing[0];
Point p2 = drawing[1];
Point start = new Point(0, 0);
Point end = new Point(0, 0);
if (p2.X > p1.X)
{
start.X = p1.X;
end.X = p2.X;
}
else
{
start.X = p2.X;
end.X = p1.X;
}
if (p2.Y > p1.Y)
{
start.Y = p1.Y;
end.Y = p2.Y;
}
else
{
start.Y = p2.Y;
end.Y = p1.Y;
}
gr.DrawRectangle(new Pen(Colors[drawingCounter], Widths[drawingCounter]), new Rectangle(start, new Size(end.X - start.X, end.Y - start.Y)));
}
drawingCounter++;
}
}
public void Start(Color color, int width)
{
Utils.StandartStart(color, width);
}
public void Clear()
{
Utils.StandartClear();
}
public void Stop()
{
for (int i = 0; i < Drawings.Count; i++)
{
List<Point> Drawing = Drawings[i];
}
}
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
{
return bmp;
}
public List<Color> GetLastColors(int colorNumber)
{
return Utils.SandartGetLastColors(colorNumber);
}
public override string ToString()
{
return Name;
}
public void Undo()
{
Utils.StandartUndo();
}
public void Redo()
{
Utils.StandartRedo();
}
public object Clone()
{
RectangleBorderPencil result = new RectangleBorderPencil(Name);
result.Width = Width;
result.Color = Color;
return (Object)(result);
}
}
}

View File

@@ -1,4 +1,9 @@
using System; /// file: RectanglePencil.cs
/// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A tool that paints a Rectangle
/// Version: 0.1.0
/// Date: 17/06/2022
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;

View File

@@ -1,8 +1,8 @@
/// file: Sketch.cs /// file: Sketch.cs
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: Class that is used to store and controll the tools and the bitmap /// Brief: This is a layer wich can controll a set of tools and is controlled by the Project
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;