Compare commits
4 Commits
9b4cfb33bd
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| e243b37884 | |||
| 640796a1b1 | |||
| 44dd8b9f0c | |||
| 95217bb3c5 |
+64
-19
@@ -18,6 +18,8 @@ namespace Paint_2
|
|||||||
private List<List<Point>> _drawings;
|
private List<List<Point>> _drawings;
|
||||||
private List<List<Point>> _drawingsRedo;
|
private List<List<Point>> _drawingsRedo;
|
||||||
private bool _needsFullRefresh;
|
private bool _needsFullRefresh;
|
||||||
|
private bool _isCtrlPressed;
|
||||||
|
private bool _isShiftPressed;
|
||||||
private PaintToolUtils Utils;
|
private PaintToolUtils Utils;
|
||||||
private List<Color> _colors;
|
private List<Color> _colors;
|
||||||
private List<Color> _colorsRedo;
|
private List<Color> _colorsRedo;
|
||||||
@@ -34,6 +36,8 @@ namespace Paint_2
|
|||||||
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
||||||
public List<int> Widths { get => _widths; set => _widths = value; }
|
public List<int> Widths { get => _widths; set => _widths = value; }
|
||||||
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
||||||
|
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||||
|
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||||
public Color Color { get => _color; set => _color = value; }
|
public Color Color { get => _color; set => _color = value; }
|
||||||
public string Name { get => _name; set => _name = value; }
|
public string Name { get => _name; set => _name = value; }
|
||||||
public int Width { get => _width; set => _width = value; }
|
public int Width { get => _width; set => _width = value; }
|
||||||
@@ -81,16 +85,54 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (points.Count > 0)
|
if (points.Count > 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < points.Count; i++)
|
for (int i = 0; i < points.Count; i++)
|
||||||
{
|
{
|
||||||
pointSize = new Size(Widths[0]/2, Widths[0]/2);
|
pointSize = new Size(Widths[0] / 2, Widths[0] / 2);
|
||||||
gr.FillEllipse(new SolidBrush(Colors[i]), new Rectangle(new Point(points[i].X - pointSize.Width / 2, points[i].Y - pointSize.Height / 2), pointSize));
|
//ContinuousBezierGenerator(gr, points, Colors[Colors.Count-1], Widths[Widths.Count -1]);
|
||||||
ContinuousBezierGenerator(gr, points, Colors[Colors.Count-1], Widths[Widths.Count -1]);
|
AdjustedBezierGenerator(gr, points, Colors[Colors.Count - 1], Widths[Widths.Count - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ContinuousBezierGenerator(Graphics gr, List<Point> points,Color color,int width)
|
private void AdjustedBezierGenerator(Graphics gr, List<Point> points, Color color, int width)
|
||||||
|
{
|
||||||
|
foreach (Point p in points)
|
||||||
|
{
|
||||||
|
gr.FillEllipse(new SolidBrush(color), new Rectangle(new Point(p.X - width / 2, p.Y - width / 2), new Size(width,width)));
|
||||||
|
}
|
||||||
|
if (points.Count >= 3)
|
||||||
|
{
|
||||||
|
float precision = 0.01f;
|
||||||
|
for (float t = 0; t <= 1; t += precision)
|
||||||
|
{
|
||||||
|
List<Point> DumpList = new List<Point>();
|
||||||
|
List<Point> WorkingList = new List<Point>();
|
||||||
|
|
||||||
|
foreach (Point p in points)
|
||||||
|
{
|
||||||
|
WorkingList.Add(new Point(p.X, p.Y));
|
||||||
|
}
|
||||||
|
while (WorkingList.Count > 1)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < WorkingList.Count - 1; i++)
|
||||||
|
{
|
||||||
|
Point p1 = WorkingList[i];
|
||||||
|
Point p2 = WorkingList[i + 1];
|
||||||
|
Point tmp = Utils.Lerp(p1, p2, t);
|
||||||
|
DumpList.Add(tmp);
|
||||||
|
}
|
||||||
|
WorkingList.Clear();
|
||||||
|
foreach (Point p in DumpList)
|
||||||
|
{
|
||||||
|
WorkingList.Add(new Point(p.X, p.Y));
|
||||||
|
}
|
||||||
|
DumpList.Clear();
|
||||||
|
}
|
||||||
|
gr.FillEllipse(new SolidBrush(color), new Rectangle(WorkingList[0].X - Widths[0] / 2, WorkingList[0].Y - Widths[0] / 2, width, width));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ContinuousBezierGenerator(Graphics gr, List<Point> points, Color color, int width)
|
||||||
{
|
{
|
||||||
if (points.Count >= 4 && points.Count % 2 == 0)
|
if (points.Count >= 4 && points.Count % 2 == 0)
|
||||||
{
|
{
|
||||||
@@ -152,33 +194,36 @@ namespace Paint_2
|
|||||||
string result = "";
|
string result = "";
|
||||||
string newLine = Environment.NewLine;
|
string newLine = Environment.NewLine;
|
||||||
|
|
||||||
if (points.Count >= 4 && points.Count % 2 == 0)
|
if (points.Count >= 3)
|
||||||
{
|
{
|
||||||
float precision = 0.01f;
|
float precision = 0.01f;
|
||||||
for (float t = 0; t <= 1; t += precision)
|
for (float t = 0; t <= 1; t += precision)
|
||||||
{
|
{
|
||||||
List<Point> DumpList = new List<Point>();
|
List<Point> DumpList = new List<Point>();
|
||||||
List<Point> WorkingList = new List<Point>(points);
|
List<Point> WorkingList = new List<Point>();
|
||||||
|
|
||||||
while (WorkingList.Count != 1)
|
foreach (Point p in points)
|
||||||
{
|
{
|
||||||
if (WorkingList.Count > 1)
|
WorkingList.Add(new Point(p.X, p.Y));
|
||||||
|
}
|
||||||
|
while (WorkingList.Count > 1)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < WorkingList.Count - 1; i++)
|
||||||
{
|
{
|
||||||
for (int pos = 0; pos < WorkingList.Count - 1; pos++)
|
Point p1 = WorkingList[i];
|
||||||
{
|
Point p2 = WorkingList[i + 1];
|
||||||
DumpList.Add(Utils.Lerp(WorkingList[pos], WorkingList[pos + 1], t));
|
Point tmp = Utils.Lerp(p1, p2, t);
|
||||||
}
|
DumpList.Add(tmp);
|
||||||
}
|
}
|
||||||
else
|
WorkingList.Clear();
|
||||||
|
foreach (Point p in DumpList)
|
||||||
{
|
{
|
||||||
DumpList.Add(Utils.Lerp(WorkingList[0], WorkingList[1], precision));
|
WorkingList.Add(new Point(p.X, p.Y));
|
||||||
}
|
}
|
||||||
WorkingList = new List<Point>(DumpList);
|
DumpList.Clear();
|
||||||
DumpList = new List<Point>();
|
|
||||||
}
|
}
|
||||||
result += "<ellipse cx=\"" + WorkingList[0].X + "\" cy=\"" + WorkingList[0].Y + "\" rx=\"" + width / 2 + "\" ry=\"" + width / 2 + "\" style=\"fill:rgb(" + color.R + ", " + color.G + ", " + color.B + ");\"/>";
|
result += "<ellipse cx=\"" + WorkingList[0].X + "\" cy=\"" + WorkingList[0].Y + "\" rx=\"" + width / 2 + "\" ry=\"" + width / 2 + "\" style=\"fill:rgb(" + color.R + ", " + color.G + ", " + color.B + ");\"/>";
|
||||||
result += newLine;
|
result += newLine;
|
||||||
//gr.FillEllipse(new SolidBrush(color), new Rectangle(WorkingList[0].X - Widths[0] / 2, WorkingList[0].Y - Widths[0] / 2, width, width));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -215,7 +260,7 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
public void Start(Color color, int width)
|
public void Start(Color color, int width)
|
||||||
{
|
{
|
||||||
Utils.StandartStart(color,width);
|
Utils.StandartStart(color, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ namespace Paint_2
|
|||||||
private List<List<Point>> _drawings;
|
private List<List<Point>> _drawings;
|
||||||
private List<List<Point>> _drawingsRedo;
|
private List<List<Point>> _drawingsRedo;
|
||||||
private bool _needsFullRefresh;
|
private bool _needsFullRefresh;
|
||||||
|
private bool _isShiftPressed;
|
||||||
|
private bool _isCtrlPressed;
|
||||||
private PaintToolUtils Utils;
|
private PaintToolUtils Utils;
|
||||||
private List<Color> _colors;
|
private List<Color> _colors;
|
||||||
private List<Color> _colorsRedo;
|
private List<Color> _colorsRedo;
|
||||||
@@ -32,6 +34,8 @@ namespace Paint_2
|
|||||||
public List<List<Point>> Drawings { get => _drawings; set => _drawings = value; }
|
public List<List<Point>> Drawings { get => _drawings; set => _drawings = value; }
|
||||||
public List<List<Point>> DrawingsRedo { get => _drawingsRedo; set => _drawingsRedo = value; }
|
public List<List<Point>> DrawingsRedo { get => _drawingsRedo; set => _drawingsRedo = value; }
|
||||||
public bool NeedsFullRefresh { get => _needsFullRefresh; set => _needsFullRefresh = value; }
|
public bool NeedsFullRefresh { get => _needsFullRefresh; set => _needsFullRefresh = value; }
|
||||||
|
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||||
|
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||||
public List<Color> Colors { get => _colors; set => _colors = value; }
|
public List<Color> Colors { get => _colors; set => _colors = value; }
|
||||||
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
||||||
public List<int> Widths { get => _widths; set => _widths = value; }
|
public List<int> Widths { get => _widths; set => _widths = value; }
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ namespace Paint_2
|
|||||||
private List<List<Point>> _drawings;
|
private List<List<Point>> _drawings;
|
||||||
private List<List<Point>> _drawingsRedo;
|
private List<List<Point>> _drawingsRedo;
|
||||||
private bool _needsFullRefresh;
|
private bool _needsFullRefresh;
|
||||||
|
private bool _isShiftPressed;
|
||||||
|
private bool _isCtrlPressed;
|
||||||
private PaintToolUtils Utils;
|
private PaintToolUtils Utils;
|
||||||
private List<Color> _colors;
|
private List<Color> _colors;
|
||||||
private List<Color> _colorsRedo;
|
private List<Color> _colorsRedo;
|
||||||
@@ -34,6 +36,8 @@ namespace Paint_2
|
|||||||
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
||||||
public List<int> Widths { get => _widths; set => _widths = value; }
|
public List<int> Widths { get => _widths; set => _widths = value; }
|
||||||
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
||||||
|
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||||
|
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||||
public Color Color { get => _color; set => _color = value; }
|
public Color Color { get => _color; set => _color = value; }
|
||||||
public string Name { get => _name; set => _name = value; }
|
public string Name { get => _name; set => _name = value; }
|
||||||
public int Width { get => _width; set => _width = value; }
|
public int Width { get => _width; set => _width = value; }
|
||||||
@@ -75,32 +79,22 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
if (drawing.Count == 2)
|
if (drawing.Count == 2)
|
||||||
{
|
{
|
||||||
Point p1 = drawing[0];
|
Point start = drawing[0];
|
||||||
Point p2 = drawing[1];
|
Point end = drawing[1];
|
||||||
|
|
||||||
Point start = new Point(0, 0);
|
List<Point> points;
|
||||||
Point end = new Point(0, 0);
|
if (drawingCounter == Drawings.Count - 1)
|
||||||
|
|
||||||
if (p2.X > p1.X)
|
|
||||||
{
|
{
|
||||||
start.X = p1.X;
|
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||||
end.X = p2.X;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start.X = p2.X;
|
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start = points[0];
|
||||||
|
end = points[1];
|
||||||
|
|
||||||
Size size = new Size((end.X - start.X) / 2, (end.Y - start.Y) / 2);
|
Size size = new Size((end.X - start.X) / 2, (end.Y - start.Y) / 2);
|
||||||
result += "<ellipse cx=\"" + (start.X + size.Width) + "\" cy=\"" + (start.Y + size.Height) + "\" rx=\"" + size.Width + "\" ry=\"" + size.Height + "\" style=\"stroke:rgb(" + Colors[drawingCounter].R + ", " + Colors[drawingCounter].G + ", " + Colors[drawingCounter].B + ");\" stroke-width=\"" + Widths[drawingCounter] + "\" fill=\"none\"/>";
|
result += "<ellipse cx=\"" + (start.X + size.Width) + "\" cy=\"" + (start.Y + size.Height) + "\" rx=\"" + size.Width + "\" ry=\"" + size.Height + "\" style=\"stroke:rgb(" + Colors[drawingCounter].R + ", " + Colors[drawingCounter].G + ", " + Colors[drawingCounter].B + ");\" stroke-width=\"" + Widths[drawingCounter] + "\" fill=\"none\"/>";
|
||||||
result += newLine;
|
result += newLine;
|
||||||
@@ -117,33 +111,22 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
if (drawing.Count == 2)
|
if (drawing.Count == 2)
|
||||||
{
|
{
|
||||||
Point p1 = drawing[0];
|
Point start = drawing[0];
|
||||||
Point p2 = drawing[1];
|
Point end = drawing[1];
|
||||||
|
|
||||||
Point start = new Point(0, 0);
|
List<Point> points;
|
||||||
Point end = new Point(0, 0);
|
if (drawingCounter == Drawings.Count - 1)
|
||||||
|
|
||||||
if (p2.X > p1.X)
|
|
||||||
{
|
{
|
||||||
start.X = p1.X;
|
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||||
end.X = p2.X;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start.X = p2.X;
|
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start = points[0];
|
||||||
|
end = points[1];
|
||||||
|
|
||||||
gr.DrawEllipse(new Pen(Colors[drawingCounter], Widths[drawingCounter]), new Rectangle(start, new Size(end.X - start.X, end.Y - start.Y)));
|
gr.DrawEllipse(new Pen(Colors[drawingCounter], Widths[drawingCounter]), new Rectangle(start, new Size(end.X - start.X, end.Y - start.Y)));
|
||||||
}
|
}
|
||||||
drawingCounter++;
|
drawingCounter++;
|
||||||
@@ -159,10 +142,8 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Drawings.Count; i++)
|
List<Point> myDrawing = Drawings.Last();
|
||||||
{
|
Drawings[Drawings.Count - 1] = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, myDrawing[0], myDrawing[1]);
|
||||||
List<Point> Drawing = Drawings[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
|
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
|
||||||
{
|
{
|
||||||
|
|||||||
+25
-44
@@ -17,6 +17,8 @@ namespace Paint_2
|
|||||||
private List<List<Point>> _drawings;
|
private List<List<Point>> _drawings;
|
||||||
private List<List<Point>> _drawingsRedo;
|
private List<List<Point>> _drawingsRedo;
|
||||||
private bool _needsFullRefresh;
|
private bool _needsFullRefresh;
|
||||||
|
private bool _isShiftPressed;
|
||||||
|
private bool _isCtrlPressed;
|
||||||
private PaintToolUtils Utils;
|
private PaintToolUtils Utils;
|
||||||
private List<Color> _colors;
|
private List<Color> _colors;
|
||||||
private List<Color> _colorsRedo;
|
private List<Color> _colorsRedo;
|
||||||
@@ -33,6 +35,8 @@ namespace Paint_2
|
|||||||
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
||||||
public List<int> Widths { get => _widths; set => _widths = value; }
|
public List<int> Widths { get => _widths; set => _widths = value; }
|
||||||
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
||||||
|
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||||
|
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||||
public Color Color { get => _color; set => _color = value; }
|
public Color Color { get => _color; set => _color = value; }
|
||||||
public string Name { get => _name; set => _name = value; }
|
public string Name { get => _name; set => _name = value; }
|
||||||
public int Width { get => _width; set => _width = value; }
|
public int Width { get => _width; set => _width = value; }
|
||||||
@@ -72,33 +76,22 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
if (drawing.Count == 2)
|
if (drawing.Count == 2)
|
||||||
{
|
{
|
||||||
Point p1 = drawing[0];
|
Point start = drawing[0];
|
||||||
Point p2 = drawing[1];
|
Point end = drawing[1];
|
||||||
|
|
||||||
Point start = new Point(0, 0);
|
List<Point> points;
|
||||||
Point end = new Point(0, 0);
|
if (drawingCounter == Drawings.Count - 1)
|
||||||
|
|
||||||
if (p2.X > p1.X)
|
|
||||||
{
|
{
|
||||||
start.X = p1.X;
|
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||||
end.X = p2.X;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start.X = p2.X;
|
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start = points[0];
|
||||||
|
end = points[1];
|
||||||
|
|
||||||
gr.FillEllipse(new SolidBrush(Colors[drawingCounter]), new Rectangle(start, new Size(end.X - start.X, end.Y - start.Y)));
|
gr.FillEllipse(new SolidBrush(Colors[drawingCounter]), new Rectangle(start, new Size(end.X - start.X, end.Y - start.Y)));
|
||||||
}
|
}
|
||||||
drawingCounter++;
|
drawingCounter++;
|
||||||
@@ -116,32 +109,22 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
if (drawing.Count == 2)
|
if (drawing.Count == 2)
|
||||||
{
|
{
|
||||||
Point p1 = drawing[0];
|
Point start = drawing[0];
|
||||||
Point p2 = drawing[1];
|
Point end = drawing[1];
|
||||||
|
|
||||||
Point start = new Point(0, 0);
|
List<Point> points;
|
||||||
Point end = new Point(0, 0);
|
if (drawingCounter == Drawings.Count - 1)
|
||||||
|
|
||||||
if (p2.X > p1.X)
|
|
||||||
{
|
{
|
||||||
start.X = p1.X;
|
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||||
end.X = p2.X;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start.X = p2.X;
|
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start = points[0];
|
||||||
|
end = points[1];
|
||||||
|
|
||||||
Size size = new Size((end.X - start.X) / 2, (end.Y - start.Y) / 2);
|
Size size = new Size((end.X - start.X) / 2, (end.Y - start.Y) / 2);
|
||||||
result += "<ellipse cx=\"" + (start.X + size.Width) + "\" cy=\"" + (start.Y + size.Height) + "\" rx=\"" + size.Width + "\" ry=\"" + size.Height + "\" style=\"fill:rgb(" + Colors[drawingCounter].R + ", " + Colors[drawingCounter].G + ", " + Colors[drawingCounter].B + ");\"/>";
|
result += "<ellipse cx=\"" + (start.X + size.Width) + "\" cy=\"" + (start.Y + size.Height) + "\" rx=\"" + size.Width + "\" ry=\"" + size.Height + "\" style=\"fill:rgb(" + Colors[drawingCounter].R + ", " + Colors[drawingCounter].G + ", " + Colors[drawingCounter].B + ");\"/>";
|
||||||
result += newLine;
|
result += newLine;
|
||||||
@@ -160,10 +143,8 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Drawings.Count; i++)
|
List<Point> myDrawing = Drawings.Last();
|
||||||
{
|
Drawings[Drawings.Count - 1] = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, myDrawing[0], myDrawing[1]);
|
||||||
List<Point> Drawing = Drawings[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
|
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
|
||||||
{
|
{
|
||||||
|
|||||||
Generated
+39
-25
@@ -69,9 +69,10 @@
|
|||||||
this.btnLayerRemove = new System.Windows.Forms.Button();
|
this.btnLayerRemove = new System.Windows.Forms.Button();
|
||||||
this.BtnAddLayer = new System.Windows.Forms.Button();
|
this.BtnAddLayer = new System.Windows.Forms.Button();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
this.DebugLabel = new System.Windows.Forms.Label();
|
this.DebugLabel1 = new System.Windows.Forms.Label();
|
||||||
this.panel4 = new System.Windows.Forms.Panel();
|
this.panel4 = new System.Windows.Forms.Panel();
|
||||||
this.btnSvgExport = new System.Windows.Forms.Button();
|
this.btnSvgExport = new System.Windows.Forms.Button();
|
||||||
|
this.DebugLabel2 = new System.Windows.Forms.Label();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.canvas)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.canvas)).BeginInit();
|
||||||
this.panelFile.SuspendLayout();
|
this.panelFile.SuspendLayout();
|
||||||
this.panelDrawing.SuspendLayout();
|
this.panelDrawing.SuspendLayout();
|
||||||
@@ -94,7 +95,7 @@
|
|||||||
this.tbxProjectName.Location = new System.Drawing.Point(2, 4);
|
this.tbxProjectName.Location = new System.Drawing.Point(2, 4);
|
||||||
this.tbxProjectName.Margin = new System.Windows.Forms.Padding(2);
|
this.tbxProjectName.Margin = new System.Windows.Forms.Padding(2);
|
||||||
this.tbxProjectName.Name = "tbxProjectName";
|
this.tbxProjectName.Name = "tbxProjectName";
|
||||||
this.tbxProjectName.Size = new System.Drawing.Size(225, 38);
|
this.tbxProjectName.Size = new System.Drawing.Size(225, 32);
|
||||||
this.tbxProjectName.TabIndex = 0;
|
this.tbxProjectName.TabIndex = 0;
|
||||||
this.tbxProjectName.Text = "Untitled Project";
|
this.tbxProjectName.Text = "Untitled Project";
|
||||||
//
|
//
|
||||||
@@ -145,7 +146,7 @@
|
|||||||
this.lblSelectedColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.lblSelectedColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.lblSelectedColor.Location = new System.Drawing.Point(6, 23);
|
this.lblSelectedColor.Location = new System.Drawing.Point(6, 23);
|
||||||
this.lblSelectedColor.Name = "lblSelectedColor";
|
this.lblSelectedColor.Name = "lblSelectedColor";
|
||||||
this.lblSelectedColor.Size = new System.Drawing.Size(256, 18);
|
this.lblSelectedColor.Size = new System.Drawing.Size(202, 14);
|
||||||
this.lblSelectedColor.TabIndex = 1;
|
this.lblSelectedColor.TabIndex = 1;
|
||||||
this.lblSelectedColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
|
this.lblSelectedColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
|
||||||
//
|
//
|
||||||
@@ -193,7 +194,7 @@
|
|||||||
this.lblHeight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.lblHeight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.lblHeight.Location = new System.Drawing.Point(3, 38);
|
this.lblHeight.Location = new System.Drawing.Point(3, 38);
|
||||||
this.lblHeight.Name = "lblHeight";
|
this.lblHeight.Name = "lblHeight";
|
||||||
this.lblHeight.Size = new System.Drawing.Size(66, 18);
|
this.lblHeight.Size = new System.Drawing.Size(53, 14);
|
||||||
this.lblHeight.TabIndex = 34;
|
this.lblHeight.TabIndex = 34;
|
||||||
this.lblHeight.Text = "H:2000";
|
this.lblHeight.Text = "H:2000";
|
||||||
//
|
//
|
||||||
@@ -203,7 +204,7 @@
|
|||||||
this.lblWidth.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.lblWidth.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.lblWidth.Location = new System.Drawing.Point(3, 7);
|
this.lblWidth.Location = new System.Drawing.Point(3, 7);
|
||||||
this.lblWidth.Name = "lblWidth";
|
this.lblWidth.Name = "lblWidth";
|
||||||
this.lblWidth.Size = new System.Drawing.Size(69, 18);
|
this.lblWidth.Size = new System.Drawing.Size(57, 14);
|
||||||
this.lblWidth.TabIndex = 33;
|
this.lblWidth.TabIndex = 33;
|
||||||
this.lblWidth.Text = "W:2000";
|
this.lblWidth.Text = "W:2000";
|
||||||
//
|
//
|
||||||
@@ -239,7 +240,7 @@
|
|||||||
this.label14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.label14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.label14.Location = new System.Drawing.Point(6, 5);
|
this.label14.Location = new System.Drawing.Point(6, 5);
|
||||||
this.label14.Name = "label14";
|
this.label14.Name = "label14";
|
||||||
this.label14.Size = new System.Drawing.Size(150, 22);
|
this.label14.Size = new System.Drawing.Size(120, 18);
|
||||||
this.label14.TabIndex = 29;
|
this.label14.TabIndex = 29;
|
||||||
this.label14.Text = "Selected color";
|
this.label14.Text = "Selected color";
|
||||||
//
|
//
|
||||||
@@ -274,7 +275,7 @@
|
|||||||
this.lblHoveringColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.lblHoveringColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.lblHoveringColor.Location = new System.Drawing.Point(7, 23);
|
this.lblHoveringColor.Location = new System.Drawing.Point(7, 23);
|
||||||
this.lblHoveringColor.Name = "lblHoveringColor";
|
this.lblHoveringColor.Name = "lblHoveringColor";
|
||||||
this.lblHoveringColor.Size = new System.Drawing.Size(256, 18);
|
this.lblHoveringColor.Size = new System.Drawing.Size(202, 14);
|
||||||
this.lblHoveringColor.TabIndex = 1;
|
this.lblHoveringColor.TabIndex = 1;
|
||||||
this.lblHoveringColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
|
this.lblHoveringColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
|
||||||
//
|
//
|
||||||
@@ -285,7 +286,7 @@
|
|||||||
this.label15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.label15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.label15.Location = new System.Drawing.Point(7, 5);
|
this.label15.Location = new System.Drawing.Point(7, 5);
|
||||||
this.label15.Name = "label15";
|
this.label15.Name = "label15";
|
||||||
this.label15.Size = new System.Drawing.Size(150, 22);
|
this.label15.Size = new System.Drawing.Size(120, 18);
|
||||||
this.label15.TabIndex = 29;
|
this.label15.TabIndex = 29;
|
||||||
this.label15.Text = "Hovering color";
|
this.label15.Text = "Hovering color";
|
||||||
//
|
//
|
||||||
@@ -308,7 +309,7 @@
|
|||||||
0,
|
0,
|
||||||
0});
|
0});
|
||||||
this.nupPencilWidth.Name = "nupPencilWidth";
|
this.nupPencilWidth.Name = "nupPencilWidth";
|
||||||
this.nupPencilWidth.Size = new System.Drawing.Size(55, 33);
|
this.nupPencilWidth.Size = new System.Drawing.Size(55, 27);
|
||||||
this.nupPencilWidth.TabIndex = 17;
|
this.nupPencilWidth.TabIndex = 17;
|
||||||
this.nupPencilWidth.Value = new decimal(new int[] {
|
this.nupPencilWidth.Value = new decimal(new int[] {
|
||||||
10,
|
10,
|
||||||
@@ -409,7 +410,7 @@
|
|||||||
this.lsbTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
this.lsbTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
this.lsbTools.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.lsbTools.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.lsbTools.FormattingEnabled = true;
|
this.lsbTools.FormattingEnabled = true;
|
||||||
this.lsbTools.ItemHeight = 18;
|
this.lsbTools.ItemHeight = 14;
|
||||||
this.lsbTools.Location = new System.Drawing.Point(6, 20);
|
this.lsbTools.Location = new System.Drawing.Point(6, 20);
|
||||||
this.lsbTools.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
this.lsbTools.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
this.lsbTools.Name = "lsbTools";
|
this.lsbTools.Name = "lsbTools";
|
||||||
@@ -433,7 +434,7 @@
|
|||||||
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.label1.Location = new System.Drawing.Point(3, 2);
|
this.label1.Location = new System.Drawing.Point(3, 2);
|
||||||
this.label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(108, 20);
|
this.label1.Size = new System.Drawing.Size(84, 16);
|
||||||
this.label1.TabIndex = 36;
|
this.label1.TabIndex = 36;
|
||||||
this.label1.Text = "Paint tools";
|
this.label1.Text = "Paint tools";
|
||||||
//
|
//
|
||||||
@@ -547,7 +548,7 @@
|
|||||||
this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.label3.Location = new System.Drawing.Point(3, 8);
|
this.label3.Location = new System.Drawing.Point(3, 8);
|
||||||
this.label3.Name = "label3";
|
this.label3.Name = "label3";
|
||||||
this.label3.Size = new System.Drawing.Size(63, 20);
|
this.label3.Size = new System.Drawing.Size(49, 16);
|
||||||
this.label3.TabIndex = 37;
|
this.label3.TabIndex = 37;
|
||||||
this.label3.Text = "Layers";
|
this.label3.Text = "Layers";
|
||||||
//
|
//
|
||||||
@@ -597,17 +598,17 @@
|
|||||||
this.label2.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.label2.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.label2.Location = new System.Drawing.Point(7, 8);
|
this.label2.Location = new System.Drawing.Point(7, 8);
|
||||||
this.label2.Name = "label2";
|
this.label2.Name = "label2";
|
||||||
this.label2.Size = new System.Drawing.Size(0, 20);
|
this.label2.Size = new System.Drawing.Size(0, 16);
|
||||||
this.label2.TabIndex = 36;
|
this.label2.TabIndex = 36;
|
||||||
//
|
//
|
||||||
// DebugLabel
|
// DebugLabel1
|
||||||
//
|
//
|
||||||
this.DebugLabel.AutoSize = true;
|
this.DebugLabel1.AutoSize = true;
|
||||||
this.DebugLabel.Location = new System.Drawing.Point(18, 86);
|
this.DebugLabel1.Location = new System.Drawing.Point(17, 64);
|
||||||
this.DebugLabel.Name = "DebugLabel";
|
this.DebugLabel1.Name = "DebugLabel1";
|
||||||
this.DebugLabel.Size = new System.Drawing.Size(55, 18);
|
this.DebugLabel1.Size = new System.Drawing.Size(48, 14);
|
||||||
this.DebugLabel.TabIndex = 38;
|
this.DebugLabel1.TabIndex = 38;
|
||||||
this.DebugLabel.Text = "Debug";
|
this.DebugLabel1.Text = "Debug";
|
||||||
//
|
//
|
||||||
// panel4
|
// panel4
|
||||||
//
|
//
|
||||||
@@ -631,24 +632,34 @@
|
|||||||
this.btnSvgExport.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
|
this.btnSvgExport.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
|
||||||
this.btnSvgExport.Font = new System.Drawing.Font("Cascadia Code", 10.2F);
|
this.btnSvgExport.Font = new System.Drawing.Font("Cascadia Code", 10.2F);
|
||||||
this.btnSvgExport.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.btnSvgExport.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.btnSvgExport.Location = new System.Drawing.Point(1039, 545);
|
this.btnSvgExport.Location = new System.Drawing.Point(1014, 505);
|
||||||
this.btnSvgExport.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
this.btnSvgExport.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
this.btnSvgExport.Name = "btnSvgExport";
|
this.btnSvgExport.Name = "btnSvgExport";
|
||||||
this.btnSvgExport.Size = new System.Drawing.Size(150, 33);
|
this.btnSvgExport.Size = new System.Drawing.Size(196, 33);
|
||||||
this.btnSvgExport.TabIndex = 37;
|
this.btnSvgExport.TabIndex = 37;
|
||||||
this.btnSvgExport.Text = "Export SVG";
|
this.btnSvgExport.Text = "Export SVG";
|
||||||
this.btnSvgExport.UseVisualStyleBackColor = false;
|
this.btnSvgExport.UseVisualStyleBackColor = false;
|
||||||
this.btnSvgExport.Click += new System.EventHandler(this.btnSvgExport_Click);
|
this.btnSvgExport.Click += new System.EventHandler(this.btnSvgExport_Click);
|
||||||
//
|
//
|
||||||
|
// DebugLabel2
|
||||||
|
//
|
||||||
|
this.DebugLabel2.AutoSize = true;
|
||||||
|
this.DebugLabel2.Location = new System.Drawing.Point(17, 78);
|
||||||
|
this.DebugLabel2.Name = "DebugLabel2";
|
||||||
|
this.DebugLabel2.Size = new System.Drawing.Size(48, 14);
|
||||||
|
this.DebugLabel2.TabIndex = 39;
|
||||||
|
this.DebugLabel2.Text = "Debug";
|
||||||
|
//
|
||||||
// PaintForm
|
// PaintForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 14F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(34)))), ((int)(((byte)(34)))), ((int)(((byte)(34)))));
|
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(34)))), ((int)(((byte)(34)))), ((int)(((byte)(34)))));
|
||||||
this.ClientSize = new System.Drawing.Size(1222, 618);
|
this.ClientSize = new System.Drawing.Size(1222, 618);
|
||||||
|
this.Controls.Add(this.DebugLabel2);
|
||||||
this.Controls.Add(this.btnSvgExport);
|
this.Controls.Add(this.btnSvgExport);
|
||||||
this.Controls.Add(this.panel4);
|
this.Controls.Add(this.panel4);
|
||||||
this.Controls.Add(this.DebugLabel);
|
this.Controls.Add(this.DebugLabel1);
|
||||||
this.Controls.Add(this.panel3);
|
this.Controls.Add(this.panel3);
|
||||||
this.Controls.Add(this.panel1);
|
this.Controls.Add(this.panel1);
|
||||||
this.Controls.Add(this.panelHoverColor);
|
this.Controls.Add(this.panelHoverColor);
|
||||||
@@ -665,6 +676,8 @@
|
|||||||
this.Name = "PaintForm";
|
this.Name = "PaintForm";
|
||||||
this.Text = "Paint 2";
|
this.Text = "Paint 2";
|
||||||
this.Load += new System.EventHandler(this.PaintForm_Load);
|
this.Load += new System.EventHandler(this.PaintForm_Load);
|
||||||
|
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PaintForm_KeyDown);
|
||||||
|
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.PaintForm_KeyUp);
|
||||||
this.Resize += new System.EventHandler(this.PaintForm_Resize);
|
this.Resize += new System.EventHandler(this.PaintForm_Resize);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.canvas)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.canvas)).EndInit();
|
||||||
this.panelFile.ResumeLayout(false);
|
this.panelFile.ResumeLayout(false);
|
||||||
@@ -728,11 +741,12 @@
|
|||||||
private System.Windows.Forms.Button btnEyeDrop;
|
private System.Windows.Forms.Button btnEyeDrop;
|
||||||
private System.Windows.Forms.Button btnLayerRemove;
|
private System.Windows.Forms.Button btnLayerRemove;
|
||||||
private System.Windows.Forms.Button BtnAddLayer;
|
private System.Windows.Forms.Button BtnAddLayer;
|
||||||
private System.Windows.Forms.Label DebugLabel;
|
private System.Windows.Forms.Label DebugLabel1;
|
||||||
private System.Windows.Forms.Panel pnlLayers;
|
private System.Windows.Forms.Panel pnlLayers;
|
||||||
private System.Windows.Forms.Label label3;
|
private System.Windows.Forms.Label label3;
|
||||||
private System.Windows.Forms.Panel panel4;
|
private System.Windows.Forms.Panel panel4;
|
||||||
private System.Windows.Forms.Button btnSvgExport;
|
private System.Windows.Forms.Button btnSvgExport;
|
||||||
|
private System.Windows.Forms.Label DebugLabel2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+83
-10
@@ -42,6 +42,7 @@ namespace Paint_2
|
|||||||
Project = new Project("Untitled project", canvas.Size);
|
Project = new Project("Untitled project", canvas.Size);
|
||||||
SelectedLayers = new List<string>();
|
SelectedLayers = new List<string>();
|
||||||
SelectedLayers.Add(Project.GetAllLayers()[0].Id);
|
SelectedLayers.Add(Project.GetAllLayers()[0].Id);
|
||||||
|
this.KeyPreview = true;
|
||||||
RefreshUi();
|
RefreshUi();
|
||||||
}
|
}
|
||||||
private Point MousePositionToCanvasPosition()
|
private Point MousePositionToCanvasPosition()
|
||||||
@@ -50,6 +51,7 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
private void canvas_MouseDown(object sender, MouseEventArgs e)
|
private void canvas_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
|
canvas.Focus();
|
||||||
Color hoveringColor = GetHoverColor();
|
Color hoveringColor = GetHoverColor();
|
||||||
Point mousePosition = MousePositionToCanvasPosition();
|
Point mousePosition = MousePositionToCanvasPosition();
|
||||||
int toolWidth = (int)nupPencilWidth.Value;
|
int toolWidth = (int)nupPencilWidth.Value;
|
||||||
@@ -93,7 +95,7 @@ namespace Paint_2
|
|||||||
private void RefreshUi()
|
private void RefreshUi()
|
||||||
{
|
{
|
||||||
lsbTools.DataSource = Project.AvaibleTools;
|
lsbTools.DataSource = Project.AvaibleTools;
|
||||||
DebugLabel.Text = "";
|
DebugLabel1.Text = "";
|
||||||
|
|
||||||
PaintTool currentTool = Project.GetCurrentTool(SelectedLayers);
|
PaintTool currentTool = Project.GetCurrentTool(SelectedLayers);
|
||||||
if (currentTool != null && currentTool.NeedsFullRefresh)
|
if (currentTool != null && currentTool.NeedsFullRefresh)
|
||||||
@@ -104,7 +106,7 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
canvas.Image = Project.PaintLayers();
|
canvas.Image = Project.PaintLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lblSelectedColor.Text = ColorToString(Project.GetCurrentToolColor(SelectedLayers));
|
lblSelectedColor.Text = ColorToString(Project.GetCurrentToolColor(SelectedLayers));
|
||||||
btnSelectedColor.BackColor = Project.GetCurrentToolColor(SelectedLayers);
|
btnSelectedColor.BackColor = Project.GetCurrentToolColor(SelectedLayers);
|
||||||
@@ -131,6 +133,26 @@ namespace Paint_2
|
|||||||
|
|
||||||
pbxSample.Image = DrawSample(pbxSample.Size);
|
pbxSample.Image = DrawSample(pbxSample.Size);
|
||||||
|
|
||||||
|
DebugLabel1.Text = "Control";
|
||||||
|
DebugLabel2.Text = "Shift";
|
||||||
|
|
||||||
|
if (Project.GetCurrentTool(SelectedLayers).IsCtrlPressed)
|
||||||
|
{
|
||||||
|
DebugLabel1.ForeColor = Color.Green;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebugLabel1.ForeColor = Color.Red;
|
||||||
|
}
|
||||||
|
if (Project.GetCurrentTool(SelectedLayers).IsShiftPressed)
|
||||||
|
{
|
||||||
|
DebugLabel2.ForeColor = Color.Green;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebugLabel2.ForeColor = Color.Red;
|
||||||
|
}
|
||||||
|
|
||||||
if (Project.RandomColor)
|
if (Project.RandomColor)
|
||||||
{
|
{
|
||||||
btnRandomColor.BackColor = FLAT_GREEN;
|
btnRandomColor.BackColor = FLAT_GREEN;
|
||||||
@@ -174,7 +196,7 @@ namespace Paint_2
|
|||||||
if (currentTool is DotPencil)
|
if (currentTool is DotPencil)
|
||||||
{
|
{
|
||||||
DotPencil pencil = currentTool as DotPencil;
|
DotPencil pencil = currentTool as DotPencil;
|
||||||
pencil.Start(paint_tool_color,paint_tool_width);
|
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++)
|
||||||
{
|
{
|
||||||
@@ -192,8 +214,8 @@ namespace Paint_2
|
|||||||
|
|
||||||
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);
|
||||||
Point p3 = new Point(size.Width / 2 - paint_tool_width / 2,size.Height + paint_tool_width / 2);
|
Point p3 = new Point(size.Width / 2 - paint_tool_width / 2, size.Height + paint_tool_width / 2);
|
||||||
Point p4 = new Point(size.Width / 2 - paint_tool_width / 2, 0 - paint_tool_width/2);
|
Point p4 = new Point(size.Width / 2 - paint_tool_width / 2, 0 - paint_tool_width / 2);
|
||||||
Point p5 = new Point(size.Width + paint_tool_width / 2, 0 - paint_tool_width / 2);
|
Point p5 = new Point(size.Width + paint_tool_width / 2, 0 - paint_tool_width / 2);
|
||||||
Point p6 = new Point(size.Width + paint_tool_width / 2, size.Height + paint_tool_width / 2);
|
Point p6 = new Point(size.Width + paint_tool_width / 2, size.Height + paint_tool_width / 2);
|
||||||
// I KNOW THIS IS HARD CODED BUT ITS ONLY PURPOSE IS TO BE PRETTY so it does'nt matter
|
// I KNOW THIS IS HARD CODED BUT ITS ONLY PURPOSE IS TO BE PRETTY so it does'nt matter
|
||||||
@@ -221,11 +243,10 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
if (currentTool is RectanglePencil || currentTool is RectangleBorderPencil || currentTool is EllipsePencil || currentTool is EllipseBorderPencil)
|
if (currentTool is RectanglePencil || currentTool is RectangleBorderPencil || currentTool is EllipsePencil || currentTool is EllipseBorderPencil)
|
||||||
{
|
{
|
||||||
currentTool.Start(paint_tool_color,paint_tool_width);
|
currentTool.Start(paint_tool_color, paint_tool_width);
|
||||||
currentTool.Add(new Point(0 + size.Width / 10,0 + size.Height / 10));
|
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.Add(new Point(size.Width - size.Width / 10, size.Height - size.Height / 10));
|
||||||
currentTool.Stop();
|
currentTool.Stop();
|
||||||
|
|
||||||
currentTool.Paint(map);
|
currentTool.Paint(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,7 +305,7 @@ namespace Paint_2
|
|||||||
int toolId = lsbTools.SelectedIndex;
|
int toolId = lsbTools.SelectedIndex;
|
||||||
Project.ChangeTool(SelectedLayers, toolId);
|
Project.ChangeTool(SelectedLayers, toolId);
|
||||||
//Yeah that is a little janky but I just want to refresh the tool
|
//Yeah that is a little janky but I just want to refresh the tool
|
||||||
nupPencilWidth_ValueChanged(sender,e);
|
nupPencilWidth_ValueChanged(sender, e);
|
||||||
RefreshUi();
|
RefreshUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +492,59 @@ namespace Paint_2
|
|||||||
|
|
||||||
private void btnSvgExport_Click(object sender, EventArgs e)
|
private void btnSvgExport_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Project.ConvertToSVG();
|
FolderBrowserDialog fbd = new FolderBrowserDialog();
|
||||||
|
fbd.Description = "Custom Description";
|
||||||
|
|
||||||
|
if (fbd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
string SelectedPath = fbd.SelectedPath;
|
||||||
|
|
||||||
|
if (Project.SaveSvg(SelectedPath, tbxProjectName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Svg saved at " + SelectedPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Ooops, could not save the SVG in " + SelectedPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PaintForm_KeyPress(object sender, KeyPressEventArgs e)
|
||||||
|
{
|
||||||
|
//empty for now
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PaintForm_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.KeyCode)
|
||||||
|
{
|
||||||
|
case Keys.ControlKey:
|
||||||
|
Project.CtrlDown();
|
||||||
|
break;
|
||||||
|
case Keys.ShiftKey:
|
||||||
|
Project.ShiftDown();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//send the key to the tools
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PaintForm_KeyUp(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.KeyCode)
|
||||||
|
{
|
||||||
|
case Keys.ControlKey:
|
||||||
|
Project.CtrlUp();
|
||||||
|
break;
|
||||||
|
case Keys.ShiftKey:
|
||||||
|
Project.ShiftUp();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//send the key to the tools
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ using System.Drawing;
|
|||||||
|
|
||||||
namespace Paint_2
|
namespace Paint_2
|
||||||
{
|
{
|
||||||
public interface PaintTool:ICloneable
|
public interface PaintTool : ICloneable
|
||||||
{
|
{
|
||||||
List<List<Point>> Drawings { get; set; }
|
List<List<Point>> Drawings { get; set; }
|
||||||
List<List<Point>> DrawingsRedo { get; set; }
|
List<List<Point>> DrawingsRedo { get; set; }
|
||||||
@@ -25,6 +25,8 @@ namespace Paint_2
|
|||||||
bool NeedsFullRefresh { get; set; }
|
bool NeedsFullRefresh { get; set; }
|
||||||
int Width { get; set; }
|
int Width { get; set; }
|
||||||
string Name { get; set; }
|
string Name { get; set; }
|
||||||
|
bool IsCtrlPressed { get; set; }
|
||||||
|
bool IsShiftPressed { get; set; }
|
||||||
|
|
||||||
void Start(Color color, int width);
|
void Start(Color color, int width);
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|||||||
@@ -92,6 +92,33 @@ namespace Paint_2
|
|||||||
result.Reverse();
|
result.Reverse();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public List<Point> ConvertRectangleIntoPositive(bool IsCtrlPressed,Point start, Point end)
|
||||||
|
{
|
||||||
|
Point newStart = new Point(start.X, start.Y);
|
||||||
|
Point newEnd = new Point(end.X, end.Y);
|
||||||
|
|
||||||
|
int xDiff = end.X - start.X;
|
||||||
|
int yDiff = end.Y - start.Y;
|
||||||
|
|
||||||
|
Size size = new Size(xDiff, yDiff);
|
||||||
|
|
||||||
|
if (xDiff < 0)
|
||||||
|
{
|
||||||
|
newStart = new Point(end.X, newStart.Y);
|
||||||
|
}
|
||||||
|
if (yDiff < 0)
|
||||||
|
{
|
||||||
|
newStart = new Point(newStart.X, end.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsCtrlPressed)
|
||||||
|
{
|
||||||
|
size = new Size(Math.Max(Math.Abs(xDiff), Math.Abs(yDiff)), Math.Max(Math.Abs(xDiff), Math.Abs(yDiff)));
|
||||||
|
}
|
||||||
|
|
||||||
|
newEnd = new Point(newStart.X + Math.Abs(size.Width), newStart.Y + Math.Abs(size.Height));
|
||||||
|
return new List<Point> { newStart, newEnd };
|
||||||
|
}
|
||||||
public Point Lerp(Point start, Point end, float t)
|
public Point Lerp(Point start, Point end, float t)
|
||||||
{
|
{
|
||||||
int xDiff = end.X - start.X;
|
int xDiff = end.X - start.X;
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace Paint_2
|
|||||||
private List<List<Point>> _drawingsRedo;
|
private List<List<Point>> _drawingsRedo;
|
||||||
private PaintToolUtils Utils;
|
private PaintToolUtils Utils;
|
||||||
private bool _needsFullRefresh;
|
private bool _needsFullRefresh;
|
||||||
|
private bool _isShiftPressed;
|
||||||
|
private bool _isCtrlPressed;
|
||||||
private List<Color> _colors;
|
private List<Color> _colors;
|
||||||
private List<Color> _colorsRedo;
|
private List<Color> _colorsRedo;
|
||||||
private List<int> _widths;
|
private List<int> _widths;
|
||||||
@@ -35,6 +37,8 @@ namespace Paint_2
|
|||||||
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
||||||
public List<int> Widths { get => _widths; set => _widths = value; }
|
public List<int> Widths { get => _widths; set => _widths = value; }
|
||||||
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
||||||
|
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||||
|
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||||
public Color Color { get => _color; set => _color = value; }
|
public Color Color { get => _color; set => _color = value; }
|
||||||
public string Name { get => _name; set => _name = value; }
|
public string Name { get => _name; set => _name = value; }
|
||||||
public int Width { get => _width; set => _width = value; }
|
public int Width { get => _width; set => _width = value; }
|
||||||
|
|||||||
+54
-8
@@ -29,6 +29,7 @@ namespace Paint_2
|
|||||||
private Random _random;
|
private Random _random;
|
||||||
private bool _drawing;
|
private bool _drawing;
|
||||||
private string _name;
|
private string _name;
|
||||||
|
|
||||||
|
|
||||||
public List<PaintTool> AvaibleTools { get => _avaibleTools; set => _avaibleTools = value; }
|
public List<PaintTool> AvaibleTools { get => _avaibleTools; set => _avaibleTools = value; }
|
||||||
//public Sketch CurrentLayer { get => _currentSketch; set => _currentSketch = value; }
|
//public Sketch CurrentLayer { get => _currentSketch; set => _currentSketch = value; }
|
||||||
@@ -272,14 +273,18 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
public Bitmap PaintLayers()
|
public Bitmap PaintLayers()
|
||||||
{
|
{
|
||||||
Bitmap result = new Bitmap(CanvasSize.Width, CanvasSize.Height);
|
Bitmap result = null;
|
||||||
Graphics gr = Graphics.FromImage(result);
|
if (CanvasSize.Width != 0 && CanvasSize.Height != 0)
|
||||||
foreach (string layerId in LayersToPrint)
|
|
||||||
{
|
{
|
||||||
Sketch layer = FindSketch(Layers, layerId);
|
result = new Bitmap(CanvasSize.Width, CanvasSize.Height);
|
||||||
if (layer != null)
|
Graphics gr = Graphics.FromImage(result);
|
||||||
|
foreach (string layerId in LayersToPrint)
|
||||||
{
|
{
|
||||||
gr.DrawImage(layer.Paint(), Point.Empty);
|
Sketch layer = FindSketch(Layers, layerId);
|
||||||
|
if (layer != null)
|
||||||
|
{
|
||||||
|
gr.DrawImage(layer.Paint(), Point.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -416,8 +421,35 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public void CtrlDown()
|
||||||
public void ConvertToSVG()
|
{
|
||||||
|
foreach (Sketch layer in Layers)
|
||||||
|
{
|
||||||
|
layer.CtrlDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void CtrlUp()
|
||||||
|
{
|
||||||
|
foreach (Sketch layer in Layers)
|
||||||
|
{
|
||||||
|
layer.CtrlUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void ShiftDown()
|
||||||
|
{
|
||||||
|
foreach (Sketch layer in Layers)
|
||||||
|
{
|
||||||
|
layer.ShiftDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void ShiftUp()
|
||||||
|
{
|
||||||
|
foreach (Sketch layer in Layers)
|
||||||
|
{
|
||||||
|
layer.ShiftUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string ConvertToSVG()
|
||||||
{
|
{
|
||||||
string fileContent = "";
|
string fileContent = "";
|
||||||
string newLine = Environment.NewLine;
|
string newLine = Environment.NewLine;
|
||||||
@@ -434,6 +466,20 @@ namespace Paint_2
|
|||||||
|
|
||||||
fileContent += newLine;
|
fileContent += newLine;
|
||||||
fileContent += "</svg>";
|
fileContent += "</svg>";
|
||||||
|
return fileContent;
|
||||||
|
}
|
||||||
|
public bool SaveSvg(string path,string fileName)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
if (Directory.Exists(path))
|
||||||
|
{
|
||||||
|
using (StreamWriter sw = File.CreateText(path + "\\" + fileName + ".svg"))
|
||||||
|
{
|
||||||
|
sw.WriteLine(ConvertToSVG());
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace Paint_2
|
|||||||
private List<List<Point>> _drawings;
|
private List<List<Point>> _drawings;
|
||||||
private List<List<Point>> _drawingsRedo;
|
private List<List<Point>> _drawingsRedo;
|
||||||
private bool _needsFullRefresh;
|
private bool _needsFullRefresh;
|
||||||
|
private bool _isShiftPressed;
|
||||||
|
private bool _isCtrlPressed;
|
||||||
private PaintToolUtils Utils;
|
private PaintToolUtils Utils;
|
||||||
private List<Color> _colors;
|
private List<Color> _colors;
|
||||||
private List<Color> _colorsRedo;
|
private List<Color> _colorsRedo;
|
||||||
@@ -33,6 +35,8 @@ namespace Paint_2
|
|||||||
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
||||||
public List<int> Widths { get => _widths; set => _widths = value; }
|
public List<int> Widths { get => _widths; set => _widths = value; }
|
||||||
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
||||||
|
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||||
|
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||||
public Color Color { get => _color; set => _color = value; }
|
public Color Color { get => _color; set => _color = value; }
|
||||||
public string Name { get => _name; set => _name = value; }
|
public string Name { get => _name; set => _name = value; }
|
||||||
public int Width { get => _width; set => _width = value; }
|
public int Width { get => _width; set => _width = value; }
|
||||||
@@ -72,33 +76,22 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
if (drawing.Count == 2)
|
if (drawing.Count == 2)
|
||||||
{
|
{
|
||||||
Point p1 = drawing[0];
|
Point start = drawing[0];
|
||||||
Point p2 = drawing[1];
|
Point end = drawing[1];
|
||||||
|
|
||||||
Point start = new Point(0, 0);
|
List<Point> points;
|
||||||
Point end = new Point(0, 0);
|
if (drawingCounter == Drawings.Count - 1)
|
||||||
|
|
||||||
if (p2.X > p1.X)
|
|
||||||
{
|
{
|
||||||
start.X = p1.X;
|
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||||
end.X = p2.X;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start.X = p2.X;
|
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start = points[0];
|
||||||
|
end = points[1];
|
||||||
|
|
||||||
gr.DrawRectangle(new Pen(Colors[drawingCounter], Widths[drawingCounter]), new Rectangle(start, new Size(end.X - start.X, end.Y - start.Y)));
|
gr.DrawRectangle(new Pen(Colors[drawingCounter], Widths[drawingCounter]), new Rectangle(start, new Size(end.X - start.X, end.Y - start.Y)));
|
||||||
}
|
}
|
||||||
drawingCounter++;
|
drawingCounter++;
|
||||||
@@ -116,32 +109,19 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
if (drawing.Count == 2)
|
if (drawing.Count == 2)
|
||||||
{
|
{
|
||||||
Point p1 = drawing[0];
|
Point start = drawing[0];
|
||||||
Point p2 = drawing[1];
|
Point end = drawing[1];
|
||||||
|
|
||||||
Point start = new Point(0, 0);
|
List<Point> points;
|
||||||
Point end = new Point(0, 0);
|
if (drawingCounter == Drawings.Count - 1)
|
||||||
|
|
||||||
if (p2.X > p1.X)
|
|
||||||
{
|
{
|
||||||
start.X = p1.X;
|
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||||
end.X = p2.X;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start.X = p2.X;
|
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result += "<rect x=\"" + start.X + "\" y=\"" + start.Y + "\" width=\"" + (end.X - start.X) + "\" height=\"" + (end.Y - start.Y) + "\" style=\"stroke:rgb(" + Colors[drawingCounter].R + ", " + Colors[drawingCounter].G + ", " + Colors[drawingCounter].B + ");\" stroke-width=\""+ Widths[drawingCounter]+"\" fill=\"none\"/>";
|
result += "<rect x=\"" + start.X + "\" y=\"" + start.Y + "\" width=\"" + (end.X - start.X) + "\" height=\"" + (end.Y - start.Y) + "\" style=\"stroke:rgb(" + Colors[drawingCounter].R + ", " + Colors[drawingCounter].G + ", " + Colors[drawingCounter].B + ");\" stroke-width=\""+ Widths[drawingCounter]+"\" fill=\"none\"/>";
|
||||||
result += newLine;
|
result += newLine;
|
||||||
}
|
}
|
||||||
@@ -159,10 +139,8 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Drawings.Count; i++)
|
List<Point> myDrawing = Drawings.Last();
|
||||||
{
|
Drawings[Drawings.Count - 1] = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, myDrawing[0], myDrawing[1]);
|
||||||
List<Point> Drawing = Drawings[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
|
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
|
||||||
{
|
{
|
||||||
|
|||||||
+20
-52
@@ -17,6 +17,8 @@ namespace Paint_2
|
|||||||
private List<List<Point>> _drawings;
|
private List<List<Point>> _drawings;
|
||||||
private List<List<Point>> _drawingsRedo;
|
private List<List<Point>> _drawingsRedo;
|
||||||
private bool _needsFullRefresh;
|
private bool _needsFullRefresh;
|
||||||
|
private bool _isShiftPressed;
|
||||||
|
private bool _isCtrlPressed;
|
||||||
private PaintToolUtils Utils;
|
private PaintToolUtils Utils;
|
||||||
private List<Color> _colors;
|
private List<Color> _colors;
|
||||||
private List<Color> _colorsRedo;
|
private List<Color> _colorsRedo;
|
||||||
@@ -36,6 +38,8 @@ namespace Paint_2
|
|||||||
public Color Color { get => _color; set => _color = value; }
|
public Color Color { get => _color; set => _color = value; }
|
||||||
public string Name { get => _name; set => _name = value; }
|
public string Name { get => _name; set => _name = value; }
|
||||||
public int Width { get => _width; set => _width = value; }
|
public int Width { get => _width; set => _width = value; }
|
||||||
|
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||||
|
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||||
|
|
||||||
public RectanglePencil(string name)
|
public RectanglePencil(string name)
|
||||||
{
|
{
|
||||||
@@ -51,13 +55,14 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
public void Add(Point point)
|
public void Add(Point point)
|
||||||
{
|
{
|
||||||
|
|
||||||
List<Point> myDrawing = Drawings[Drawings.Count - 1];
|
List<Point> myDrawing = Drawings[Drawings.Count - 1];
|
||||||
if (myDrawing.Count == 0 || myDrawing.Count == 1)
|
if (myDrawing.Count == 0 || myDrawing.Count == 1)
|
||||||
{
|
{
|
||||||
myDrawing.Add(point);
|
myDrawing.Add(point);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
myDrawing[1] = point;
|
myDrawing[1] = point;
|
||||||
}
|
}
|
||||||
Drawings[Drawings.Count - 1] = myDrawing;
|
Drawings[Drawings.Count - 1] = myDrawing;
|
||||||
@@ -66,40 +71,21 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
Graphics gr = Graphics.FromImage(canvas);
|
Graphics gr = Graphics.FromImage(canvas);
|
||||||
int drawingCounter = 0;
|
int drawingCounter = 0;
|
||||||
Size pointSize;
|
|
||||||
|
|
||||||
foreach (List<Point> drawing in Drawings)
|
foreach (List<Point> drawing in Drawings)
|
||||||
{
|
{
|
||||||
if (drawing.Count == 2)
|
if (drawing.Count == 2)
|
||||||
{
|
{
|
||||||
Point p1 = drawing[0];
|
List<Point> points;
|
||||||
Point p2 = drawing[1];
|
if (drawingCounter == Drawings.Count - 1)
|
||||||
|
|
||||||
Point start = new Point(0,0);
|
|
||||||
Point end = new Point(0,0);
|
|
||||||
|
|
||||||
if (p2.X > p1.X)
|
|
||||||
{
|
{
|
||||||
start.X = p1.X;
|
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||||
end.X = p2.X;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start.X = p2.X;
|
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||||
end.X = p1.X;
|
|
||||||
}
|
}
|
||||||
if (p2.Y > p1.Y)
|
gr.FillRectangle(new SolidBrush(Colors[drawingCounter]), new Rectangle(points[0], new Size(points[1].X - points[0].X, points[1].Y - points[0].Y)));
|
||||||
{
|
|
||||||
start.Y = p1.Y;
|
|
||||||
end.Y = p2.Y;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
start.Y = p2.Y;
|
|
||||||
end.Y = p1.Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
gr.FillRectangle(new SolidBrush(Colors[drawingCounter]), new Rectangle(start, new Size(end.X - start.X, end.Y - start.Y)));
|
|
||||||
}
|
}
|
||||||
drawingCounter++;
|
drawingCounter++;
|
||||||
}
|
}
|
||||||
@@ -110,41 +96,25 @@ namespace Paint_2
|
|||||||
string newLine = Environment.NewLine;
|
string newLine = Environment.NewLine;
|
||||||
|
|
||||||
int drawingCounter = 0;
|
int drawingCounter = 0;
|
||||||
Size pointSize;
|
|
||||||
|
|
||||||
foreach (List<Point> drawing in Drawings)
|
foreach (List<Point> drawing in Drawings)
|
||||||
{
|
{
|
||||||
if (drawing.Count == 2)
|
if (drawing.Count == 2)
|
||||||
{
|
{
|
||||||
Point p1 = drawing[0];
|
List<Point> points;
|
||||||
Point p2 = drawing[1];
|
if (drawingCounter == Drawings.Count -1)
|
||||||
|
|
||||||
Point start = new Point(0, 0);
|
|
||||||
Point end = new Point(0, 0);
|
|
||||||
|
|
||||||
if (p2.X > p1.X)
|
|
||||||
{
|
{
|
||||||
start.X = p1.X;
|
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||||
end.X = p2.X;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start.X = p2.X;
|
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
Point start = points[0];
|
||||||
|
Point end = points[1];
|
||||||
result += "<rect x=\"" + start.X + "\" y=\"" + start.Y + "\" width=\"" + (end.X - start.X) + "\" height=\"" + (end.Y - start.Y) + "\" style=\"fill:rgb(" + Colors[drawingCounter].R + ", " + Colors[drawingCounter].G + ", " + Colors[drawingCounter].B + ");\"/>";
|
result += "<rect x=\"" + start.X + "\" y=\"" + start.Y + "\" width=\"" + (end.X - start.X) + "\" height=\"" + (end.Y - start.Y) + "\" style=\"fill:rgb(" + Colors[drawingCounter].R + ", " + Colors[drawingCounter].G + ", " + Colors[drawingCounter].B + ");\"/>";
|
||||||
result += newLine;
|
result += newLine;
|
||||||
//gr.DrawRectangle(new Pen(Colors[drawingCounter], Widths[drawingCounter]), new Rectangle(start, new Size(end.X - start.X, end.Y - start.Y)));
|
|
||||||
}
|
}
|
||||||
drawingCounter++;
|
drawingCounter++;
|
||||||
}
|
}
|
||||||
@@ -160,10 +130,8 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Drawings.Count; i++)
|
List<Point> myDrawing = Drawings.Last();
|
||||||
{
|
Drawings[Drawings.Count - 1] = Utils.ConvertRectangleIntoPositive(IsCtrlPressed,myDrawing[0], myDrawing[1]);
|
||||||
List<Point> Drawing = Drawings[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
|
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -143,6 +143,28 @@ namespace Paint_2
|
|||||||
//Todo
|
//Todo
|
||||||
return Color.FromArgb(0x34, 0xF4, 0xFF);
|
return Color.FromArgb(0x34, 0xF4, 0xFF);
|
||||||
}
|
}
|
||||||
|
public void CtrlDown()
|
||||||
|
{
|
||||||
|
if (!CurrentTool.IsCtrlPressed)
|
||||||
|
{
|
||||||
|
CurrentTool.IsCtrlPressed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void CtrlUp()
|
||||||
|
{
|
||||||
|
CurrentTool.IsCtrlPressed = false;
|
||||||
|
}
|
||||||
|
public void ShiftDown()
|
||||||
|
{
|
||||||
|
if (!CurrentTool.IsShiftPressed)
|
||||||
|
{
|
||||||
|
CurrentTool.IsShiftPressed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void ShiftUp()
|
||||||
|
{
|
||||||
|
CurrentTool.IsShiftPressed = false;
|
||||||
|
}
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return Name;
|
return Name;
|
||||||
|
|||||||
Reference in New Issue
Block a user