Reworked 4 pencils and added the ability to CTRL+Drag to change the shapes while drawing them
This commit is contained in:
@@ -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; }
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
34
Paint_2/Form1.Designer.cs
generated
34
Paint_2/Form1.Designer.cs
generated
@@ -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();
|
||||||
@@ -600,14 +601,14 @@
|
|||||||
this.label2.Size = new System.Drawing.Size(0, 16);
|
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(48, 14);
|
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
|
||||||
//
|
//
|
||||||
@@ -640,15 +641,25 @@
|
|||||||
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(8F, 14F);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,10 +498,10 @@ namespace Paint_2
|
|||||||
if (fbd.ShowDialog() == DialogResult.OK)
|
if (fbd.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
string SelectedPath = fbd.SelectedPath;
|
string SelectedPath = fbd.SelectedPath;
|
||||||
|
|
||||||
if (Project.SaveSvg(SelectedPath,tbxProjectName.Text))
|
if (Project.SaveSvg(SelectedPath, tbxProjectName.Text))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Svg saved at "+ SelectedPath);
|
MessageBox.Show("Svg saved at " + SelectedPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -488,5 +509,42 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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; }
|
||||||
|
|||||||
@@ -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,7 +421,34 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public void CtrlDown()
|
||||||
|
{
|
||||||
|
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()
|
public string ConvertToSVG()
|
||||||
{
|
{
|
||||||
string fileContent = "";
|
string fileContent = "";
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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