Compare commits

...

13 Commits

15 changed files with 1478 additions and 203 deletions
+120 -10
View File
@@ -2,7 +2,7 @@
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A unique tool that draws Bezier curves /// Brief: A unique tool that draws Bezier curves
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -17,6 +17,9 @@ 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 _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;
@@ -28,16 +31,20 @@ 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 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; }
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; }
public BezierPencil(string name) public BezierPencil(string name)
{ {
NeedsFullRefresh = true;
Drawings = new List<List<Point>>(); Drawings = new List<List<Point>>();
DrawingsRedo = new List<List<Point>>(); DrawingsRedo = new List<List<Point>>();
Colors = new List<Color>(); Colors = new List<Color>();
@@ -79,16 +86,53 @@ namespace Paint_2
} }
if (points.Count > 0) if (points.Count > 0)
{ {
for (int i = 0; i < points.Count; i++)
for (int i = 1; i <= points.Count; i++)
{ {
pointSize = new Size(Widths[0], Widths[0]); pointSize = new Size(Widths[0] / 2, Widths[0] / 2);
gr.FillEllipse(new SolidBrush(Colors[i - 1]), new Rectangle(new Point(points[i - 1].X - pointSize.Width / 2, points[i - 1].Y - pointSize.Height / 2), pointSize)); //ContinuousBezierGenerator(gr, points, Colors[Colors.Count-1], Widths[Widths.Count -1]);
ContinuousBezierGenerator(gr, points, i); AdjustedBezierGenerator(gr, points, Colors[Colors.Count - 1], Widths[Widths.Count - 1]);
} }
} }
} }
private void ContinuousBezierGenerator(Graphics gr, List<Point> points, int i) 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)
{ {
@@ -100,7 +144,7 @@ namespace Paint_2
while (WorkingList.Count != 1) while (WorkingList.Count != 1)
{ {
if (WorkingList.Count > 2) if (WorkingList.Count > 1)
{ {
for (int pos = 0; pos < WorkingList.Count - 1; pos++) for (int pos = 0; pos < WorkingList.Count - 1; pos++)
{ {
@@ -114,10 +158,76 @@ namespace Paint_2
WorkingList = new List<Point>(DumpList); WorkingList = new List<Point>(DumpList);
DumpList = new List<Point>(); DumpList = new List<Point>();
} }
gr.FillEllipse(new SolidBrush(GetRandomColor()), new Rectangle(WorkingList[0].X - Widths[0] / 2, WorkingList[0].Y - Widths[0] / 2, Widths[0], Widths[0])); gr.FillEllipse(new SolidBrush(color), new Rectangle(WorkingList[0].X - Widths[0] / 2, WorkingList[0].Y - Widths[0] / 2, width, width));
} }
} }
} }
public string PaintSVG()
{
string result = "";
string newLine = Environment.NewLine;
Size pointSize;
List<Point> points = new List<Point>();
foreach (List<Point> drawing in Drawings)
{
if (drawing.Count > 0)
{
points.Add(drawing[0]);
}
}
if (points.Count > 0)
{
for (int i = 0; i < points.Count; i++)
{
pointSize = new Size(Widths[0] / 2, Widths[0] / 2);
//Not really usefull in the SVG world because only the last layer will be displayed
//result += "<ellipse cx=\"" + points[i].X + "\" cy=\"" + points[i].Y + "\" rx=\"" + pointSize.Width / 2 + "\" ry=\"" + pointSize.Height / 2 + "\" style=\"fill:rgb(" + Colors[i].R + ", " + Colors[i].G + ", " + Colors[i].B + ");\"/>";
//result += newLine;
result += ContinuousBezierGeneratorSVG(points, Colors[Colors.Count - 1], Widths[Widths.Count - 1]);
}
}
return result;
}
private string ContinuousBezierGeneratorSVG(List<Point> points, Color color, int width)
{
string result = "";
string newLine = Environment.NewLine;
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();
}
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;
}
}
return result;
}
private void BezierGenerator(Graphics gr, Point p1, Point p2, Point p3, Point p4, int i) private void BezierGenerator(Graphics gr, Point p1, Point p2, Point p3, Point p4, int i)
{ {
gr.DrawLine(new Pen(Colors[i - 4], Widths[i - 4]), p1, p2); gr.DrawLine(new Pen(Colors[i - 4], Widths[i - 4]), p1, p2);
@@ -150,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()
+35 -29
View File
@@ -58,7 +58,7 @@
// //
this.pbxColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); this.pbxColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.pbxColor.Location = new System.Drawing.Point(13, 13); this.pbxColor.Location = new System.Drawing.Point(13, 13);
this.pbxColor.Margin = new System.Windows.Forms.Padding(4); this.pbxColor.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
this.pbxColor.Name = "pbxColor"; this.pbxColor.Name = "pbxColor";
this.pbxColor.Size = new System.Drawing.Size(255, 255); this.pbxColor.Size = new System.Drawing.Size(255, 255);
this.pbxColor.TabIndex = 0; this.pbxColor.TabIndex = 0;
@@ -70,9 +70,9 @@
// //
this.pbxSelectedColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); this.pbxSelectedColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.pbxSelectedColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.pbxSelectedColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pbxSelectedColor.Location = new System.Drawing.Point(326, 205); this.pbxSelectedColor.Location = new System.Drawing.Point(311, 189);
this.pbxSelectedColor.Name = "pbxSelectedColor"; this.pbxSelectedColor.Name = "pbxSelectedColor";
this.pbxSelectedColor.Size = new System.Drawing.Size(100, 100); this.pbxSelectedColor.Size = new System.Drawing.Size(116, 116);
this.pbxSelectedColor.TabIndex = 4; this.pbxSelectedColor.TabIndex = 4;
this.pbxSelectedColor.TabStop = false; this.pbxSelectedColor.TabStop = false;
this.pbxSelectedColor.Click += new System.EventHandler(this.pbxSelectedColor_Click); this.pbxSelectedColor.Click += new System.EventHandler(this.pbxSelectedColor_Click);
@@ -81,16 +81,16 @@
// //
this.nupRed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.nupRed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.nupRed.BorderStyle = System.Windows.Forms.BorderStyle.None; this.nupRed.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupRed.Font = new System.Drawing.Font("Cascadia Code", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.nupRed.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nupRed.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.nupRed.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.nupRed.Location = new System.Drawing.Point(348, 12); this.nupRed.Location = new System.Drawing.Point(336, 58);
this.nupRed.Maximum = new decimal(new int[] { this.nupRed.Maximum = new decimal(new int[] {
255, 255,
0, 0,
0, 0,
0}); 0});
this.nupRed.Name = "nupRed"; this.nupRed.Name = "nupRed";
this.nupRed.Size = new System.Drawing.Size(78, 27); this.nupRed.Size = new System.Drawing.Size(91, 25);
this.nupRed.TabIndex = 11; this.nupRed.TabIndex = 11;
this.nupRed.ValueChanged += new System.EventHandler(this.nupValueChanged); this.nupRed.ValueChanged += new System.EventHandler(this.nupValueChanged);
// //
@@ -98,16 +98,16 @@
// //
this.nupGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.nupGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.nupGreen.BorderStyle = System.Windows.Forms.BorderStyle.None; this.nupGreen.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupGreen.Font = new System.Drawing.Font("Cascadia Code", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.nupGreen.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nupGreen.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.nupGreen.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.nupGreen.Location = new System.Drawing.Point(348, 46); this.nupGreen.Location = new System.Drawing.Point(336, 89);
this.nupGreen.Maximum = new decimal(new int[] { this.nupGreen.Maximum = new decimal(new int[] {
255, 255,
0, 0,
0, 0,
0}); 0});
this.nupGreen.Name = "nupGreen"; this.nupGreen.Name = "nupGreen";
this.nupGreen.Size = new System.Drawing.Size(78, 27); this.nupGreen.Size = new System.Drawing.Size(91, 25);
this.nupGreen.TabIndex = 16; this.nupGreen.TabIndex = 16;
this.nupGreen.ValueChanged += new System.EventHandler(this.nupValueChanged); this.nupGreen.ValueChanged += new System.EventHandler(this.nupValueChanged);
// //
@@ -115,16 +115,16 @@
// //
this.nupBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.nupBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.nupBlue.BorderStyle = System.Windows.Forms.BorderStyle.None; this.nupBlue.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupBlue.Font = new System.Drawing.Font("Cascadia Code", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.nupBlue.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nupBlue.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.nupBlue.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.nupBlue.Location = new System.Drawing.Point(348, 79); this.nupBlue.Location = new System.Drawing.Point(336, 120);
this.nupBlue.Maximum = new decimal(new int[] { this.nupBlue.Maximum = new decimal(new int[] {
255, 255,
0, 0,
0, 0,
0}); 0});
this.nupBlue.Name = "nupBlue"; this.nupBlue.Name = "nupBlue";
this.nupBlue.Size = new System.Drawing.Size(78, 27); this.nupBlue.Size = new System.Drawing.Size(91, 25);
this.nupBlue.TabIndex = 17; this.nupBlue.TabIndex = 17;
this.nupBlue.ValueChanged += new System.EventHandler(this.nupValueChanged); this.nupBlue.ValueChanged += new System.EventHandler(this.nupValueChanged);
// //
@@ -132,16 +132,16 @@
// //
this.nupGamma.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.nupGamma.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.nupGamma.BorderStyle = System.Windows.Forms.BorderStyle.None; this.nupGamma.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupGamma.Font = new System.Drawing.Font("Cascadia Code", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.nupGamma.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nupGamma.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.nupGamma.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.nupGamma.Location = new System.Drawing.Point(348, 112); this.nupGamma.Location = new System.Drawing.Point(336, 151);
this.nupGamma.Maximum = new decimal(new int[] { this.nupGamma.Maximum = new decimal(new int[] {
255, 255,
0, 0,
0, 0,
0}); 0});
this.nupGamma.Name = "nupGamma"; this.nupGamma.Name = "nupGamma";
this.nupGamma.Size = new System.Drawing.Size(78, 27); this.nupGamma.Size = new System.Drawing.Size(91, 25);
this.nupGamma.TabIndex = 18; this.nupGamma.TabIndex = 18;
this.nupGamma.ValueChanged += new System.EventHandler(this.nupValueChanged); this.nupGamma.ValueChanged += new System.EventHandler(this.nupValueChanged);
// //
@@ -149,18 +149,20 @@
// //
this.tbxColorHex.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.tbxColorHex.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.tbxColorHex.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.tbxColorHex.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbxColorHex.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tbxColorHex.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.tbxColorHex.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.tbxColorHex.Location = new System.Drawing.Point(326, 155); this.tbxColorHex.Location = new System.Drawing.Point(311, 14);
this.tbxColorHex.Name = "tbxColorHex"; this.tbxColorHex.Name = "tbxColorHex";
this.tbxColorHex.Size = new System.Drawing.Size(100, 27); this.tbxColorHex.Size = new System.Drawing.Size(116, 29);
this.tbxColorHex.TabIndex = 20; this.tbxColorHex.TabIndex = 20;
this.tbxColorHex.Text = "#FFFFFF";
this.tbxColorHex.TextChanged += new System.EventHandler(this.tbxColorHex_TextChanged); this.tbxColorHex.TextChanged += new System.EventHandler(this.tbxColorHex_TextChanged);
this.tbxColorHex.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxColorHex_KeyDown); this.tbxColorHex.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxColorHex_KeyDown);
// //
// pbxSliderRed // pbxSliderRed
// //
this.pbxSliderRed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); this.pbxSliderRed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.pbxSliderRed.Location = new System.Drawing.Point(12, 275); this.pbxSliderRed.Location = new System.Drawing.Point(11, 275);
this.pbxSliderRed.Name = "pbxSliderRed"; this.pbxSliderRed.Name = "pbxSliderRed";
this.pbxSliderRed.Size = new System.Drawing.Size(255, 30); this.pbxSliderRed.Size = new System.Drawing.Size(255, 30);
this.pbxSliderRed.TabIndex = 21; this.pbxSliderRed.TabIndex = 21;
@@ -182,40 +184,44 @@
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
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(322, 15); this.label1.Location = new System.Drawing.Point(308, 57);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(20, 22); this.label1.Size = new System.Drawing.Size(24, 22);
this.label1.TabIndex = 23; this.label1.TabIndex = 23;
this.label1.Text = "R"; this.label1.Text = "R";
// //
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.label2.Location = new System.Drawing.Point(322, 49); this.label2.Location = new System.Drawing.Point(307, 88);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(20, 22); this.label2.Size = new System.Drawing.Size(25, 22);
this.label2.TabIndex = 24; this.label2.TabIndex = 24;
this.label2.Text = "G"; this.label2.Text = "G";
// //
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
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(322, 82); this.label3.Location = new System.Drawing.Point(307, 119);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(20, 22); this.label3.Size = new System.Drawing.Size(23, 22);
this.label3.TabIndex = 25; this.label3.TabIndex = 25;
this.label3.Text = "B"; this.label3.Text = "B";
// //
// label4 // label4
// //
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.label4.Location = new System.Drawing.Point(322, 115); this.label4.Location = new System.Drawing.Point(308, 150);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(20, 22); this.label4.Size = new System.Drawing.Size(23, 22);
this.label4.TabIndex = 26; this.label4.TabIndex = 26;
this.label4.Text = "A"; this.label4.Text = "A";
// //
@@ -231,10 +237,10 @@
// //
// ColorPicker // ColorPicker
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 22F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F);
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(440, 316); this.ClientSize = new System.Drawing.Size(433, 314);
this.Controls.Add(this.label4); this.Controls.Add(this.label4);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
@@ -252,7 +258,7 @@
this.Font = new System.Drawing.Font("Cascadia Code", 10.2F); this.Font = new System.Drawing.Font("Cascadia Code", 10.2F);
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214))))); this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Margin = new System.Windows.Forms.Padding(4); this.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
this.MaximizeBox = false; this.MaximizeBox = false;
this.Name = "ColorPicker"; this.Name = "ColorPicker";
this.Text = "ColorPicker"; this.Text = "ColorPicker";
+38 -2
View File
@@ -2,7 +2,7 @@
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A variant of the default tool /// Brief: A variant of the default tool
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -15,10 +15,13 @@ namespace Paint_2
{ {
public class DotPencil : PaintTool public class DotPencil : PaintTool
{ {
const int POST_PROCESSING_PRECISION = 3; const int POST_PROCESSING_PRECISION = 1;
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 _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;
@@ -30,6 +33,9 @@ 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 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; }
@@ -47,6 +53,7 @@ namespace Paint_2
Widths = new List<int>(); Widths = new List<int>();
WidthsRedo = new List<int>(); WidthsRedo = new List<int>();
Name = name; Name = name;
NeedsFullRefresh = false;
Utils = new PaintToolUtils(this); Utils = new PaintToolUtils(this);
} }
@@ -135,5 +142,34 @@ namespace Paint_2
result.Color = Color; result.Color = Color;
return (Object)(result); return (Object)(result);
} }
public string PaintSVG()
{
string result = "";
string newLine = Environment.NewLine;
for (int drawCount = 0; drawCount < Drawings.Count; drawCount++)
{
Point p1;
Point p2;
List<Point> drawing = Drawings[drawCount];
Color color = Colors[drawCount];
int width = Widths[drawCount];
for (int pointIndex = 0; pointIndex < drawing.Count; pointIndex++)
{
if (pointIndex >= 1)
{
p1 = drawing[pointIndex - 1];
p2 = drawing[pointIndex];
result += "<ellipse cx=\"" + p2.X + "\" cy=\"" + p2.Y + "\" rx=\"" + width / 2 + "\" ry=\"" + width / 2 + "\" style=\"fill:rgb(" + color.R + ", " + color.G + ", " + color.B + ");\"/>";
result += newLine;
}
}
}
return result;
}
} }
} }
+179
View File
@@ -0,0 +1,179 @@
/// file: EllipseBorderPencil.cs
/// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A tool that paints the outline of an ellipse
/// Version: 0.1.0
/// Date: 17/06/2022
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace Paint_2
{
internal class EllipseBorderPencil : PaintTool
{
private List<List<Point>> _drawings;
private List<List<Point>> _drawingsRedo;
private bool _needsFullRefresh;
private bool _isShiftPressed;
private bool _isCtrlPressed;
private PaintToolUtils Utils;
private List<Color> _colors;
private List<Color> _colorsRedo;
private List<int> _widths;
private List<int> _widthsRedo;
private Color _color;
private string _name;
private int _width;
public List<List<Point>> Drawings { get => _drawings; set => _drawings = value; }
public List<List<Point>> DrawingsRedo { get => _drawingsRedo; set => _drawingsRedo = value; }
public bool NeedsFullRefresh { get => _needsFullRefresh; set => _needsFullRefresh = value; }
public List<Color> Colors { get => _colors; set => _colors = value; }
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
public List<int> Widths { get => _widths; set => _widths = value; }
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
public 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; }
public EllipseBorderPencil(string name)
{
NeedsFullRefresh = true;
Drawings = new List<List<Point>>();
DrawingsRedo = new List<List<Point>>();
Colors = new List<Color>();
ColorsRedo = new List<Color>();
Widths = new List<int>();
WidthsRedo = new List<int>();
Name = name;
Utils = new PaintToolUtils(this);
}
public void Add(Point point)
{
List<Point> myDrawing = Drawings[Drawings.Count - 1];
if (myDrawing.Count == 0 || myDrawing.Count == 1)
{
myDrawing.Add(point);
}
else
{
myDrawing[1] = point;
}
Drawings[Drawings.Count - 1] = myDrawing;
}
public string PaintSVG()
{
string result = "";
string newLine = Environment.NewLine;
int drawingCounter = 0;
Size pointSize;
foreach (List<Point> drawing in Drawings)
{
if (drawing.Count == 2)
{
Point start = drawing[0];
Point end = drawing[1];
List<Point> points;
if (drawingCounter == Drawings.Count - 1)
{
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
}
else
{
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;
}
drawingCounter++;
}
return result;
}
public void Paint(Bitmap canvas)
{
Graphics gr = Graphics.FromImage(canvas);
int drawingCounter = 0;
foreach (List<Point> drawing in Drawings)
{
if (drawing.Count == 2)
{
Point start = drawing[0];
Point end = drawing[1];
List<Point> points;
if (drawingCounter == Drawings.Count - 1)
{
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
}
else
{
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++;
}
}
public void Start(Color color, int width)
{
Utils.StandartStart(color, width);
}
public void Clear()
{
Utils.StandartClear();
}
public void Stop()
{
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)
{
return bmp;
}
public List<Color> GetLastColors(int colorNumber)
{
return Utils.SandartGetLastColors(colorNumber);
}
public override string ToString()
{
return Name;
}
public void Undo()
{
Utils.StandartUndo();
}
public void Redo()
{
Utils.StandartRedo();
}
public object Clone()
{
EllipseBorderPencil result = new EllipseBorderPencil(Name);
result.Width = Width;
result.Color = Color;
return (Object)(result);
}
}
}
+180
View File
@@ -0,0 +1,180 @@
/// file: EllipsePencil.cs
/// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A tool that paints an ellipse
/// Version: 0.1.0
/// Date: 17/06/2022
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace Paint_2
{
internal class EllipsePencil : PaintTool
{
private List<List<Point>> _drawings;
private List<List<Point>> _drawingsRedo;
private bool _needsFullRefresh;
private bool _isShiftPressed;
private bool _isCtrlPressed;
private PaintToolUtils Utils;
private List<Color> _colors;
private List<Color> _colorsRedo;
private List<int> _widths;
private List<int> _widthsRedo;
private Color _color;
private string _name;
private int _width;
public List<List<Point>> Drawings { get => _drawings; set => _drawings = value; }
public List<List<Point>> DrawingsRedo { get => _drawingsRedo; set => _drawingsRedo = value; }
public bool NeedsFullRefresh { get => _needsFullRefresh; set => _needsFullRefresh = value; }
public List<Color> Colors { get => _colors; set => _colors = value; }
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
public List<int> Widths { get => _widths; set => _widths = value; }
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
public 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; }
public EllipsePencil(string name)
{
NeedsFullRefresh = true;
Drawings = new List<List<Point>>();
DrawingsRedo = new List<List<Point>>();
Colors = new List<Color>();
ColorsRedo = new List<Color>();
Widths = new List<int>();
WidthsRedo = new List<int>();
Name = name;
Utils = new PaintToolUtils(this);
}
public void Add(Point point)
{
List<Point> myDrawing = Drawings[Drawings.Count - 1];
if (myDrawing.Count == 0 || myDrawing.Count == 1)
{
myDrawing.Add(point);
}
else
{
myDrawing[1] = point;
}
Drawings[Drawings.Count - 1] = myDrawing;
}
public void Paint(Bitmap canvas)
{
Graphics gr = Graphics.FromImage(canvas);
int drawingCounter = 0;
Size pointSize;
foreach (List<Point> drawing in Drawings)
{
if (drawing.Count == 2)
{
Point start = drawing[0];
Point end = drawing[1];
List<Point> points;
if (drawingCounter == Drawings.Count - 1)
{
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
}
else
{
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++;
}
}
public string PaintSVG()
{
string result = "";
string newLine = Environment.NewLine;
int drawingCounter = 0;
Size pointSize;
foreach (List<Point> drawing in Drawings)
{
if (drawing.Count == 2)
{
Point start = drawing[0];
Point end = drawing[1];
List<Point> points;
if (drawingCounter == Drawings.Count - 1)
{
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
}
else
{
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;
}
drawingCounter++;
}
return result;
}
public void Start(Color color, int width)
{
Utils.StandartStart(color, width);
}
public void Clear()
{
Utils.StandartClear();
}
public void Stop()
{
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)
{
return bmp;
}
public List<Color> GetLastColors(int colorNumber)
{
return Utils.SandartGetLastColors(colorNumber);
}
public override string ToString()
{
return Name;
}
public void Undo()
{
Utils.StandartUndo();
}
public void Redo()
{
Utils.StandartRedo();
}
public object Clone()
{
EllipsePencil result = new EllipsePencil(Name);
result.Width = Width;
result.Color = Color;
return (Object)(result);
}
}
}
+116 -92
View File
@@ -54,23 +54,25 @@
this.btnColorHistory1 = new System.Windows.Forms.Button(); this.btnColorHistory1 = new System.Windows.Forms.Button();
this.btnClear = new System.Windows.Forms.Button(); this.btnClear = new System.Windows.Forms.Button();
this.panelTools = new System.Windows.Forms.Panel(); this.panelTools = new System.Windows.Forms.Panel();
this.btnEyeDrop = new System.Windows.Forms.Button(); this.lsbTools = new System.Windows.Forms.ListBox();
this.pbxSample = new System.Windows.Forms.PictureBox(); this.pbxSample = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.btnEyeDrop = new System.Windows.Forms.Button();
this.btnRandomColor = new System.Windows.Forms.Button(); this.btnRandomColor = new System.Windows.Forms.Button();
this.btnColorPicker = new System.Windows.Forms.Button(); this.btnColorPicker = new System.Windows.Forms.Button();
this.btnRedo = new System.Windows.Forms.Button(); this.btnRedo = new System.Windows.Forms.Button();
this.btnUndo = new System.Windows.Forms.Button(); this.btnUndo = new System.Windows.Forms.Button();
this.lsbTools = new System.Windows.Forms.ListBox();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel(); this.panel3 = new System.Windows.Forms.Panel();
this.label3 = new System.Windows.Forms.Label();
this.pnlLayers = new System.Windows.Forms.Panel(); this.pnlLayers = new System.Windows.Forms.Panel();
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.label3 = new System.Windows.Forms.Label(); 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();
@@ -90,8 +92,8 @@
this.tbxProjectName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.tbxProjectName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbxProjectName.Font = new System.Drawing.Font("Verdana", 15F); this.tbxProjectName.Font = new System.Drawing.Font("Verdana", 15F);
this.tbxProjectName.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.tbxProjectName.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.tbxProjectName.Location = new System.Drawing.Point(2, 3); this.tbxProjectName.Location = new System.Drawing.Point(2, 4);
this.tbxProjectName.Margin = new System.Windows.Forms.Padding(2, 2, 2, 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, 32); this.tbxProjectName.Size = new System.Drawing.Size(225, 32);
this.tbxProjectName.TabIndex = 0; this.tbxProjectName.TabIndex = 0;
@@ -102,8 +104,8 @@
this.btnSave.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.btnSave.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.btnSave.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnSave.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnSave.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnSave.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnSave.Location = new System.Drawing.Point(231, 2); this.btnSave.Location = new System.Drawing.Point(231, 3);
this.btnSave.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.btnSave.Margin = new System.Windows.Forms.Padding(2);
this.btnSave.Name = "btnSave"; this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(54, 33); this.btnSave.Size = new System.Drawing.Size(54, 33);
this.btnSave.TabIndex = 1; this.btnSave.TabIndex = 1;
@@ -116,7 +118,7 @@
this.canvas.BackColor = System.Drawing.Color.Transparent; this.canvas.BackColor = System.Drawing.Color.Transparent;
this.canvas.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.canvas.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.canvas.Location = new System.Drawing.Point(10, 49); this.canvas.Location = new System.Drawing.Point(10, 49);
this.canvas.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.canvas.Margin = new System.Windows.Forms.Padding(2);
this.canvas.Name = "canvas"; this.canvas.Name = "canvas";
this.canvas.Size = new System.Drawing.Size(1000, 500); this.canvas.Size = new System.Drawing.Size(1000, 500);
this.canvas.TabIndex = 2; this.canvas.TabIndex = 2;
@@ -129,8 +131,8 @@
this.btnSaveCopy.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.btnSaveCopy.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.btnSaveCopy.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnSaveCopy.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnSaveCopy.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnSaveCopy.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnSaveCopy.Location = new System.Drawing.Point(289, 2); this.btnSaveCopy.Location = new System.Drawing.Point(289, 3);
this.btnSaveCopy.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.btnSaveCopy.Margin = new System.Windows.Forms.Padding(2);
this.btnSaveCopy.Name = "btnSaveCopy"; this.btnSaveCopy.Name = "btnSaveCopy";
this.btnSaveCopy.Size = new System.Drawing.Size(92, 33); this.btnSaveCopy.Size = new System.Drawing.Size(92, 33);
this.btnSaveCopy.TabIndex = 2; this.btnSaveCopy.TabIndex = 2;
@@ -151,7 +153,6 @@
// panelFile // panelFile
// //
this.panelFile.BackColor = System.Drawing.Color.Transparent; this.panelFile.BackColor = System.Drawing.Color.Transparent;
this.panelFile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panelFile.Controls.Add(this.btnLoadFile); this.panelFile.Controls.Add(this.btnLoadFile);
this.panelFile.Controls.Add(this.tbxProjectName); this.panelFile.Controls.Add(this.tbxProjectName);
this.panelFile.Controls.Add(this.btnSave); this.panelFile.Controls.Add(this.btnSave);
@@ -167,8 +168,8 @@
this.btnLoadFile.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.btnLoadFile.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.btnLoadFile.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnLoadFile.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnLoadFile.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnLoadFile.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnLoadFile.Location = new System.Drawing.Point(385, 2); this.btnLoadFile.Location = new System.Drawing.Point(385, 3);
this.btnLoadFile.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.btnLoadFile.Margin = new System.Windows.Forms.Padding(2);
this.btnLoadFile.Name = "btnLoadFile"; this.btnLoadFile.Name = "btnLoadFile";
this.btnLoadFile.Size = new System.Drawing.Size(96, 33); this.btnLoadFile.Size = new System.Drawing.Size(96, 33);
this.btnLoadFile.TabIndex = 3; this.btnLoadFile.TabIndex = 3;
@@ -179,7 +180,6 @@
// //
this.panelDrawing.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.panelDrawing.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.panelDrawing.BackColor = System.Drawing.Color.Transparent; this.panelDrawing.BackColor = System.Drawing.Color.Transparent;
this.panelDrawing.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panelDrawing.Controls.Add(this.lblHeight); this.panelDrawing.Controls.Add(this.lblHeight);
this.panelDrawing.Controls.Add(this.lblWidth); this.panelDrawing.Controls.Add(this.lblWidth);
this.panelDrawing.Location = new System.Drawing.Point(737, 553); this.panelDrawing.Location = new System.Drawing.Point(737, 553);
@@ -192,7 +192,7 @@
// //
this.lblHeight.AutoSize = true; this.lblHeight.AutoSize = true;
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, 33); this.lblHeight.Location = new System.Drawing.Point(3, 38);
this.lblHeight.Name = "lblHeight"; this.lblHeight.Name = "lblHeight";
this.lblHeight.Size = new System.Drawing.Size(53, 14); this.lblHeight.Size = new System.Drawing.Size(53, 14);
this.lblHeight.TabIndex = 34; this.lblHeight.TabIndex = 34;
@@ -212,7 +212,6 @@
// //
this.panelSelectedColor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.panelSelectedColor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.panelSelectedColor.BackColor = System.Drawing.Color.Transparent; this.panelSelectedColor.BackColor = System.Drawing.Color.Transparent;
this.panelSelectedColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panelSelectedColor.Controls.Add(this.btnSelectedColor); this.panelSelectedColor.Controls.Add(this.btnSelectedColor);
this.panelSelectedColor.Controls.Add(this.lblSelectedColor); this.panelSelectedColor.Controls.Add(this.lblSelectedColor);
this.panelSelectedColor.Controls.Add(this.label14); this.panelSelectedColor.Controls.Add(this.label14);
@@ -249,7 +248,6 @@
// //
this.panelHoverColor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.panelHoverColor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.panelHoverColor.BackColor = System.Drawing.Color.Transparent; this.panelHoverColor.BackColor = System.Drawing.Color.Transparent;
this.panelHoverColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panelHoverColor.Controls.Add(this.btnHoveringColor); this.panelHoverColor.Controls.Add(this.btnHoveringColor);
this.panelHoverColor.Controls.Add(this.lblHoveringColor); this.panelHoverColor.Controls.Add(this.lblHoveringColor);
this.panelHoverColor.Controls.Add(this.label15); this.panelHoverColor.Controls.Add(this.label15);
@@ -303,7 +301,7 @@
this.nupPencilWidth.BorderStyle = System.Windows.Forms.BorderStyle.None; this.nupPencilWidth.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupPencilWidth.Font = new System.Drawing.Font("Cascadia Code", 15F); this.nupPencilWidth.Font = new System.Drawing.Font("Cascadia Code", 15F);
this.nupPencilWidth.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.nupPencilWidth.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.nupPencilWidth.Location = new System.Drawing.Point(126, 191); this.nupPencilWidth.Location = new System.Drawing.Point(134, 166);
this.nupPencilWidth.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.nupPencilWidth.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.nupPencilWidth.Maximum = new decimal(new int[] { this.nupPencilWidth.Maximum = new decimal(new int[] {
255, 255,
@@ -311,7 +309,7 @@
0, 0,
0}); 0});
this.nupPencilWidth.Name = "nupPencilWidth"; this.nupPencilWidth.Name = "nupPencilWidth";
this.nupPencilWidth.Size = new System.Drawing.Size(63, 27); 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,
@@ -326,7 +324,7 @@
this.btnColorHistory4.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnColorHistory4.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnColorHistory4.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnColorHistory4.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnColorHistory4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnColorHistory4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnColorHistory4.Location = new System.Drawing.Point(3, 2); this.btnColorHistory4.Location = new System.Drawing.Point(3, 3);
this.btnColorHistory4.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnColorHistory4.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnColorHistory4.Name = "btnColorHistory4"; this.btnColorHistory4.Name = "btnColorHistory4";
this.btnColorHistory4.Size = new System.Drawing.Size(36, 33); this.btnColorHistory4.Size = new System.Drawing.Size(36, 33);
@@ -340,7 +338,7 @@
this.btnColorHistory3.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnColorHistory3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnColorHistory3.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnColorHistory3.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnColorHistory3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnColorHistory3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnColorHistory3.Location = new System.Drawing.Point(45, 2); this.btnColorHistory3.Location = new System.Drawing.Point(45, 3);
this.btnColorHistory3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnColorHistory3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnColorHistory3.Name = "btnColorHistory3"; this.btnColorHistory3.Name = "btnColorHistory3";
this.btnColorHistory3.Size = new System.Drawing.Size(36, 33); this.btnColorHistory3.Size = new System.Drawing.Size(36, 33);
@@ -354,7 +352,7 @@
this.btnColorHistory2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnColorHistory2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnColorHistory2.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnColorHistory2.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnColorHistory2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnColorHistory2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnColorHistory2.Location = new System.Drawing.Point(87, 2); this.btnColorHistory2.Location = new System.Drawing.Point(87, 3);
this.btnColorHistory2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnColorHistory2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnColorHistory2.Name = "btnColorHistory2"; this.btnColorHistory2.Name = "btnColorHistory2";
this.btnColorHistory2.Size = new System.Drawing.Size(36, 33); this.btnColorHistory2.Size = new System.Drawing.Size(36, 33);
@@ -368,7 +366,7 @@
this.btnColorHistory1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnColorHistory1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnColorHistory1.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnColorHistory1.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnColorHistory1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnColorHistory1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnColorHistory1.Location = new System.Drawing.Point(129, 2); this.btnColorHistory1.Location = new System.Drawing.Point(129, 3);
this.btnColorHistory1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnColorHistory1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnColorHistory1.Name = "btnColorHistory1"; this.btnColorHistory1.Name = "btnColorHistory1";
this.btnColorHistory1.Size = new System.Drawing.Size(36, 33); this.btnColorHistory1.Size = new System.Drawing.Size(36, 33);
@@ -381,9 +379,9 @@
this.btnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnClear.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.btnClear.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.btnClear.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnClear.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnClear.Font = new System.Drawing.Font("Cascadia Code", 10.2F); this.btnClear.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnClear.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnClear.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnClear.Location = new System.Drawing.Point(4, 31); this.btnClear.Location = new System.Drawing.Point(6, 30);
this.btnClear.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnClear.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnClear.Name = "btnClear"; this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(169, 24); this.btnClear.Size = new System.Drawing.Size(169, 24);
@@ -396,7 +394,6 @@
// //
this.panelTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.panelTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.panelTools.BackColor = System.Drawing.Color.Transparent; this.panelTools.BackColor = System.Drawing.Color.Transparent;
this.panelTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panelTools.Controls.Add(this.nupPencilWidth); this.panelTools.Controls.Add(this.nupPencilWidth);
this.panelTools.Controls.Add(this.lsbTools); this.panelTools.Controls.Add(this.lsbTools);
this.panelTools.Controls.Add(this.pbxSample); this.panelTools.Controls.Add(this.pbxSample);
@@ -404,16 +401,50 @@
this.panelTools.Location = new System.Drawing.Point(1014, 6); this.panelTools.Location = new System.Drawing.Point(1014, 6);
this.panelTools.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.panelTools.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panelTools.Name = "panelTools"; this.panelTools.Name = "panelTools";
this.panelTools.Size = new System.Drawing.Size(196, 237); this.panelTools.Size = new System.Drawing.Size(196, 232);
this.panelTools.TabIndex = 31; this.panelTools.TabIndex = 31;
// //
// lsbTools
//
this.lsbTools.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
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.FormattingEnabled = true;
this.lsbTools.ItemHeight = 14;
this.lsbTools.Location = new System.Drawing.Point(6, 20);
this.lsbTools.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.lsbTools.Name = "lsbTools";
this.lsbTools.Size = new System.Drawing.Size(183, 128);
this.lsbTools.TabIndex = 32;
this.lsbTools.SelectedIndexChanged += new System.EventHandler(this.lsbTools_SelectedIndexChanged);
//
// pbxSample
//
this.pbxSample.Location = new System.Drawing.Point(6, 166);
this.pbxSample.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pbxSample.Name = "pbxSample";
this.pbxSample.Size = new System.Drawing.Size(122, 64);
this.pbxSample.TabIndex = 35;
this.pbxSample.TabStop = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
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.Name = "label1";
this.label1.Size = new System.Drawing.Size(84, 16);
this.label1.TabIndex = 36;
this.label1.Text = "Paint tools";
//
// btnEyeDrop // btnEyeDrop
// //
this.btnEyeDrop.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.btnEyeDrop.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.btnEyeDrop.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnEyeDrop.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnEyeDrop.Font = new System.Drawing.Font("Cascadia Code", 10.2F); this.btnEyeDrop.Font = new System.Drawing.Font("Cascadia Code", 10.2F);
this.btnEyeDrop.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnEyeDrop.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnEyeDrop.Location = new System.Drawing.Point(283, 2); this.btnEyeDrop.Location = new System.Drawing.Point(283, 3);
this.btnEyeDrop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnEyeDrop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnEyeDrop.Name = "btnEyeDrop"; this.btnEyeDrop.Name = "btnEyeDrop";
this.btnEyeDrop.Size = new System.Drawing.Size(104, 33); this.btnEyeDrop.Size = new System.Drawing.Size(104, 33);
@@ -422,22 +453,13 @@
this.btnEyeDrop.UseVisualStyleBackColor = false; this.btnEyeDrop.UseVisualStyleBackColor = false;
this.btnEyeDrop.Click += new System.EventHandler(this.btnEyeDrop_Click); this.btnEyeDrop.Click += new System.EventHandler(this.btnEyeDrop_Click);
// //
// pbxSample
//
this.pbxSample.Location = new System.Drawing.Point(3, 174);
this.pbxSample.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pbxSample.Name = "pbxSample";
this.pbxSample.Size = new System.Drawing.Size(117, 59);
this.pbxSample.TabIndex = 35;
this.pbxSample.TabStop = false;
//
// btnRandomColor // btnRandomColor
// //
this.btnRandomColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.btnRandomColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.btnRandomColor.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnRandomColor.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnRandomColor.Font = new System.Drawing.Font("Cascadia Code", 10.2F); this.btnRandomColor.Font = new System.Drawing.Font("Cascadia Code", 10.2F);
this.btnRandomColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnRandomColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnRandomColor.Location = new System.Drawing.Point(393, 2); this.btnRandomColor.Location = new System.Drawing.Point(393, 3);
this.btnRandomColor.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnRandomColor.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnRandomColor.Name = "btnRandomColor"; this.btnRandomColor.Name = "btnRandomColor";
this.btnRandomColor.Size = new System.Drawing.Size(108, 33); this.btnRandomColor.Size = new System.Drawing.Size(108, 33);
@@ -452,7 +474,7 @@
this.btnColorPicker.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnColorPicker.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnColorPicker.Font = new System.Drawing.Font("Cascadia Code", 10.2F); this.btnColorPicker.Font = new System.Drawing.Font("Cascadia Code", 10.2F);
this.btnColorPicker.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnColorPicker.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnColorPicker.Location = new System.Drawing.Point(171, 2); this.btnColorPicker.Location = new System.Drawing.Point(171, 3);
this.btnColorPicker.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnColorPicker.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnColorPicker.Name = "btnColorPicker"; this.btnColorPicker.Name = "btnColorPicker";
this.btnColorPicker.Size = new System.Drawing.Size(106, 33); this.btnColorPicker.Size = new System.Drawing.Size(106, 33);
@@ -465,9 +487,9 @@
// //
this.btnRedo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.btnRedo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.btnRedo.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnRedo.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnRedo.Font = new System.Drawing.Font("Cascadia Code", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnRedo.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnRedo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnRedo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnRedo.Location = new System.Drawing.Point(3, 5); this.btnRedo.Location = new System.Drawing.Point(6, 4);
this.btnRedo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnRedo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnRedo.Name = "btnRedo"; this.btnRedo.Name = "btnRedo";
this.btnRedo.Size = new System.Drawing.Size(80, 23); this.btnRedo.Size = new System.Drawing.Size(80, 23);
@@ -480,9 +502,9 @@
// //
this.btnUndo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59))))); this.btnUndo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.btnUndo.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnUndo.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnUndo.Font = new System.Drawing.Font("Cascadia Code", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnUndo.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnUndo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnUndo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.btnUndo.Location = new System.Drawing.Point(92, 5); this.btnUndo.Location = new System.Drawing.Point(95, 4);
this.btnUndo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnUndo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnUndo.Name = "btnUndo"; this.btnUndo.Name = "btnUndo";
this.btnUndo.Size = new System.Drawing.Size(80, 23); this.btnUndo.Size = new System.Drawing.Size(80, 23);
@@ -491,25 +513,10 @@
this.btnUndo.UseVisualStyleBackColor = false; this.btnUndo.UseVisualStyleBackColor = false;
this.btnUndo.Click += new System.EventHandler(this.btnUndo_Click); this.btnUndo.Click += new System.EventHandler(this.btnUndo_Click);
// //
// lsbTools
//
this.lsbTools.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
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.FormattingEnabled = true;
this.lsbTools.ItemHeight = 14;
this.lsbTools.Location = new System.Drawing.Point(6, 20);
this.lsbTools.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.lsbTools.Name = "lsbTools";
this.lsbTools.Size = new System.Drawing.Size(183, 142);
this.lsbTools.TabIndex = 32;
this.lsbTools.SelectedIndexChanged += new System.EventHandler(this.lsbTools_SelectedIndexChanged);
//
// panel1 // panel1
// //
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.panel1.BackColor = System.Drawing.Color.Transparent; this.panel1.BackColor = System.Drawing.Color.Transparent;
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Controls.Add(this.btnClear); this.panel1.Controls.Add(this.btnClear);
this.panel1.Controls.Add(this.btnRedo); this.panel1.Controls.Add(this.btnRedo);
this.panel1.Controls.Add(this.btnUndo); this.panel1.Controls.Add(this.btnUndo);
@@ -519,33 +526,32 @@
this.panel1.Size = new System.Drawing.Size(178, 60); this.panel1.Size = new System.Drawing.Size(178, 60);
this.panel1.TabIndex = 35; this.panel1.TabIndex = 35;
// //
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
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.Name = "label1";
this.label1.Size = new System.Drawing.Size(84, 16);
this.label1.TabIndex = 36;
this.label1.Text = "Paint tools";
//
// panel3 // panel3
// //
this.panel3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.panel3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.panel3.BackColor = System.Drawing.Color.Transparent; this.panel3.BackColor = System.Drawing.Color.Transparent;
this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel3.Controls.Add(this.label3); this.panel3.Controls.Add(this.label3);
this.panel3.Controls.Add(this.pnlLayers); this.panel3.Controls.Add(this.pnlLayers);
this.panel3.Controls.Add(this.btnLayerRemove); this.panel3.Controls.Add(this.btnLayerRemove);
this.panel3.Controls.Add(this.BtnAddLayer); this.panel3.Controls.Add(this.BtnAddLayer);
this.panel3.Controls.Add(this.label2); this.panel3.Controls.Add(this.label2);
this.panel3.Location = new System.Drawing.Point(1014, 247); this.panel3.Location = new System.Drawing.Point(1014, 242);
this.panel3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.panel3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panel3.Name = "panel3"; this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(196, 259); this.panel3.Size = new System.Drawing.Size(196, 259);
this.panel3.TabIndex = 37; this.panel3.TabIndex = 37;
// //
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
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.Name = "label3";
this.label3.Size = new System.Drawing.Size(49, 16);
this.label3.TabIndex = 37;
this.label3.Text = "Layers";
//
// pnlLayers // pnlLayers
// //
this.pnlLayers.AutoScroll = true; this.pnlLayers.AutoScroll = true;
@@ -595,19 +601,18 @@
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
// //
this.panel4.BackColor = System.Drawing.Color.Transparent; this.panel4.BackColor = System.Drawing.Color.Transparent;
this.panel4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel4.Controls.Add(this.btnEyeDrop); this.panel4.Controls.Add(this.btnEyeDrop);
this.panel4.Controls.Add(this.btnRandomColor); this.panel4.Controls.Add(this.btnRandomColor);
this.panel4.Controls.Add(this.btnColorPicker); this.panel4.Controls.Add(this.btnColorPicker);
@@ -621,16 +626,29 @@
this.panel4.Size = new System.Drawing.Size(507, 39); this.panel4.Size = new System.Drawing.Size(507, 39);
this.panel4.TabIndex = 37; this.panel4.TabIndex = 37;
// //
// label3 // btnSvgExport
// //
this.label3.AutoSize = true; this.btnSvgExport.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
this.label3.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnSvgExport.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); this.btnSvgExport.Font = new System.Drawing.Font("Cascadia Code", 10.2F);
this.label3.Location = new System.Drawing.Point(3, 8); this.btnSvgExport.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.label3.Name = "label3"; this.btnSvgExport.Location = new System.Drawing.Point(1014, 505);
this.label3.Size = new System.Drawing.Size(49, 16); this.btnSvgExport.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.label3.TabIndex = 37; this.btnSvgExport.Name = "btnSvgExport";
this.label3.Text = "Layers"; this.btnSvgExport.Size = new System.Drawing.Size(196, 33);
this.btnSvgExport.TabIndex = 37;
this.btnSvgExport.Text = "Export SVG";
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 // PaintForm
// //
@@ -638,8 +656,10 @@
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.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);
@@ -656,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);
@@ -719,10 +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.Label DebugLabel2;
} }
} }
+230 -50
View File
@@ -2,7 +2,7 @@
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: Class that is controlling the view /// Brief: Class that is controlling the view
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -21,20 +21,11 @@ namespace Paint_2
public partial class PaintForm : Form public partial class PaintForm : Form
{ {
const int WINDOW_OFFSET = 15; const int WINDOW_OFFSET = 15;
//const string DEFAULT_FILEPATH = "C:/Paint2/Drawings/"; //readonly Font FONT = new Font("Arial", fontSize);
readonly Color FLAT_RED = Color.FromArgb(0xC6, 0x28, 0x28); readonly Color FLAT_RED = Color.FromArgb(0xC6, 0x28, 0x28);
readonly Color FLAT_GREEN = Color.FromArgb(0x00, 0x89, 0x7B); readonly Color FLAT_GREEN = Color.FromArgb(0x00, 0x89, 0x7B);
readonly Color FLAT_GREY1 = Color.FromArgb(0x59, 0x59, 0x59);
//public Sketch sketch;
//List<PaintTool> toolList;
//bool drawing = false;
//bool randomColor = false;
//bool eyeDropping = false;
//Random _random;
private Color _hoveringColor; private Color _hoveringColor;
private Project _project; private Project _project;
private int _selectedLayer; private int _selectedLayer;
@@ -51,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()
@@ -59,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;
@@ -102,9 +95,18 @@ 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);
if (currentTool != null && currentTool.NeedsFullRefresh)
{
canvas.Image = Project.ForcePaintLayers();
}
else
{
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);
@@ -113,12 +115,16 @@ namespace Paint_2
btnHoveringColor.BackColor = HoveringColor; btnHoveringColor.BackColor = HoveringColor;
List<Color> colorHistory = Project.GetLayerColorHistory(SelectedLayers, 4); List<Color> colorHistory = Project.GetLayerColorHistory(SelectedLayers, 4);
btnColorHistory1.BackColor = colorHistory[0]; btnColorHistory1.BackColor = colorHistory[0];
btnColorHistory1.ForeColor = colorHistory[0]; btnColorHistory1.ForeColor = colorHistory[0];
btnColorHistory2.BackColor = colorHistory[1]; btnColorHistory2.BackColor = colorHistory[1];
btnColorHistory2.ForeColor = colorHistory[1]; btnColorHistory2.ForeColor = colorHistory[1];
btnColorHistory3.BackColor = colorHistory[2]; btnColorHistory3.BackColor = colorHistory[2];
btnColorHistory3.ForeColor = colorHistory[2]; btnColorHistory3.ForeColor = colorHistory[2];
btnColorHistory4.BackColor = colorHistory[3]; btnColorHistory4.BackColor = colorHistory[3];
btnColorHistory4.ForeColor = colorHistory[3]; btnColorHistory4.ForeColor = colorHistory[3];
@@ -127,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;
@@ -148,8 +174,86 @@ namespace Paint_2
{ {
Bitmap map = new Bitmap(size.Width, size.Height); Bitmap map = new Bitmap(size.Width, size.Height);
Graphics gr = Graphics.FromImage(map); Graphics gr = Graphics.FromImage(map);
gr.DrawLine(new Pen(Project.GetCurrentToolColor(SelectedLayers), Project.GetCurrentToolWidth(SelectedLayers)), new Point(0, 0), new Point(size.Width, size.Height));
if (Project.GetCurrentTool(SelectedLayers) != null)
{
PaintTool currentTool = (PaintTool)Project.GetCurrentTool(SelectedLayers).Clone();
Color paint_tool_color = Project.GetCurrentToolColor(SelectedLayers);
int paint_tool_width = Project.GetCurrentToolWidth(SelectedLayers);
//Would have loved to use a switch case but I cant
if (currentTool is Pencil)
{
Pencil pencil = currentTool as Pencil;
pencil.Start(paint_tool_color, paint_tool_width);
pencil.Add(new Point(0, size.Height));
pencil.Add(new Point(size.Width, 0));
pencil.Stop();
pencil.Paint(map);
}
else
{
if (currentTool is DotPencil)
{
DotPencil pencil = currentTool as DotPencil;
pencil.Start(paint_tool_color, paint_tool_width);
int precision = 5;
for (int i = 0; i <= precision; i++)
{
Point newPoint = new Point(i * (size.Width / precision), size.Height - (i * (size.Height / precision)));
pencil.Add(newPoint);
}
pencil.Stop();
pencil.Paint(map);
}
else
{
if (currentTool is BezierPencil)
{
BezierPencil pencil = currentTool as BezierPencil;
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 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 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);
// I KNOW THIS IS HARD CODED BUT ITS ONLY PURPOSE IS TO BE PRETTY so it does'nt matter
pencil.Start(paint_tool_color, paint_tool_width);
pencil.Add(p1);
pencil.Stop();
pencil.Start(paint_tool_color, paint_tool_width);
pencil.Add(p2);
pencil.Stop();
pencil.Start(paint_tool_color, paint_tool_width);
pencil.Add(p3);
pencil.Stop();
pencil.Start(paint_tool_color, paint_tool_width);
pencil.Add(p4);
pencil.Stop();
pencil.Start(paint_tool_color, paint_tool_width);
pencil.Add(p5);
pencil.Stop();
pencil.Start(paint_tool_color, paint_tool_width);
pencil.Add(p6);
pencil.Stop();
pencil.Paint(map);
}
else
{
if (currentTool is RectanglePencil || currentTool is RectangleBorderPencil || currentTool is EllipsePencil || currentTool is EllipseBorderPencil)
{
currentTool.Start(paint_tool_color, paint_tool_width);
currentTool.Add(new Point(0 + size.Width / 10, 0 + size.Height / 10));
currentTool.Add(new Point(size.Width - size.Width / 10, size.Height - size.Height / 10));
currentTool.Stop();
currentTool.Paint(map);
}
}
}
}
}
//gr.DrawLine(new Pen(Project.GetCurrentToolColor(SelectedLayers), Project.GetCurrentToolWidth(SelectedLayers)), new Point(0, 0), new Point(size.Width, size.Height));
return map; return map;
} }
private Color GetHoverColor() private Color GetHoverColor()
@@ -200,6 +304,8 @@ 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
nupPencilWidth_ValueChanged(sender, e);
RefreshUi(); RefreshUi();
} }
@@ -253,7 +359,7 @@ namespace Paint_2
{ {
LayersToRemove.Add(layer); LayersToRemove.Add(layer);
} }
for (int id = layersCount -1; id >= 0; id--) for (int id = layersCount - 1; id >= 0; id--)
{ {
if (Project.RemoveLayer(LayersToRemove[id])) if (Project.RemoveLayer(LayersToRemove[id]))
{ {
@@ -270,22 +376,22 @@ namespace Paint_2
private void BtnAddLayer_Click(object sender, EventArgs e) private void BtnAddLayer_Click(object sender, EventArgs e)
{ {
Project.AddLayer(); SelectedLayers.Add(Project.AddLayer());
DisplayLayers(); DisplayLayers();
RefreshUi(); RefreshUi();
} }
private void DisplayLayers() private void DisplayLayers()
{ {
//I know I know this is not really MVC yet but I will address that int Yoffset = 10;
int Yoffset = 25;
int Xoffset = 10; int Xoffset = 10;
float fontSize = 10;
int blocsCount = 1; Size blocSize = new Size(pnlLayers.Width, pnlLayers.Height / 6);
int btnWidth = 75; int blocsCount = 0;
int labelWidth = 70; int btnWidth = (int)(blocSize.Width / 2.7);
int labelWidth = (int)(blocSize.Width / 3.0);
int BtnXoffset = labelWidth; int BtnXoffset = labelWidth;
int ChkXOffset = BtnXoffset + btnWidth + Xoffset / 2; int ChkXOffset = BtnXoffset + btnWidth /*+ Xoffset*/;
int ChkWidth = 20; int ChkWidth = (int)(blocSize.Width / 6.0);
pnlLayers.Controls.Clear(); pnlLayers.Controls.Clear();
@@ -293,32 +399,54 @@ namespace Paint_2
foreach (Sketch layer in layers) foreach (Sketch layer in layers)
{ {
Label name = new Label(); //LABEL LAYER NAME
name.AutoSize = false; Label lblName = new Label();
name.Width = labelWidth; //Style
name.Text = layer.Name; lblName.Name = "lblLayer" + layer.Id;
name.BackColor = Color.Transparent; lblName.Font = new Font("Arial", fontSize);
pnlLayers.Controls.Add(name); lblName.AutoSize = false;
name.Location = new Point(0, blocsCount * Yoffset); lblName.Width = labelWidth;
lblName.Text = layer.Name;
lblName.BackColor = Color.Transparent;
lblName.Location = new Point(0, blocsCount * blocSize.Height + Yoffset);
//Style
//Behaviour
pnlLayers.Controls.Add(lblName);
//Behaviour
Button btn = new Button(); //BUTTON VISIBILITY
btn.Name = "ChkLayerVisible:" + layer.Id; Button BtnVisbility = new Button();
btn.Click += LayerSelection; //Style
BtnVisbility.FlatStyle = FlatStyle.Popup;
BtnVisbility.BackColor = FLAT_GREY1;
BtnVisbility.Location = new Point(BtnXoffset, blocsCount * blocSize.Height + Yoffset / 2);
BtnVisbility.Width = btnWidth;
//Style
//Behaviour
if (Project.LayersToPrint.Contains(layer.Id)) if (Project.LayersToPrint.Contains(layer.Id))
{ {
btn.Text = "Visible"; BtnVisbility.Text = "Visible";
} }
else else
{ {
btn.Text = "Invisible"; BtnVisbility.Text = "Invisible";
} }
pnlLayers.Controls.Add(btn); BtnVisbility.Name = "ChkLayerVisible:" + layer.Id;
btn.BackColor = Color.FromArgb(59, 59, 59); BtnVisbility.Click += LayerSelection;
btn.Location = new Point(BtnXoffset, blocsCount * Yoffset); pnlLayers.Controls.Add(BtnVisbility);
btn.Width = btnWidth; //Behaviour
btn.FlatStyle = FlatStyle.Popup;
//BUTTON LAYER SELECTION
Button chk = new Button(); Button chk = new Button();
//Style
chk.Location = new Point(ChkXOffset, blocsCount * blocSize.Height + Yoffset / 2);
chk.AutoSize = false;
chk.Text = "";
chk.FlatStyle = FlatStyle.Popup;
chk.Width = ChkWidth;
chk.Name = "ChkLayerSelected:" + layer.Id;
//Style
//Behaviour
chk.Click += LayerCheck; chk.Click += LayerCheck;
if (SelectedLayers.Contains(layer.Id)) if (SelectedLayers.Contains(layer.Id))
{ {
@@ -329,19 +457,14 @@ namespace Paint_2
chk.BackColor = Color.Red; chk.BackColor = Color.Red;
} }
pnlLayers.Controls.Add(chk); pnlLayers.Controls.Add(chk);
chk.Location = new Point(ChkXOffset, blocsCount * Yoffset); //Behaviour
chk.AutoSize = false;
chk.Text = "";
chk.FlatStyle = FlatStyle.Popup;
chk.Width = ChkWidth;
chk.Name = "ChkLayerSelected:" + layer.Id;
blocsCount++; blocsCount++;
} }
} }
private void LayerSelection(object sender, EventArgs e) private void LayerSelection(object sender, EventArgs e)
{ {
//We assume that the id of the layer is the name of the button //We know that the button's name is ChkLayerVisible:... ... being the GUID of the layer
Button btn = sender as Button; Button btn = sender as Button;
string rawId = btn.Name; string rawId = btn.Name;
string id = rawId.Replace("ChkLayerVisible:", String.Empty); string id = rawId.Replace("ChkLayerVisible:", String.Empty);
@@ -350,7 +473,7 @@ namespace Paint_2
} }
private void LayerCheck(object sender, EventArgs e) private void LayerCheck(object sender, EventArgs e)
{ {
// We should receive "CheckBox:937r9837r893" //We know that the button's name is ChkLayerSelected:... ... being the GUID of the layer
Button btn = sender as Button; Button btn = sender as Button;
//MessageBox.Show("Btn " + btn.Name + " pressed"); //MessageBox.Show("Btn " + btn.Name + " pressed");
string rawId = btn.Name; string rawId = btn.Name;
@@ -366,5 +489,62 @@ namespace Paint_2
} }
DisplayLayers(); DisplayLayers();
} }
private void btnSvgExport_Click(object sender, EventArgs e)
{
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;
}
}
} }
} }
+6 -2
View File
@@ -2,7 +2,7 @@
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: Interface that is here to define what is a paint tool /// Brief: Interface that is here to define what is a paint tool
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -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; }
@@ -22,8 +22,11 @@ namespace Paint_2
Color Color { get; set; } Color Color { get; set; }
List<int> Widths { get; set; } List<int> Widths { get; set; }
List<int> WidthsRedo { get; set; } List<int> WidthsRedo { 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();
@@ -33,6 +36,7 @@ namespace Paint_2
void Clear(); void Clear();
List<Color> GetLastColors(int colorNumber); List<Color> GetLastColors(int colorNumber);
void Paint(Bitmap canvas); void Paint(Bitmap canvas);
string PaintSVG();
string ToString(); string ToString();
} }
} }
+32 -1
View File
@@ -2,7 +2,7 @@
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A class that groups all the frequently used by painttools methods /// Brief: A class that groups all the frequently used by painttools methods
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -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;
@@ -101,5 +128,9 @@ namespace Paint_2
Point result = new Point(resultX, resultY); Point result = new Point(resultX, resultY);
return result; return result;
} }
public string StandartPaintSVG(List<List<Point>> Drawings,List<Color> Colors, List<int> Widths)
{
return "COUCOU";
}
} }
} }
+4
View File
@@ -54,6 +54,8 @@
<DependentUpon>ColorPicker.cs</DependentUpon> <DependentUpon>ColorPicker.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="DotPencil.cs" /> <Compile Include="DotPencil.cs" />
<Compile Include="EllipseBorderPencil.cs" />
<Compile Include="EllipsePencil.cs" />
<Compile Include="Form1.cs"> <Compile Include="Form1.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@@ -66,6 +68,8 @@
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Project.cs" /> <Compile Include="Project.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RectangleBorderPencil.cs" />
<Compile Include="RectanglePencil.cs" />
<Compile Include="Sketch.cs" /> <Compile Include="Sketch.cs" />
<EmbeddedResource Include="ColorPicker.resx"> <EmbeddedResource Include="ColorPicker.resx">
<DependentUpon>ColorPicker.cs</DependentUpon> <DependentUpon>ColorPicker.cs</DependentUpon>
+41 -1
View File
@@ -2,7 +2,7 @@
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: Paint tool that is kind of the default tool /// Brief: Paint tool that is kind of the default tool
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -20,6 +20,9 @@ namespace Paint_2
private List<List<Point>> _drawings; private List<List<Point>> _drawings;
private List<List<Point>> _drawingsRedo; private List<List<Point>> _drawingsRedo;
private PaintToolUtils Utils; private PaintToolUtils Utils;
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;
@@ -34,9 +37,12 @@ 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; }
public bool NeedsFullRefresh { get => _needsFullRefresh; set => _needsFullRefresh = value; }
public Pencil(string name) public Pencil(string name)
{ {
@@ -48,6 +54,7 @@ namespace Paint_2
WidthsRedo = new List<int>(); WidthsRedo = new List<int>();
Name = name; Name = name;
Utils = new PaintToolUtils(this); Utils = new PaintToolUtils(this);
NeedsFullRefresh = false;
} }
public void Add(Point point) public void Add(Point point)
{ {
@@ -75,6 +82,37 @@ namespace Paint_2
drawingCounter += 1; drawingCounter += 1;
} }
} }
public string PaintSVG()
{
string result = "";
string newLine = Environment.NewLine;
//foreach (List<Point> drawing in Drawings)
for (int drawCount = 0; drawCount < Drawings.Count; drawCount++)
{
Point p1;
Point p2;
List<Point> drawing = Drawings[drawCount];
Color color = Colors[drawCount];
int width = Widths[drawCount];
for (int pointIndex = 0; pointIndex < drawing.Count; pointIndex++)
{
if (pointIndex >= 1)
{
p1 = drawing[pointIndex - 1];
p2 = drawing[pointIndex];
result += "<ellipse cx=\"" + p2.X + "\" cy=\"" + p2.Y + "\" rx=\"" + width/2 + "\" ry=\"" + width/2 + "\" style=\"fill:rgb(" + color.R + ", " + color.G + ", " + color.B + ");\"/>";
result += newLine;
result += "<line x1=\"" + p1.X + "\" y1=\"" + p1.Y + "\" x2=\"" + p2.X + "\" y2=\"" + p2.Y + "\" style=\"stroke: rgb(" + color.R + ", " + color.G + ", " + color.B + "); stroke-width:" + width + "\"/>";
result += newLine;
}
}
}
return result;
}
public void Start(Color color, int width) public void Start(Color color, int width)
{ {
Utils.StandartStart(color, width); Utils.StandartStart(color, width);
@@ -120,5 +158,7 @@ namespace Paint_2
result.Color = Color; result.Color = Color;
return (Object)(result); return (Object)(result);
} }
} }
} }
+111 -9
View File
@@ -1,4 +1,9 @@
using System; /// file: Project.cs
/// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A controller that manipulates that gives the view all the info it needs and controlls the layers and tools
/// Version: 0.1.0
/// Date: 17/06/2022
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
@@ -25,6 +30,7 @@ namespace Paint_2
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; }
public List<Sketch> Layers { get => _layers; set => _layers = value; } public List<Sketch> Layers { get => _layers; set => _layers = value; }
@@ -46,6 +52,10 @@ namespace Paint_2
AvaibleTools.Add(new Pencil("Default Pencil")); AvaibleTools.Add(new Pencil("Default Pencil"));
AvaibleTools.Add(new DotPencil("Dotted Line")); AvaibleTools.Add(new DotPencil("Dotted Line"));
AvaibleTools.Add(new BezierPencil("Bezier Generator")); AvaibleTools.Add(new BezierPencil("Bezier Generator"));
AvaibleTools.Add(new RectanglePencil("Box tool"));
AvaibleTools.Add(new RectangleBorderPencil("Rectangle tool"));
AvaibleTools.Add(new EllipsePencil("Ball tool"));
AvaibleTools.Add(new EllipseBorderPencil("Ellipse tool"));
//We create a single first layer with the default toolSet //We create a single first layer with the default toolSet
Layers = new List<Sketch>(); Layers = new List<Sketch>();
@@ -54,7 +64,7 @@ namespace Paint_2
AddLayer(); AddLayer();
LayersToPrint.Add(Layers[0].Id); LayersToPrint.Add(Layers[0].Id);
} }
public void AddLayer() public string AddLayer()
{ {
List<PaintTool> newTools = new List<PaintTool>(); List<PaintTool> newTools = new List<PaintTool>();
foreach (PaintTool tool in AvaibleTools) foreach (PaintTool tool in AvaibleTools)
@@ -63,7 +73,22 @@ namespace Paint_2
} }
uniqIdGenerator = Guid.NewGuid(); uniqIdGenerator = Guid.NewGuid();
string test = uniqIdGenerator.ToString(); string test = uniqIdGenerator.ToString();
Layers.Add(new Sketch(String.Concat("Layer", Layers.Count + 1), CanvasSize, newTools, uniqIdGenerator.ToString())); Sketch newSketch = new Sketch(String.Concat("Layer_", Layers.Count + 1), CanvasSize, newTools, uniqIdGenerator.ToString());
Layers.Add(newSketch);
LayersToPrint.Add(newSketch.Id);
RestoreLayerNames();
return (newSketch.Id);
}
private void RestoreLayerNames()
{
//resets all the names to not have multiple layer 3 for example
for (int i = 0; i < Layers.Count; i++)
{
Layers[i].Name = "Layer_" + (i + 1);
}
} }
public bool RemoveLayer(string layerId) public bool RemoveLayer(string layerId)
{ {
@@ -71,6 +96,7 @@ namespace Paint_2
if (layer != null) if (layer != null)
{ {
Layers.Remove(layer); Layers.Remove(layer);
RestoreLayerNames();
return true; return true;
} }
else else
@@ -247,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;
@@ -266,6 +296,18 @@ namespace Paint_2
layer.Clear(); layer.Clear();
} }
} }
public PaintTool GetCurrentTool(List<string> selectedLayers)
{
if (Layers.Count == 0 || selectedLayers.Count == 0)
{
return null;
}
else
{
Sketch CurrentLayer = FindSketch(Layers, selectedLayers[0]);
return CurrentLayer.CurrentTool;
}
}
public Color GetCurrentToolColor(List<string> selectedLayers) public Color GetCurrentToolColor(List<string> selectedLayers)
{ {
if (Layers.Count == 0 || selectedLayers.Count == 0) if (Layers.Count == 0 || selectedLayers.Count == 0)
@@ -379,5 +421,65 @@ 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()
{
string fileContent = "";
string newLine = Environment.NewLine;
fileContent += "<svg version=\"1.1\" width=\"100%\" viewbox=\"0 0 "+CanvasSize.Width+" "+CanvasSize.Height+"\" xmlns = \"http://www.w3.org/2000/svg\">";
fileContent += newLine;
foreach (Sketch layer in Layers)
{
fileContent += "<!-- "+layer.Name+" -->";
fileContent += newLine;
fileContent += layer.PaintSVG();
}
fileContent += newLine;
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;
}
} }
} }
+177
View File
@@ -0,0 +1,177 @@
/// file: RectangleBorderPencil.cs
/// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A tool that paints the outline of a rectangle
/// Version: 0.1.0
/// Date: 17/06/2022
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace Paint_2
{
internal class RectangleBorderPencil:PaintTool
{
private List<List<Point>> _drawings;
private List<List<Point>> _drawingsRedo;
private bool _needsFullRefresh;
private bool _isShiftPressed;
private bool _isCtrlPressed;
private PaintToolUtils Utils;
private List<Color> _colors;
private List<Color> _colorsRedo;
private List<int> _widths;
private List<int> _widthsRedo;
private Color _color;
private string _name;
private int _width;
public List<List<Point>> Drawings { get => _drawings; set => _drawings = value; }
public List<List<Point>> DrawingsRedo { get => _drawingsRedo; set => _drawingsRedo = value; }
public bool NeedsFullRefresh { get => _needsFullRefresh; set => _needsFullRefresh = value; }
public List<Color> Colors { get => _colors; set => _colors = value; }
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
public List<int> Widths { get => _widths; set => _widths = value; }
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
public 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; }
public RectangleBorderPencil(string name)
{
NeedsFullRefresh = true;
Drawings = new List<List<Point>>();
DrawingsRedo = new List<List<Point>>();
Colors = new List<Color>();
ColorsRedo = new List<Color>();
Widths = new List<int>();
WidthsRedo = new List<int>();
Name = name;
Utils = new PaintToolUtils(this);
}
public void Add(Point point)
{
List<Point> myDrawing = Drawings[Drawings.Count - 1];
if (myDrawing.Count == 0 || myDrawing.Count == 1)
{
myDrawing.Add(point);
}
else
{
myDrawing[1] = point;
}
Drawings[Drawings.Count - 1] = myDrawing;
}
public void Paint(Bitmap canvas)
{
Graphics gr = Graphics.FromImage(canvas);
int drawingCounter = 0;
Size pointSize;
foreach (List<Point> drawing in Drawings)
{
if (drawing.Count == 2)
{
Point start = drawing[0];
Point end = drawing[1];
List<Point> points;
if (drawingCounter == Drawings.Count - 1)
{
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
}
else
{
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++;
}
}
public string PaintSVG()
{
string result = "";
string newLine = Environment.NewLine;
int drawingCounter = 0;
Size pointSize;
foreach (List<Point> drawing in Drawings)
{
if (drawing.Count == 2)
{
Point start = drawing[0];
Point end = drawing[1];
List<Point> points;
if (drawingCounter == Drawings.Count - 1)
{
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
}
else
{
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;
}
drawingCounter++;
}
return result;
}
public void Start(Color color, int width)
{
Utils.StandartStart(color, width);
}
public void Clear()
{
Utils.StandartClear();
}
public void Stop()
{
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)
{
return bmp;
}
public List<Color> GetLastColors(int colorNumber)
{
return Utils.SandartGetLastColors(colorNumber);
}
public override string ToString()
{
return Name;
}
public void Undo()
{
Utils.StandartUndo();
}
public void Redo()
{
Utils.StandartRedo();
}
public object Clone()
{
RectangleBorderPencil result = new RectangleBorderPencil(Name);
result.Width = Width;
result.Color = Color;
return (Object)(result);
}
}
}
+167
View File
@@ -0,0 +1,167 @@
/// file: RectanglePencil.cs
/// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: A tool that paints a Rectangle
/// Version: 0.1.0
/// Date: 17/06/2022
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace Paint_2
{
internal class RectanglePencil:PaintTool
{
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;
private List<int> _widths;
private List<int> _widthsRedo;
private Color _color;
private string _name;
private int _width;
public List<List<Point>> Drawings { get => _drawings; set => _drawings = value; }
public List<List<Point>> DrawingsRedo { get => _drawingsRedo; set => _drawingsRedo = value; }
public bool NeedsFullRefresh { get => _needsFullRefresh; set => _needsFullRefresh = value; }
public List<Color> Colors { get => _colors; set => _colors = value; }
public List<Color> ColorsRedo { get => _colorsRedo; set => _colorsRedo = value; }
public List<int> Widths { get => _widths; set => _widths = value; }
public List<int> WidthsRedo { get => _widthsRedo; set => _widthsRedo = value; }
public Color Color { get => _color; set => _color = value; }
public string Name { get => _name; set => _name = value; }
public int Width { get => _width; set => _width = value; }
public bool IsShiftPressed { get => _isShiftPressed; set => _isShiftPressed = value; }
public bool IsCtrlPressed { get => _isCtrlPressed; set => _isCtrlPressed = value; }
public RectanglePencil(string name)
{
NeedsFullRefresh = true;
Drawings = new List<List<Point>>();
DrawingsRedo = new List<List<Point>>();
Colors = new List<Color>();
ColorsRedo = new List<Color>();
Widths = new List<int>();
WidthsRedo = new List<int>();
Name = name;
Utils = new PaintToolUtils(this);
}
public void Add(Point point)
{
List<Point> myDrawing = Drawings[Drawings.Count - 1];
if (myDrawing.Count == 0 || myDrawing.Count == 1)
{
myDrawing.Add(point);
}
else
{
myDrawing[1] = point;
}
Drawings[Drawings.Count - 1] = myDrawing;
}
public void Paint(Bitmap canvas)
{
Graphics gr = Graphics.FromImage(canvas);
int drawingCounter = 0;
foreach (List<Point> drawing in Drawings)
{
if (drawing.Count == 2)
{
List<Point> points;
if (drawingCounter == Drawings.Count - 1)
{
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
}
else
{
points = Utils.ConvertRectangleIntoPositive(false, drawing[0], drawing[1]);
}
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++;
}
}
public string PaintSVG()
{
string result = "";
string newLine = Environment.NewLine;
int drawingCounter = 0;
foreach (List<Point> drawing in Drawings)
{
if (drawing.Count == 2)
{
List<Point> points;
if (drawingCounter == Drawings.Count -1)
{
points = Utils.ConvertRectangleIntoPositive(IsCtrlPressed, drawing[0], drawing[1]);
}
else
{
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;
}
drawingCounter++;
}
return result;
}
public void Start(Color color, int width)
{
Utils.StandartStart(color, width);
}
public void Clear()
{
Utils.StandartClear();
}
public void Stop()
{
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)
{
return bmp;
}
public List<Color> GetLastColors(int colorNumber)
{
return Utils.SandartGetLastColors(colorNumber);
}
public override string ToString()
{
return Name;
}
public void Undo()
{
Utils.StandartUndo();
}
public void Redo()
{
Utils.StandartRedo();
}
public object Clone()
{
RectanglePencil result = new RectanglePencil(Name);
result.Width = Width;
result.Color = Color;
return (Object)(result);
}
}
}
+39 -4
View File
@@ -1,8 +1,8 @@
/// file: Sketch.cs /// file: Sketch.cs
/// Author: Maxime Rohmer <maxluligames@gmail.com> /// Author: Maxime Rohmer <maxluligames@gmail.com>
/// Brief: Class that is used to store and controll the tools and the bitmap /// Brief: This is a layer wich can controll a set of tools and is controlled by the Project
/// Version: 0.1.0 /// Version: 0.1.0
/// Date: 08/06/2022 /// Date: 17/06/2022
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -30,7 +30,7 @@ namespace Paint_2
public string Name { get => _name; set => _name = value; } public string Name { get => _name; set => _name = value; }
public string Id { get => id; set => id = value; } public string Id { get => id; set => id = value; }
public Sketch(string name,Size sketchSize, List<PaintTool> toolList,string guid) public Sketch(string name, Size sketchSize, List<PaintTool> toolList, string guid)
{ {
IsDrawing = false; IsDrawing = false;
Id = guid; Id = guid;
@@ -52,7 +52,7 @@ namespace Paint_2
CurrentTool = null; CurrentTool = null;
} }
} }
public Sketch(List<PaintTool> toolList,string guid) : this("Layer 1",new Size(500, 500), toolList,guid) public Sketch(List<PaintTool> toolList, string guid) : this("Layer 1", new Size(500, 500), toolList, guid)
{ {
//empty //empty
} }
@@ -116,6 +116,19 @@ namespace Paint_2
CurrentTool.Paint(Drawing); CurrentTool.Paint(Drawing);
return Drawing; return Drawing;
} }
public string PaintSVG()
{
string result = "";
string newLine = Environment.NewLine;
foreach (PaintTool tool in ToolList)
{
result += "<!-- " + tool.Name + " -->";
result += newLine;
result += tool.PaintSVG();
}
return result;
}
public Bitmap ForcePaint() public Bitmap ForcePaint()
{ {
Drawing = new Bitmap(SketchSize.Width, SketchSize.Height); Drawing = new Bitmap(SketchSize.Width, SketchSize.Height);
@@ -130,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;