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>> _drawingsRedo;
|
||||
private bool _needsFullRefresh;
|
||||
private bool _isCtrlPressed;
|
||||
private bool _isShiftPressed;
|
||||
private PaintToolUtils Utils;
|
||||
private List<Color> _colors;
|
||||
private List<Color> _colorsRedo;
|
||||
@@ -34,6 +36,8 @@ namespace Paint_2
|
||||
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
||||
public List<int> Widths { get => _widths; set => _widths = value; }
|
||||
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
||||
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||
public Color Color { get => _color; set => _color = value; }
|
||||
public string Name { get => _name; set => _name = value; }
|
||||
public int Width { get => _width; set => _width = value; }
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Paint_2
|
||||
private List<List<Point>> _drawings;
|
||||
private List<List<Point>> _drawingsRedo;
|
||||
private bool _needsFullRefresh;
|
||||
private bool _isShiftPressed;
|
||||
private bool _isCtrlPressed;
|
||||
private PaintToolUtils Utils;
|
||||
private List<Color> _colors;
|
||||
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>> DrawingsRedo { get => _drawingsRedo; set => _drawingsRedo = 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> ColorsRedo { get => _colorsRedo; set => _colorsRedo = 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>> _drawingsRedo;
|
||||
private bool _needsFullRefresh;
|
||||
private bool _isShiftPressed;
|
||||
private bool _isCtrlPressed;
|
||||
private PaintToolUtils Utils;
|
||||
private List<Color> _colors;
|
||||
private List<Color> _colorsRedo;
|
||||
@@ -34,6 +36,8 @@ namespace Paint_2
|
||||
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
||||
public List<int> Widths { get => _widths; set => _widths = value; }
|
||||
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
||||
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||
public Color Color { get => _color; set => _color = value; }
|
||||
public string Name { get => _name; set => _name = value; }
|
||||
public int Width { get => _width; set => _width = value; }
|
||||
@@ -75,32 +79,22 @@ namespace Paint_2
|
||||
{
|
||||
if (drawing.Count == 2)
|
||||
{
|
||||
Point p1 = drawing[0];
|
||||
Point p2 = drawing[1];
|
||||
Point start = drawing[0];
|
||||
Point end = drawing[1];
|
||||
|
||||
Point start = new Point(0, 0);
|
||||
Point end = new Point(0, 0);
|
||||
|
||||
if (p2.X > p1.X)
|
||||
List<Point> points;
|
||||
if (drawingCounter == Drawings.Count - 1)
|
||||
{
|
||||
start.X = p1.X;
|
||||
end.X = p2.X;
|
||||
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
start.X = p2.X;
|
||||
end.X = p1.X;
|
||||
}
|
||||
if (p2.Y > p1.Y)
|
||||
{
|
||||
start.Y = p1.Y;
|
||||
end.Y = p2.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
start.Y = p2.Y;
|
||||
end.Y = p1.Y;
|
||||
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||
}
|
||||
|
||||
start = points[0];
|
||||
end = points[1];
|
||||
|
||||
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 += newLine;
|
||||
@@ -117,33 +111,22 @@ namespace Paint_2
|
||||
{
|
||||
if (drawing.Count == 2)
|
||||
{
|
||||
Point p1 = drawing[0];
|
||||
Point p2 = drawing[1];
|
||||
Point start = drawing[0];
|
||||
Point end = drawing[1];
|
||||
|
||||
Point start = new Point(0, 0);
|
||||
Point end = new Point(0, 0);
|
||||
|
||||
if (p2.X > p1.X)
|
||||
List<Point> points;
|
||||
if (drawingCounter == Drawings.Count - 1)
|
||||
{
|
||||
start.X = p1.X;
|
||||
end.X = p2.X;
|
||||
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
start.X = p2.X;
|
||||
end.X = p1.X;
|
||||
}
|
||||
if (p2.Y > p1.Y)
|
||||
{
|
||||
start.Y = p1.Y;
|
||||
end.Y = p2.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
start.Y = p2.Y;
|
||||
end.Y = p1.Y;
|
||||
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
drawingCounter++;
|
||||
@@ -159,10 +142,8 @@ namespace Paint_2
|
||||
}
|
||||
public void Stop()
|
||||
{
|
||||
for (int i = 0; i < Drawings.Count; i++)
|
||||
{
|
||||
List<Point> Drawing = Drawings[i];
|
||||
}
|
||||
List<Point> myDrawing = Drawings.Last();
|
||||
Drawings[Drawings.Count - 1] = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, myDrawing[0], myDrawing[1]);
|
||||
}
|
||||
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>> _drawingsRedo;
|
||||
private bool _needsFullRefresh;
|
||||
private bool _isShiftPressed;
|
||||
private bool _isCtrlPressed;
|
||||
private PaintToolUtils Utils;
|
||||
private List<Color> _colors;
|
||||
private List<Color> _colorsRedo;
|
||||
@@ -33,6 +35,8 @@ namespace Paint_2
|
||||
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
||||
public List<int> Widths { get => _widths; set => _widths = value; }
|
||||
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
||||
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||
public Color Color { get => _color; set => _color = value; }
|
||||
public string Name { get => _name; set => _name = value; }
|
||||
public int Width { get => _width; set => _width = value; }
|
||||
@@ -72,33 +76,22 @@ namespace Paint_2
|
||||
{
|
||||
if (drawing.Count == 2)
|
||||
{
|
||||
Point p1 = drawing[0];
|
||||
Point p2 = drawing[1];
|
||||
Point start = drawing[0];
|
||||
Point end = drawing[1];
|
||||
|
||||
Point start = new Point(0, 0);
|
||||
Point end = new Point(0, 0);
|
||||
|
||||
if (p2.X > p1.X)
|
||||
List<Point> points;
|
||||
if (drawingCounter == Drawings.Count - 1)
|
||||
{
|
||||
start.X = p1.X;
|
||||
end.X = p2.X;
|
||||
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
start.X = p2.X;
|
||||
end.X = p1.X;
|
||||
}
|
||||
if (p2.Y > p1.Y)
|
||||
{
|
||||
start.Y = p1.Y;
|
||||
end.Y = p2.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
start.Y = p2.Y;
|
||||
end.Y = p1.Y;
|
||||
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
drawingCounter++;
|
||||
@@ -116,32 +109,22 @@ namespace Paint_2
|
||||
{
|
||||
if (drawing.Count == 2)
|
||||
{
|
||||
Point p1 = drawing[0];
|
||||
Point p2 = drawing[1];
|
||||
Point start = drawing[0];
|
||||
Point end = drawing[1];
|
||||
|
||||
Point start = new Point(0, 0);
|
||||
Point end = new Point(0, 0);
|
||||
|
||||
if (p2.X > p1.X)
|
||||
List<Point> points;
|
||||
if (drawingCounter == Drawings.Count - 1)
|
||||
{
|
||||
start.X = p1.X;
|
||||
end.X = p2.X;
|
||||
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
start.X = p2.X;
|
||||
end.X = p1.X;
|
||||
}
|
||||
if (p2.Y > p1.Y)
|
||||
{
|
||||
start.Y = p1.Y;
|
||||
end.Y = p2.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
start.Y = p2.Y;
|
||||
end.Y = p1.Y;
|
||||
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||
}
|
||||
|
||||
start = points[0];
|
||||
end = points[1];
|
||||
|
||||
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 += newLine;
|
||||
@@ -160,10 +143,8 @@ namespace Paint_2
|
||||
}
|
||||
public void Stop()
|
||||
{
|
||||
for (int i = 0; i < Drawings.Count; i++)
|
||||
{
|
||||
List<Point> Drawing = Drawings[i];
|
||||
}
|
||||
List<Point> myDrawing = Drawings.Last();
|
||||
Drawings[Drawings.Count - 1] = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, myDrawing[0], myDrawing[1]);
|
||||
}
|
||||
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.BtnAddLayer = new System.Windows.Forms.Button();
|
||||
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.btnSvgExport = new System.Windows.Forms.Button();
|
||||
this.DebugLabel2 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.canvas)).BeginInit();
|
||||
this.panelFile.SuspendLayout();
|
||||
this.panelDrawing.SuspendLayout();
|
||||
@@ -600,14 +601,14 @@
|
||||
this.label2.Size = new System.Drawing.Size(0, 16);
|
||||
this.label2.TabIndex = 36;
|
||||
//
|
||||
// DebugLabel
|
||||
// DebugLabel1
|
||||
//
|
||||
this.DebugLabel.AutoSize = true;
|
||||
this.DebugLabel.Location = new System.Drawing.Point(18, 86);
|
||||
this.DebugLabel.Name = "DebugLabel";
|
||||
this.DebugLabel.Size = new System.Drawing.Size(48, 14);
|
||||
this.DebugLabel.TabIndex = 38;
|
||||
this.DebugLabel.Text = "Debug";
|
||||
this.DebugLabel1.AutoSize = true;
|
||||
this.DebugLabel1.Location = new System.Drawing.Point(17, 64);
|
||||
this.DebugLabel1.Name = "DebugLabel1";
|
||||
this.DebugLabel1.Size = new System.Drawing.Size(48, 14);
|
||||
this.DebugLabel1.TabIndex = 38;
|
||||
this.DebugLabel1.Text = "Debug";
|
||||
//
|
||||
// panel4
|
||||
//
|
||||
@@ -640,15 +641,25 @@
|
||||
this.btnSvgExport.UseVisualStyleBackColor = false;
|
||||
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
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 14F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(34)))), ((int)(((byte)(34)))), ((int)(((byte)(34)))));
|
||||
this.ClientSize = new System.Drawing.Size(1222, 618);
|
||||
this.Controls.Add(this.DebugLabel2);
|
||||
this.Controls.Add(this.btnSvgExport);
|
||||
this.Controls.Add(this.panel4);
|
||||
this.Controls.Add(this.DebugLabel);
|
||||
this.Controls.Add(this.DebugLabel1);
|
||||
this.Controls.Add(this.panel3);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Controls.Add(this.panelHoverColor);
|
||||
@@ -665,6 +676,8 @@
|
||||
this.Name = "PaintForm";
|
||||
this.Text = "Paint 2";
|
||||
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);
|
||||
((System.ComponentModel.ISupportInitialize)(this.canvas)).EndInit();
|
||||
this.panelFile.ResumeLayout(false);
|
||||
@@ -728,11 +741,12 @@
|
||||
private System.Windows.Forms.Button btnEyeDrop;
|
||||
private System.Windows.Forms.Button btnLayerRemove;
|
||||
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.Label label3;
|
||||
private System.Windows.Forms.Panel panel4;
|
||||
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);
|
||||
SelectedLayers = new List<string>();
|
||||
SelectedLayers.Add(Project.GetAllLayers()[0].Id);
|
||||
this.KeyPreview = true;
|
||||
RefreshUi();
|
||||
}
|
||||
private Point MousePositionToCanvasPosition()
|
||||
@@ -50,6 +51,7 @@ namespace Paint_2
|
||||
}
|
||||
private void canvas_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
canvas.Focus();
|
||||
Color hoveringColor = GetHoverColor();
|
||||
Point mousePosition = MousePositionToCanvasPosition();
|
||||
int toolWidth = (int)nupPencilWidth.Value;
|
||||
@@ -93,7 +95,7 @@ namespace Paint_2
|
||||
private void RefreshUi()
|
||||
{
|
||||
lsbTools.DataSource = Project.AvaibleTools;
|
||||
DebugLabel.Text = "";
|
||||
DebugLabel1.Text = "";
|
||||
|
||||
PaintTool currentTool = Project.GetCurrentTool(SelectedLayers);
|
||||
if (currentTool != null && currentTool.NeedsFullRefresh)
|
||||
@@ -131,6 +133,26 @@ namespace Paint_2
|
||||
|
||||
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)
|
||||
{
|
||||
btnRandomColor.BackColor = FLAT_GREEN;
|
||||
@@ -225,7 +247,6 @@ namespace Paint_2
|
||||
currentTool.Add(new Point(0 + size.Width / 10, 0 + size.Height / 10));
|
||||
currentTool.Add(new Point(size.Width - size.Width / 10, size.Height - size.Height / 10));
|
||||
currentTool.Stop();
|
||||
|
||||
currentTool.Paint(map);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace Paint_2
|
||||
bool NeedsFullRefresh { get; set; }
|
||||
int Width { get; set; }
|
||||
string Name { get; set; }
|
||||
bool IsCtrlPressed { get; set; }
|
||||
bool IsShiftPressed { get; set; }
|
||||
|
||||
void Start(Color color, int width);
|
||||
void Stop();
|
||||
|
||||
@@ -92,6 +92,33 @@ namespace Paint_2
|
||||
result.Reverse();
|
||||
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)
|
||||
{
|
||||
int xDiff = end.X - start.X;
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace Paint_2
|
||||
private List<List<Point>> _drawingsRedo;
|
||||
private PaintToolUtils Utils;
|
||||
private bool _needsFullRefresh;
|
||||
private bool _isShiftPressed;
|
||||
private bool _isCtrlPressed;
|
||||
private List<Color> _colors;
|
||||
private List<Color> _colorsRedo;
|
||||
private List<int> _widths;
|
||||
@@ -35,6 +37,8 @@ namespace Paint_2
|
||||
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
||||
public List<int> Widths { get => _widths; set => _widths = value; }
|
||||
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
||||
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||
public Color Color { get => _color; set => _color = value; }
|
||||
public string Name { get => _name; set => _name = value; }
|
||||
public int Width { get => _width; set => _width = value; }
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace Paint_2
|
||||
private bool _drawing;
|
||||
private string _name;
|
||||
|
||||
|
||||
public List<PaintTool> AvaibleTools { get => _avaibleTools; set => _avaibleTools = value; }
|
||||
//public Sketch CurrentLayer { get => _currentSketch; set => _currentSketch = value; }
|
||||
public List<Sketch> Layers { get => _layers; set => _layers = value; }
|
||||
@@ -272,7 +273,10 @@ namespace Paint_2
|
||||
}
|
||||
public Bitmap PaintLayers()
|
||||
{
|
||||
Bitmap result = new Bitmap(CanvasSize.Width, CanvasSize.Height);
|
||||
Bitmap result = null;
|
||||
if (CanvasSize.Width != 0 && CanvasSize.Height != 0)
|
||||
{
|
||||
result = new Bitmap(CanvasSize.Width, CanvasSize.Height);
|
||||
Graphics gr = Graphics.FromImage(result);
|
||||
foreach (string layerId in LayersToPrint)
|
||||
{
|
||||
@@ -282,6 +286,7 @@ namespace Paint_2
|
||||
gr.DrawImage(layer.Paint(), Point.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public void Clear()
|
||||
@@ -416,7 +421,34 @@ namespace Paint_2
|
||||
}
|
||||
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()
|
||||
{
|
||||
string fileContent = "";
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace Paint_2
|
||||
private List<List<Point>> _drawings;
|
||||
private List<List<Point>> _drawingsRedo;
|
||||
private bool _needsFullRefresh;
|
||||
private bool _isShiftPressed;
|
||||
private bool _isCtrlPressed;
|
||||
private PaintToolUtils Utils;
|
||||
private List<Color> _colors;
|
||||
private List<Color> _colorsRedo;
|
||||
@@ -33,6 +35,8 @@ namespace Paint_2
|
||||
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
|
||||
public List<int> Widths { get => _widths; set => _widths = value; }
|
||||
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
|
||||
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||
public Color Color { get => _color; set => _color = value; }
|
||||
public string Name { get => _name; set => _name = value; }
|
||||
public int Width { get => _width; set => _width = value; }
|
||||
@@ -72,33 +76,22 @@ namespace Paint_2
|
||||
{
|
||||
if (drawing.Count == 2)
|
||||
{
|
||||
Point p1 = drawing[0];
|
||||
Point p2 = drawing[1];
|
||||
Point start = drawing[0];
|
||||
Point end = drawing[1];
|
||||
|
||||
Point start = new Point(0, 0);
|
||||
Point end = new Point(0, 0);
|
||||
|
||||
if (p2.X > p1.X)
|
||||
List<Point> points;
|
||||
if (drawingCounter == Drawings.Count - 1)
|
||||
{
|
||||
start.X = p1.X;
|
||||
end.X = p2.X;
|
||||
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
start.X = p2.X;
|
||||
end.X = p1.X;
|
||||
}
|
||||
if (p2.Y > p1.Y)
|
||||
{
|
||||
start.Y = p1.Y;
|
||||
end.Y = p2.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
start.Y = p2.Y;
|
||||
end.Y = p1.Y;
|
||||
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
drawingCounter++;
|
||||
@@ -116,32 +109,19 @@ namespace Paint_2
|
||||
{
|
||||
if (drawing.Count == 2)
|
||||
{
|
||||
Point p1 = drawing[0];
|
||||
Point p2 = drawing[1];
|
||||
Point start = drawing[0];
|
||||
Point end = drawing[1];
|
||||
|
||||
Point start = new Point(0, 0);
|
||||
Point end = new Point(0, 0);
|
||||
|
||||
if (p2.X > p1.X)
|
||||
List<Point> points;
|
||||
if (drawingCounter == Drawings.Count - 1)
|
||||
{
|
||||
start.X = p1.X;
|
||||
end.X = p2.X;
|
||||
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
start.X = p2.X;
|
||||
end.X = p1.X;
|
||||
}
|
||||
if (p2.Y > p1.Y)
|
||||
{
|
||||
start.Y = p1.Y;
|
||||
end.Y = p2.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
start.Y = p2.Y;
|
||||
end.Y = p1.Y;
|
||||
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -159,10 +139,8 @@ namespace Paint_2
|
||||
}
|
||||
public void Stop()
|
||||
{
|
||||
for (int i = 0; i < Drawings.Count; i++)
|
||||
{
|
||||
List<Point> Drawing = Drawings[i];
|
||||
}
|
||||
List<Point> myDrawing = Drawings.Last();
|
||||
Drawings[Drawings.Count - 1] = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, myDrawing[0], myDrawing[1]);
|
||||
}
|
||||
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>> _drawingsRedo;
|
||||
private bool _needsFullRefresh;
|
||||
private bool _isShiftPressed;
|
||||
private bool _isCtrlPressed;
|
||||
private PaintToolUtils Utils;
|
||||
private List<Color> _colors;
|
||||
private List<Color> _colorsRedo;
|
||||
@@ -36,6 +38,8 @@ namespace Paint_2
|
||||
public Color Color { get => _color; set => _color = value; }
|
||||
public string Name { get => _name; set => _name = value; }
|
||||
public int Width { get => _width; set => _width = value; }
|
||||
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
|
||||
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
|
||||
|
||||
public RectanglePencil(string name)
|
||||
{
|
||||
@@ -51,6 +55,7 @@ namespace Paint_2
|
||||
}
|
||||
public void Add(Point point)
|
||||
{
|
||||
|
||||
List<Point> myDrawing = Drawings[Drawings.Count - 1];
|
||||
if (myDrawing.Count == 0 || myDrawing.Count == 1)
|
||||
{
|
||||
@@ -66,40 +71,21 @@ namespace Paint_2
|
||||
{
|
||||
Graphics gr = Graphics.FromImage(canvas);
|
||||
int drawingCounter = 0;
|
||||
Size pointSize;
|
||||
|
||||
foreach (List<Point> drawing in Drawings)
|
||||
{
|
||||
if (drawing.Count == 2)
|
||||
{
|
||||
Point p1 = drawing[0];
|
||||
Point p2 = drawing[1];
|
||||
|
||||
Point start = new Point(0,0);
|
||||
Point end = new Point(0,0);
|
||||
|
||||
if (p2.X > p1.X)
|
||||
List<Point> points;
|
||||
if (drawingCounter == Drawings.Count - 1)
|
||||
{
|
||||
start.X = p1.X;
|
||||
end.X = p2.X;
|
||||
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
start.X = p2.X;
|
||||
end.X = p1.X;
|
||||
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||
}
|
||||
if (p2.Y > p1.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)));
|
||||
gr.FillRectangle(new SolidBrush(Colors[drawingCounter]), new Rectangle(points[0], new Size(points[1].X - points[0].X, points[1].Y - points[0].Y)));
|
||||
}
|
||||
drawingCounter++;
|
||||
}
|
||||
@@ -110,41 +96,25 @@ namespace Paint_2
|
||||
string newLine = Environment.NewLine;
|
||||
|
||||
int drawingCounter = 0;
|
||||
Size pointSize;
|
||||
|
||||
|
||||
foreach (List<Point> drawing in Drawings)
|
||||
{
|
||||
if (drawing.Count == 2)
|
||||
{
|
||||
Point p1 = drawing[0];
|
||||
Point p2 = drawing[1];
|
||||
|
||||
Point start = new Point(0, 0);
|
||||
Point end = new Point(0, 0);
|
||||
|
||||
if (p2.X > p1.X)
|
||||
List<Point> points;
|
||||
if (drawingCounter == Drawings.Count -1)
|
||||
{
|
||||
start.X = p1.X;
|
||||
end.X = p2.X;
|
||||
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
start.X = p2.X;
|
||||
end.X = p1.X;
|
||||
}
|
||||
if (p2.Y > p1.Y)
|
||||
{
|
||||
start.Y = p1.Y;
|
||||
end.Y = p2.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
start.Y = p2.Y;
|
||||
end.Y = p1.Y;
|
||||
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
|
||||
}
|
||||
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 += newLine;
|
||||
//gr.DrawRectangle(new Pen(Colors[drawingCounter], Widths[drawingCounter]), new Rectangle(start, new Size(end.X - start.X, end.Y - start.Y)));
|
||||
}
|
||||
drawingCounter++;
|
||||
}
|
||||
@@ -160,10 +130,8 @@ namespace Paint_2
|
||||
}
|
||||
public void Stop()
|
||||
{
|
||||
for (int i = 0; i < Drawings.Count; i++)
|
||||
{
|
||||
List<Point> Drawing = Drawings[i];
|
||||
}
|
||||
List<Point> myDrawing = Drawings.Last();
|
||||
Drawings[Drawings.Count - 1] = Utils.ConvertRectangleIntoPositive(IsCtrlPressed,myDrawing[0], myDrawing[1]);
|
||||
}
|
||||
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
|
||||
{
|
||||
|
||||
@@ -143,6 +143,28 @@ namespace Paint_2
|
||||
//Todo
|
||||
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()
|
||||
{
|
||||
return Name;
|
||||
|
||||
Reference in New Issue
Block a user