Added multi layer support
This commit is contained in:
@@ -173,9 +173,12 @@ namespace Paint_2
|
|||||||
Utils.StandartRedo();
|
Utils.StandartRedo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap Stop(Bitmap bmp)
|
public object Clone()
|
||||||
{
|
{
|
||||||
return bmp;
|
BezierPencil result = new BezierPencil(Name);
|
||||||
|
result.Width = Width;
|
||||||
|
result.Color = Color;
|
||||||
|
return (Object)(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace Paint_2
|
|||||||
|
|
||||||
private void ColorPicker_Load(object sender, EventArgs e)
|
private void ColorPicker_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SelectedColor = main.sketch.CurrentTool.Color;
|
SelectedColor = main.Project.GetCurrentToolColor(main.SelectedLayers);
|
||||||
RefreshUi();
|
RefreshUi();
|
||||||
}
|
}
|
||||||
private Bitmap RefreshMap(Size size)
|
private Bitmap RefreshMap(Size size)
|
||||||
@@ -253,7 +253,7 @@ namespace Paint_2
|
|||||||
|
|
||||||
private void ColorPicker_FormClosing(object sender, FormClosingEventArgs e)
|
private void ColorPicker_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
main.sketch.ChangePaintToolColor(SelectedColor);
|
main.Project.ChangeColor(main.SelectedLayers, SelectedColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tbxColorHex_KeyDown(object sender, KeyEventArgs e)
|
private void tbxColorHex_KeyDown(object sender, KeyEventArgs e)
|
||||||
@@ -271,7 +271,7 @@ namespace Paint_2
|
|||||||
|
|
||||||
private void pbxSelectedColor_Click(object sender, EventArgs e)
|
private void pbxSelectedColor_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
main.sketch.ChangePaintToolColor(SelectedColor);
|
main.Project.ChangeColor(main.SelectedLayers, SelectedColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tmrRefresh_Tick(object sender, EventArgs e)
|
private void tmrRefresh_Tick(object sender, EventArgs e)
|
||||||
|
|||||||
@@ -74,7 +74,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 Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
@@ -82,7 +82,7 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
for (int i = 0;i<POST_PROCESSING_PRECISION;i++)
|
for (int i = 0; i < POST_PROCESSING_PRECISION; i++)
|
||||||
{
|
{
|
||||||
List<Point> Drawing = Drawings[Drawings.Count - 1];
|
List<Point> Drawing = Drawings[Drawings.Count - 1];
|
||||||
Drawings[Drawings.Count - 1] = PostProcessing(Drawing);
|
Drawings[Drawings.Count - 1] = PostProcessing(Drawing);
|
||||||
@@ -128,9 +128,12 @@ namespace Paint_2
|
|||||||
Utils.StandartRedo();
|
Utils.StandartRedo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap Stop(Bitmap bmp)
|
public object Clone()
|
||||||
{
|
{
|
||||||
return bmp;
|
DotPencil result = new DotPencil(Name);
|
||||||
|
result.Width = Width;
|
||||||
|
result.Color = Color;
|
||||||
|
return (Object)(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
110
Paint_2/Form1.Designer.cs
generated
110
Paint_2/Form1.Designer.cs
generated
@@ -67,10 +67,12 @@
|
|||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.button2 = new System.Windows.Forms.Button();
|
this.button2 = new System.Windows.Forms.Button();
|
||||||
this.panel3 = new System.Windows.Forms.Panel();
|
this.panel3 = new System.Windows.Forms.Panel();
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
this.btnLayerRemove = 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.button1 = new System.Windows.Forms.Button();
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
this.listBox1 = new System.Windows.Forms.ListBox();
|
this.DebugLabel = new System.Windows.Forms.Label();
|
||||||
|
this.pnlLayers = new System.Windows.Forms.Panel();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.canvas)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.canvas)).BeginInit();
|
||||||
this.panelFile.SuspendLayout();
|
this.panelFile.SuspendLayout();
|
||||||
this.panelDrawing.SuspendLayout();
|
this.panelDrawing.SuspendLayout();
|
||||||
@@ -93,7 +95,7 @@
|
|||||||
this.tbxProjectName.Location = new System.Drawing.Point(11, 3);
|
this.tbxProjectName.Location = new System.Drawing.Point(11, 3);
|
||||||
this.tbxProjectName.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
|
this.tbxProjectName.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
|
||||||
this.tbxProjectName.Name = "tbxProjectName";
|
this.tbxProjectName.Name = "tbxProjectName";
|
||||||
this.tbxProjectName.Size = new System.Drawing.Size(253, 38);
|
this.tbxProjectName.Size = new System.Drawing.Size(253, 32);
|
||||||
this.tbxProjectName.TabIndex = 0;
|
this.tbxProjectName.TabIndex = 0;
|
||||||
this.tbxProjectName.Text = "Untitled Project";
|
this.tbxProjectName.Text = "Untitled Project";
|
||||||
//
|
//
|
||||||
@@ -144,7 +146,7 @@
|
|||||||
this.lblSelectedColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.lblSelectedColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.lblSelectedColor.Location = new System.Drawing.Point(7, 28);
|
this.lblSelectedColor.Location = new System.Drawing.Point(7, 28);
|
||||||
this.lblSelectedColor.Name = "lblSelectedColor";
|
this.lblSelectedColor.Name = "lblSelectedColor";
|
||||||
this.lblSelectedColor.Size = new System.Drawing.Size(288, 20);
|
this.lblSelectedColor.Size = new System.Drawing.Size(234, 17);
|
||||||
this.lblSelectedColor.TabIndex = 1;
|
this.lblSelectedColor.TabIndex = 1;
|
||||||
this.lblSelectedColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
|
this.lblSelectedColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
|
||||||
//
|
//
|
||||||
@@ -192,7 +194,7 @@
|
|||||||
this.lblHeight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.lblHeight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.lblHeight.Location = new System.Drawing.Point(3, 40);
|
this.lblHeight.Location = new System.Drawing.Point(3, 40);
|
||||||
this.lblHeight.Name = "lblHeight";
|
this.lblHeight.Name = "lblHeight";
|
||||||
this.lblHeight.Size = new System.Drawing.Size(74, 20);
|
this.lblHeight.Size = new System.Drawing.Size(60, 17);
|
||||||
this.lblHeight.TabIndex = 34;
|
this.lblHeight.TabIndex = 34;
|
||||||
this.lblHeight.Text = "H:2000";
|
this.lblHeight.Text = "H:2000";
|
||||||
//
|
//
|
||||||
@@ -202,7 +204,7 @@
|
|||||||
this.lblWidth.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.lblWidth.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.lblWidth.Location = new System.Drawing.Point(3, 8);
|
this.lblWidth.Location = new System.Drawing.Point(3, 8);
|
||||||
this.lblWidth.Name = "lblWidth";
|
this.lblWidth.Name = "lblWidth";
|
||||||
this.lblWidth.Size = new System.Drawing.Size(77, 20);
|
this.lblWidth.Size = new System.Drawing.Size(64, 17);
|
||||||
this.lblWidth.TabIndex = 33;
|
this.lblWidth.TabIndex = 33;
|
||||||
this.lblWidth.Text = "W:2000";
|
this.lblWidth.Text = "W:2000";
|
||||||
//
|
//
|
||||||
@@ -237,7 +239,7 @@
|
|||||||
this.label14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.label14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.label14.Location = new System.Drawing.Point(7, 6);
|
this.label14.Location = new System.Drawing.Point(7, 6);
|
||||||
this.label14.Name = "label14";
|
this.label14.Name = "label14";
|
||||||
this.label14.Size = new System.Drawing.Size(150, 22);
|
this.label14.Size = new System.Drawing.Size(120, 18);
|
||||||
this.label14.TabIndex = 29;
|
this.label14.TabIndex = 29;
|
||||||
this.label14.Text = "Selected color";
|
this.label14.Text = "Selected color";
|
||||||
//
|
//
|
||||||
@@ -271,7 +273,7 @@
|
|||||||
this.lblHoveringColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.lblHoveringColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.lblHoveringColor.Location = new System.Drawing.Point(8, 28);
|
this.lblHoveringColor.Location = new System.Drawing.Point(8, 28);
|
||||||
this.lblHoveringColor.Name = "lblHoveringColor";
|
this.lblHoveringColor.Name = "lblHoveringColor";
|
||||||
this.lblHoveringColor.Size = new System.Drawing.Size(288, 20);
|
this.lblHoveringColor.Size = new System.Drawing.Size(234, 17);
|
||||||
this.lblHoveringColor.TabIndex = 1;
|
this.lblHoveringColor.TabIndex = 1;
|
||||||
this.lblHoveringColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
|
this.lblHoveringColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
|
||||||
//
|
//
|
||||||
@@ -282,7 +284,7 @@
|
|||||||
this.label15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.label15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.label15.Location = new System.Drawing.Point(8, 6);
|
this.label15.Location = new System.Drawing.Point(8, 6);
|
||||||
this.label15.Name = "label15";
|
this.label15.Name = "label15";
|
||||||
this.label15.Size = new System.Drawing.Size(150, 22);
|
this.label15.Size = new System.Drawing.Size(120, 18);
|
||||||
this.label15.TabIndex = 29;
|
this.label15.TabIndex = 29;
|
||||||
this.label15.Text = "Hovering color";
|
this.label15.Text = "Hovering color";
|
||||||
//
|
//
|
||||||
@@ -304,7 +306,7 @@
|
|||||||
0,
|
0,
|
||||||
0});
|
0});
|
||||||
this.nupPencilWidth.Name = "nupPencilWidth";
|
this.nupPencilWidth.Name = "nupPencilWidth";
|
||||||
this.nupPencilWidth.Size = new System.Drawing.Size(71, 33);
|
this.nupPencilWidth.Size = new System.Drawing.Size(71, 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,
|
||||||
@@ -359,7 +361,7 @@
|
|||||||
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(7, 3);
|
this.label4.Location = new System.Drawing.Point(7, 3);
|
||||||
this.label4.Name = "label4";
|
this.label4.Name = "label4";
|
||||||
this.label4.Size = new System.Drawing.Size(135, 20);
|
this.label4.Size = new System.Drawing.Size(105, 16);
|
||||||
this.label4.TabIndex = 1;
|
this.label4.TabIndex = 1;
|
||||||
this.label4.Text = "Colors history";
|
this.label4.Text = "Colors history";
|
||||||
//
|
//
|
||||||
@@ -428,7 +430,7 @@
|
|||||||
//
|
//
|
||||||
this.pbxSample.Location = new System.Drawing.Point(10, 152);
|
this.pbxSample.Location = new System.Drawing.Point(10, 152);
|
||||||
this.pbxSample.Name = "pbxSample";
|
this.pbxSample.Name = "pbxSample";
|
||||||
this.pbxSample.Size = new System.Drawing.Size(101, 33);
|
this.pbxSample.Size = new System.Drawing.Size(101, 27);
|
||||||
this.pbxSample.TabIndex = 35;
|
this.pbxSample.TabIndex = 35;
|
||||||
this.pbxSample.TabStop = false;
|
this.pbxSample.TabStop = false;
|
||||||
//
|
//
|
||||||
@@ -494,10 +496,10 @@
|
|||||||
this.lsbTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
this.lsbTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
this.lsbTools.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.lsbTools.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.lsbTools.FormattingEnabled = true;
|
this.lsbTools.FormattingEnabled = true;
|
||||||
this.lsbTools.ItemHeight = 20;
|
this.lsbTools.ItemHeight = 17;
|
||||||
this.lsbTools.Location = new System.Drawing.Point(10, 33);
|
this.lsbTools.Location = new System.Drawing.Point(10, 33);
|
||||||
this.lsbTools.Name = "lsbTools";
|
this.lsbTools.Name = "lsbTools";
|
||||||
this.lsbTools.Size = new System.Drawing.Size(179, 122);
|
this.lsbTools.Size = new System.Drawing.Size(179, 121);
|
||||||
this.lsbTools.TabIndex = 32;
|
this.lsbTools.TabIndex = 32;
|
||||||
this.lsbTools.SelectedIndexChanged += new System.EventHandler(this.lsbTools_SelectedIndexChanged);
|
this.lsbTools.SelectedIndexChanged += new System.EventHandler(this.lsbTools_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
@@ -534,7 +536,7 @@
|
|||||||
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.label1.Location = new System.Drawing.Point(8, 10);
|
this.label1.Location = new System.Drawing.Point(8, 10);
|
||||||
this.label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(108, 20);
|
this.label1.Size = new System.Drawing.Size(84, 16);
|
||||||
this.label1.TabIndex = 36;
|
this.label1.TabIndex = 36;
|
||||||
this.label1.Text = "Paint tools";
|
this.label1.Text = "Paint tools";
|
||||||
//
|
//
|
||||||
@@ -557,25 +559,44 @@
|
|||||||
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.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
this.panel3.Controls.Add(this.label3);
|
this.panel3.Controls.Add(this.pnlLayers);
|
||||||
|
this.panel3.Controls.Add(this.btnLayerRemove);
|
||||||
|
this.panel3.Controls.Add(this.BtnAddLayer);
|
||||||
this.panel3.Controls.Add(this.label2);
|
this.panel3.Controls.Add(this.label2);
|
||||||
this.panel3.Controls.Add(this.button1);
|
this.panel3.Controls.Add(this.button1);
|
||||||
this.panel3.Controls.Add(this.listBox1);
|
|
||||||
this.panel3.Location = new System.Drawing.Point(920, 384);
|
this.panel3.Location = new System.Drawing.Point(920, 384);
|
||||||
this.panel3.Name = "panel3";
|
this.panel3.Name = "panel3";
|
||||||
this.panel3.Size = new System.Drawing.Size(200, 175);
|
this.panel3.Size = new System.Drawing.Size(200, 175);
|
||||||
this.panel3.TabIndex = 37;
|
this.panel3.TabIndex = 37;
|
||||||
//
|
//
|
||||||
// label3
|
// btnLayerRemove
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
this.btnLayerRemove.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.btnLayerRemove.Enabled = false;
|
||||||
this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.btnLayerRemove.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
|
||||||
this.label3.Location = new System.Drawing.Point(8, 10);
|
this.btnLayerRemove.Font = new System.Drawing.Font("Cascadia Code", 10.2F);
|
||||||
this.label3.Name = "label3";
|
this.btnLayerRemove.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
this.label3.Size = new System.Drawing.Size(135, 20);
|
this.btnLayerRemove.Location = new System.Drawing.Point(101, 137);
|
||||||
this.label3.TabIndex = 37;
|
this.btnLayerRemove.Name = "btnLayerRemove";
|
||||||
this.label3.Text = "Drawing Layers";
|
this.btnLayerRemove.Size = new System.Drawing.Size(88, 33);
|
||||||
|
this.btnLayerRemove.TabIndex = 38;
|
||||||
|
this.btnLayerRemove.Text = "-";
|
||||||
|
this.btnLayerRemove.UseVisualStyleBackColor = false;
|
||||||
|
this.btnLayerRemove.Click += new System.EventHandler(this.btnLayerRemove_Click);
|
||||||
|
//
|
||||||
|
// BtnAddLayer
|
||||||
|
//
|
||||||
|
this.BtnAddLayer.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
|
||||||
|
this.BtnAddLayer.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
|
||||||
|
this.BtnAddLayer.Font = new System.Drawing.Font("Cascadia Code", 10.2F);
|
||||||
|
this.BtnAddLayer.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||||
|
this.BtnAddLayer.Location = new System.Drawing.Point(10, 137);
|
||||||
|
this.BtnAddLayer.Name = "BtnAddLayer";
|
||||||
|
this.BtnAddLayer.Size = new System.Drawing.Size(88, 33);
|
||||||
|
this.BtnAddLayer.TabIndex = 37;
|
||||||
|
this.BtnAddLayer.Text = "+";
|
||||||
|
this.BtnAddLayer.UseVisualStyleBackColor = false;
|
||||||
|
this.BtnAddLayer.Click += new System.EventHandler(this.BtnAddLayer_Click);
|
||||||
//
|
//
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
@@ -583,7 +604,7 @@
|
|||||||
this.label2.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.label2.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.label2.Location = new System.Drawing.Point(8, 10);
|
this.label2.Location = new System.Drawing.Point(8, 10);
|
||||||
this.label2.Name = "label2";
|
this.label2.Name = "label2";
|
||||||
this.label2.Size = new System.Drawing.Size(0, 20);
|
this.label2.Size = new System.Drawing.Size(0, 16);
|
||||||
this.label2.TabIndex = 36;
|
this.label2.TabIndex = 36;
|
||||||
//
|
//
|
||||||
// button1
|
// button1
|
||||||
@@ -600,24 +621,30 @@
|
|||||||
this.button1.Text = "ColorPicker";
|
this.button1.Text = "ColorPicker";
|
||||||
this.button1.UseVisualStyleBackColor = false;
|
this.button1.UseVisualStyleBackColor = false;
|
||||||
//
|
//
|
||||||
// listBox1
|
// DebugLabel
|
||||||
//
|
//
|
||||||
this.listBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
|
this.DebugLabel.AutoSize = true;
|
||||||
this.listBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
this.DebugLabel.Location = new System.Drawing.Point(12, 555);
|
||||||
this.listBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
this.DebugLabel.Name = "DebugLabel";
|
||||||
this.listBox1.FormattingEnabled = true;
|
this.DebugLabel.Size = new System.Drawing.Size(54, 17);
|
||||||
this.listBox1.ItemHeight = 20;
|
this.DebugLabel.TabIndex = 38;
|
||||||
this.listBox1.Location = new System.Drawing.Point(10, 33);
|
this.DebugLabel.Text = "Debug";
|
||||||
this.listBox1.Name = "listBox1";
|
//
|
||||||
this.listBox1.Size = new System.Drawing.Size(179, 122);
|
// pnlLayers
|
||||||
this.listBox1.TabIndex = 32;
|
//
|
||||||
|
this.pnlLayers.AutoScroll = true;
|
||||||
|
this.pnlLayers.Location = new System.Drawing.Point(10, 10);
|
||||||
|
this.pnlLayers.Name = "pnlLayers";
|
||||||
|
this.pnlLayers.Size = new System.Drawing.Size(178, 121);
|
||||||
|
this.pnlLayers.TabIndex = 39;
|
||||||
//
|
//
|
||||||
// PaintForm
|
// PaintForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F);
|
||||||
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(1132, 655);
|
this.ClientSize = new System.Drawing.Size(1132, 655);
|
||||||
|
this.Controls.Add(this.DebugLabel);
|
||||||
this.Controls.Add(this.panel3);
|
this.Controls.Add(this.panel3);
|
||||||
this.Controls.Add(this.panel2);
|
this.Controls.Add(this.panel2);
|
||||||
this.Controls.Add(this.btnColorPicker);
|
this.Controls.Add(this.btnColorPicker);
|
||||||
@@ -655,6 +682,7 @@
|
|||||||
this.panel3.ResumeLayout(false);
|
this.panel3.ResumeLayout(false);
|
||||||
this.panel3.PerformLayout();
|
this.panel3.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,12 +724,14 @@
|
|||||||
private System.Windows.Forms.Label label1;
|
private System.Windows.Forms.Label label1;
|
||||||
private System.Windows.Forms.Button button2;
|
private System.Windows.Forms.Button button2;
|
||||||
private System.Windows.Forms.Panel panel3;
|
private System.Windows.Forms.Panel panel3;
|
||||||
private System.Windows.Forms.Label label3;
|
|
||||||
private System.Windows.Forms.Label label2;
|
private System.Windows.Forms.Label label2;
|
||||||
private System.Windows.Forms.Button button1;
|
private System.Windows.Forms.Button button1;
|
||||||
private System.Windows.Forms.ListBox listBox1;
|
|
||||||
private System.Windows.Forms.Button btnLoadFile;
|
private System.Windows.Forms.Button btnLoadFile;
|
||||||
private System.Windows.Forms.Button btnEyeDrop;
|
private System.Windows.Forms.Button btnEyeDrop;
|
||||||
|
private System.Windows.Forms.Button btnLayerRemove;
|
||||||
|
private System.Windows.Forms.Button BtnAddLayer;
|
||||||
|
private System.Windows.Forms.Label DebugLabel;
|
||||||
|
private System.Windows.Forms.Panel pnlLayers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
290
Paint_2/Form1.cs
290
Paint_2/Form1.cs
@@ -21,82 +21,67 @@ 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/";
|
//const string DEFAULT_FILEPATH = "C:/Paint2/Drawings/";
|
||||||
Color FLAT_RED = Color.FromArgb(0xC6, 0x28, 0x28);
|
readonly Color FLAT_RED = Color.FromArgb(0xC6, 0x28, 0x28);
|
||||||
Color FLAT_GREEN = Color.FromArgb(0x00, 0x89, 0x7B);
|
readonly Color FLAT_GREEN = Color.FromArgb(0x00, 0x89, 0x7B);
|
||||||
|
|
||||||
|
//public Sketch sketch;
|
||||||
|
|
||||||
|
|
||||||
|
//List<PaintTool> toolList;
|
||||||
|
|
||||||
|
//bool drawing = false;
|
||||||
|
//bool randomColor = false;
|
||||||
|
//bool eyeDropping = false;
|
||||||
|
|
||||||
|
//Random _random;
|
||||||
|
private Color _hoveringColor;
|
||||||
|
private Project _project;
|
||||||
|
private int _selectedLayer;
|
||||||
|
private List<int> _selectedLayers;
|
||||||
|
|
||||||
|
public Color HoveringColor { get => _hoveringColor; set => _hoveringColor = value; }
|
||||||
|
public Project Project { get => _project; set => _project = value; }
|
||||||
|
public int SelectedLayer { get => _selectedLayer; set => _selectedLayer = value; }
|
||||||
|
public List<int> SelectedLayers { get => _selectedLayers; set => _selectedLayers = value; }
|
||||||
|
|
||||||
public Sketch sketch;
|
|
||||||
List<PaintTool> toolList;
|
|
||||||
bool drawing = false;
|
|
||||||
bool randomColor = false;
|
|
||||||
bool eyeDropping = false;
|
|
||||||
Random rnd;
|
|
||||||
Color hoveringColor;
|
|
||||||
public PaintForm()
|
public PaintForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
rnd = new Random();
|
Project = new Project("Untitled project", canvas.Size);
|
||||||
toolList = new List<PaintTool>();
|
SelectedLayers = new List<int>();
|
||||||
toolList.Add(new Pencil("Default Pencil"));
|
SelectedLayers.Add(0);
|
||||||
toolList.Add(new DotPencil("Dotted Line"));
|
|
||||||
toolList.Add(new BezierPencil("Bezier Generator"));
|
|
||||||
sketch = new Sketch(new Size(canvas.Width, canvas.Height), toolList);
|
|
||||||
tmrRefresh.Enabled = true;
|
|
||||||
|
|
||||||
RefreshUi();
|
RefreshUi();
|
||||||
}
|
}
|
||||||
private Point MousePositionToCanvasPosition()
|
private Point MousePositionToCanvasPosition()
|
||||||
{
|
{
|
||||||
//return new Point(MousePosition.X - canvas.Location.X, MousePosition.Y - canvas.Location.Y);
|
|
||||||
return canvas.PointToClient(MousePosition);
|
return canvas.PointToClient(MousePosition);
|
||||||
}
|
}
|
||||||
private void canvas_MouseDown(object sender, MouseEventArgs e)
|
private void canvas_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (eyeDropping)
|
Color hoveringColor = GetHoverColor();
|
||||||
{
|
Point mousePosition = MousePositionToCanvasPosition();
|
||||||
Color pointedColor = GetHoverColor();
|
int toolWidth = (int)nupPencilWidth.Value;
|
||||||
if (sketch.CurrentTool.Color != pointedColor)
|
Project.MouseDown(SelectedLayers,hoveringColor, mousePosition, toolWidth);
|
||||||
{
|
RefreshUi();
|
||||||
sketch.ChangePaintToolColor(pointedColor);
|
|
||||||
RefreshUi();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
drawing = true;
|
|
||||||
if (randomColor)
|
|
||||||
{
|
|
||||||
sketch.StartDrawing(MousePositionToCanvasPosition(), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), (int)nupPencilWidth.Value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sketch.StartDrawing(MousePositionToCanvasPosition(), sketch.CurrentTool.Color, (int)nupPencilWidth.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void canvas_MouseUp(object sender, MouseEventArgs e)
|
private void canvas_MouseUp(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (!eyeDropping)
|
Point mousePosition = MousePositionToCanvasPosition();
|
||||||
{
|
Project.MouseUp(SelectedLayers, mousePosition);
|
||||||
sketch.AddDrawingPoint(MousePositionToCanvasPosition());
|
RefreshUi();
|
||||||
drawing = false;
|
|
||||||
canvas.Image = sketch.StopDrawing((Bitmap)canvas.Image);
|
|
||||||
RefreshUi();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tmrRefresh_Tick(object sender, EventArgs e)
|
private void tmrRefresh_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (drawing)
|
Point mousePosition = MousePositionToCanvasPosition();
|
||||||
{
|
Project.TimerTick(SelectedLayers, mousePosition);
|
||||||
sketch.AddDrawingPoint(MousePositionToCanvasPosition());
|
|
||||||
}
|
|
||||||
RefreshUi();
|
RefreshUi();
|
||||||
}
|
}
|
||||||
private void BtnColor_Click(object sender, EventArgs e)
|
private void BtnColor_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Button button = sender as Button;
|
Color newColor = (sender as Button).BackColor;
|
||||||
sketch.ChangePaintToolColor(button.BackColor);
|
Project.ChangeColor(SelectedLayers, newColor);
|
||||||
tmrRefresh_Tick(sender, e);
|
tmrRefresh_Tick(sender, e);
|
||||||
}
|
}
|
||||||
private string ColorToString(Color color)
|
private string ColorToString(Color color)
|
||||||
@@ -105,37 +90,46 @@ namespace Paint_2
|
|||||||
string result = "";
|
string result = "";
|
||||||
result += ColorPicker.ColorToHex(color);
|
result += ColorPicker.ColorToHex(color);
|
||||||
result += " ";
|
result += " ";
|
||||||
result += "R:" + color.R + " G:" + color.G + " B:" + color.B;
|
result += "R:" + color.R + " G:" + color.G + " B:" + color.B + " A:" + color.A;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private void ForceRefresh()
|
private void ForceRefresh()
|
||||||
{
|
{
|
||||||
canvas.Image = sketch.ForcePaint();
|
//canvas.Image = Project.ForcePaintAllLayers();
|
||||||
|
canvas.Image = Project.ForcePaintLayers();
|
||||||
RefreshUi();
|
RefreshUi();
|
||||||
}
|
}
|
||||||
private void RefreshUi()
|
private void RefreshUi()
|
||||||
{
|
{
|
||||||
canvas.Image = sketch.Paint();
|
lsbTools.DataSource = Project.AvaibleTools;
|
||||||
lblSelectedColor.Text = ColorToString(sketch.CurrentTool.Color);
|
//DebugLabel.Text = Project.PrintAllLayers();
|
||||||
btnSelectedColor.BackColor = sketch.CurrentTool.Color;
|
DebugLabel.Text = "";
|
||||||
hoveringColor = GetHoverColor();
|
|
||||||
lblHoveringColor.Text = ColorToString(hoveringColor);
|
|
||||||
btnHoveringColor.BackColor = hoveringColor;
|
|
||||||
|
|
||||||
List<Color> colorHistory = sketch.CurrentTool.GetLastColors(4);
|
//canvas.Image = Project.PaintAllLayers();
|
||||||
|
canvas.Image = Project.PaintLayers();
|
||||||
|
|
||||||
|
lblSelectedColor.Text = ColorToString(Project.GetCurrentToolColor(SelectedLayers));
|
||||||
|
btnSelectedColor.BackColor = Project.GetCurrentToolColor(SelectedLayers);
|
||||||
|
HoveringColor = GetHoverColor();
|
||||||
|
lblHoveringColor.Text = ColorToString(HoveringColor);
|
||||||
|
btnHoveringColor.BackColor = HoveringColor;
|
||||||
|
|
||||||
|
List<Color> colorHistory = Project.GetLayerColorHistory(SelectedLayers, 4);
|
||||||
btnColorHistory1.BackColor = colorHistory[0];
|
btnColorHistory1.BackColor = colorHistory[0];
|
||||||
|
btnColorHistory1.ForeColor = colorHistory[0];
|
||||||
btnColorHistory2.BackColor = colorHistory[1];
|
btnColorHistory2.BackColor = colorHistory[1];
|
||||||
|
btnColorHistory2.ForeColor = colorHistory[1];
|
||||||
btnColorHistory3.BackColor = colorHistory[2];
|
btnColorHistory3.BackColor = colorHistory[2];
|
||||||
|
btnColorHistory3.ForeColor = colorHistory[2];
|
||||||
btnColorHistory4.BackColor = colorHistory[3];
|
btnColorHistory4.BackColor = colorHistory[3];
|
||||||
|
btnColorHistory4.ForeColor = colorHistory[3];
|
||||||
lsbTools.DataSource = toolList;
|
|
||||||
|
|
||||||
lblWidth.Text = "W: " + canvas.Width.ToString();
|
lblWidth.Text = "W: " + canvas.Width.ToString();
|
||||||
lblHeight.Text = "H: " + canvas.Height.ToString();
|
lblHeight.Text = "H: " + canvas.Height.ToString();
|
||||||
|
|
||||||
pbxSample.Image = DrawSample(pbxSample.Size);
|
pbxSample.Image = DrawSample(pbxSample.Size);
|
||||||
|
|
||||||
if (randomColor)
|
if (Project.RandomColor)
|
||||||
{
|
{
|
||||||
btnRandomColor.BackColor = FLAT_GREEN;
|
btnRandomColor.BackColor = FLAT_GREEN;
|
||||||
}
|
}
|
||||||
@@ -143,7 +137,7 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
btnRandomColor.BackColor = FLAT_RED;
|
btnRandomColor.BackColor = FLAT_RED;
|
||||||
}
|
}
|
||||||
if (eyeDropping)
|
if (Project.Eyedropping)
|
||||||
{
|
{
|
||||||
btnEyeDrop.BackColor = FLAT_GREEN;
|
btnEyeDrop.BackColor = FLAT_GREEN;
|
||||||
}
|
}
|
||||||
@@ -156,8 +150,7 @@ 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));
|
||||||
gr.DrawLine(new Pen(sketch.CurrentTool.Color, sketch.CurrentTool.Width), new Point(0, 0), new Point(size.Width, size.Height));
|
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@@ -179,13 +172,14 @@ namespace Paint_2
|
|||||||
}
|
}
|
||||||
private void btnClear_Click(object sender, EventArgs e)
|
private void btnClear_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
sketch.Clear();
|
Project.Clear();
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void nupPencilWidth_ValueChanged(object sender, EventArgs e)
|
private void nupPencilWidth_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
sketch.ChangePaintToolWidth((int)nupPencilWidth.Value);
|
int newWidth = (int)nupPencilWidth.Value;
|
||||||
|
Project.ChangeWidth(SelectedLayers, newWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnSave_Click(object sender, EventArgs e)
|
private void btnSave_Click(object sender, EventArgs e)
|
||||||
@@ -193,86 +187,176 @@ namespace Paint_2
|
|||||||
string fileName = tbxProjectName.Text;
|
string fileName = tbxProjectName.Text;
|
||||||
Bitmap image = (Bitmap)canvas.Image;
|
Bitmap image = (Bitmap)canvas.Image;
|
||||||
|
|
||||||
if (!Directory.Exists(DEFAULT_FILEPATH))
|
Project.Save(fileName, image);
|
||||||
{
|
|
||||||
Directory.CreateDirectory(DEFAULT_FILEPATH);
|
|
||||||
}
|
|
||||||
if (!Directory.Exists(DEFAULT_FILEPATH + fileName))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(DEFAULT_FILEPATH + fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
image.Save(DEFAULT_FILEPATH + fileName + "/" + fileName + ".png", System.Drawing.Imaging.ImageFormat.Png);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnSaveCopy_Click(object sender, EventArgs e)
|
private void btnSaveCopy_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string fileName = tbxProjectName.Text;
|
string fileName = tbxProjectName.Text;
|
||||||
int version = 1;
|
|
||||||
Bitmap image = (Bitmap)canvas.Image;
|
Bitmap image = (Bitmap)canvas.Image;
|
||||||
|
|
||||||
if (!Directory.Exists(DEFAULT_FILEPATH))
|
Project.SaveCopy(fileName, image);
|
||||||
{
|
|
||||||
Directory.CreateDirectory(DEFAULT_FILEPATH);
|
|
||||||
}
|
|
||||||
if (!Directory.Exists(DEFAULT_FILEPATH + fileName))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(DEFAULT_FILEPATH + fileName);
|
|
||||||
}
|
|
||||||
while (File.Exists(DEFAULT_FILEPATH + fileName + "/" + fileName + version + ".png"))
|
|
||||||
{
|
|
||||||
version += 1;
|
|
||||||
}
|
|
||||||
image.Save(DEFAULT_FILEPATH + fileName + "/" + fileName + version + ".png", System.Drawing.Imaging.ImageFormat.Png);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lsbTools_SelectedIndexChanged(object sender, EventArgs e)
|
private void lsbTools_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
sketch.ChangeTool(lsbTools.SelectedIndex);
|
int toolId = lsbTools.SelectedIndex;
|
||||||
|
Project.ChangeTool(SelectedLayers, toolId);
|
||||||
RefreshUi();
|
RefreshUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PaintForm_Resize(object sender, EventArgs e)
|
private void PaintForm_Resize(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
canvas.Size = new Size(this.Width - (this.Width - panelTools.Location.X) - canvas.Location.X - WINDOW_OFFSET, this.Height - (this.Height - panelHoverColor.Location.Y) - WINDOW_OFFSET - (panelFile.Location.Y + panelFile.Height));
|
canvas.Size = new Size(this.Width - (this.Width - panelTools.Location.X) - canvas.Location.X - WINDOW_OFFSET, this.Height - (this.Height - panelHoverColor.Location.Y) - WINDOW_OFFSET - (panelFile.Location.Y + panelFile.Height));
|
||||||
sketch.Resize(canvas.Size);
|
Project.Resize(canvas.Size);
|
||||||
RefreshUi();
|
RefreshUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnRandomColor_Click(object sender, EventArgs e)
|
private void btnRandomColor_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
randomColor = !randomColor;
|
Project.SwitchRandom();
|
||||||
|
RefreshUi();
|
||||||
|
}
|
||||||
|
private void btnEyeDrop_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Project.SwitchEyeDrop();
|
||||||
RefreshUi();
|
RefreshUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnUndo_Click(object sender, EventArgs e)
|
private void btnUndo_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
sketch.Undo();
|
Project.Undo(SelectedLayers);
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnRedo_Click(object sender, EventArgs e)
|
private void btnRedo_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
sketch.Redo();
|
Project.Redo(SelectedLayers);
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnColorPicker_Click(object sender, EventArgs e)
|
private void btnColorPicker_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ColorPicker cp = new ColorPicker(this);
|
ColorPicker cp = new ColorPicker(this);
|
||||||
//ColorDialog cd = new ColorDialog();
|
|
||||||
cp.Show();
|
cp.Show();
|
||||||
//cd.ShowDialog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PaintForm_Load(object sender, EventArgs e)
|
private void PaintForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
//lsbTools.DataSource = Project.AvaibleTools;
|
||||||
|
//lsbLayers.DataSource = Project.Layers;
|
||||||
|
|
||||||
|
//lsbLayers.DataSource = Project.Layers[0].ToolList;
|
||||||
|
tmrRefresh.Enabled = true;
|
||||||
|
DisplayLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnEyeDrop_Click(object sender, EventArgs e)
|
private void btnLayerRemove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
eyeDropping = !eyeDropping;
|
//Project.RemoveLayer(lsbLayers.SelectedIndex);
|
||||||
|
//foreach (int id in SelectedLayers)
|
||||||
|
for(int id = 0;id < SelectedLayers.Count;id++)
|
||||||
|
{
|
||||||
|
SelectedLayers.Remove(id);
|
||||||
|
Project.RemoveLayer(id);
|
||||||
|
}
|
||||||
|
DisplayLayers();
|
||||||
|
RefreshUi();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BtnAddLayer_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Project.AddLayer();
|
||||||
|
DisplayLayers();
|
||||||
|
RefreshUi();
|
||||||
|
}
|
||||||
|
//This is the only really non MVC method
|
||||||
|
private void DisplayLayers()
|
||||||
|
{
|
||||||
|
int Yoffset = 25;
|
||||||
|
int Xoffset = 10;
|
||||||
|
|
||||||
|
int blocsCount = 1;
|
||||||
|
int btnWidth = 75;
|
||||||
|
int labelWidth = 70;
|
||||||
|
int BtnXoffset = labelWidth;
|
||||||
|
int ChkXOffset = BtnXoffset + btnWidth + Xoffset /2;
|
||||||
|
int ChkWidth = 20;
|
||||||
|
|
||||||
|
pnlLayers.Controls.Clear();
|
||||||
|
|
||||||
|
foreach (Sketch layer in Project.Layers)
|
||||||
|
{
|
||||||
|
Label name = new Label();
|
||||||
|
name.AutoSize = false;
|
||||||
|
name.Width = labelWidth;
|
||||||
|
name.Text = layer.Name;
|
||||||
|
name.BackColor = Color.Transparent;
|
||||||
|
pnlLayers.Controls.Add(name);
|
||||||
|
name.Location = new Point(0,blocsCount * Yoffset);
|
||||||
|
|
||||||
|
Button btn = new Button();
|
||||||
|
btn.Name = (blocsCount - 1).ToString();
|
||||||
|
btn.Click += LayerSelection;
|
||||||
|
if (Project.LayersToPrint.Contains(Convert.ToInt32(btn.Name)))
|
||||||
|
{
|
||||||
|
btn.Text = "Visible";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btn.Text = "Invisible";
|
||||||
|
}
|
||||||
|
pnlLayers.Controls.Add(btn);
|
||||||
|
btn.BackColor = Color.FromArgb(59, 59, 59);
|
||||||
|
btn.Location = new Point(BtnXoffset,blocsCount * Yoffset);
|
||||||
|
btn.Width = btnWidth;
|
||||||
|
btn.FlatStyle = FlatStyle.Popup;
|
||||||
|
|
||||||
|
Button chk = new Button();
|
||||||
|
chk.Click += LayerCheck;
|
||||||
|
if (SelectedLayers.Contains(blocsCount-1))
|
||||||
|
{
|
||||||
|
chk.BackColor = Color.Green;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chk.BackColor = Color.Red;
|
||||||
|
}
|
||||||
|
pnlLayers.Controls.Add(chk);
|
||||||
|
chk.Location = new Point(ChkXOffset, blocsCount * Yoffset);
|
||||||
|
chk.AutoSize = false;
|
||||||
|
chk.Text = "";
|
||||||
|
chk.FlatStyle = FlatStyle.Popup;
|
||||||
|
chk.Width = ChkWidth;
|
||||||
|
chk.Name = "C" + (blocsCount -1).ToString();
|
||||||
|
|
||||||
|
blocsCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LayerSelection(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//We assume that the id of the layer is the name of the button
|
||||||
|
Button btn = sender as Button;
|
||||||
|
int id = Convert.ToInt32(btn.Name);
|
||||||
|
Project.SwitchLayer(id);
|
||||||
|
DisplayLayers();
|
||||||
|
}
|
||||||
|
private void LayerCheck(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//We assume that the id of the layer is the name with the 'c' removed
|
||||||
|
Button btn = sender as Button;
|
||||||
|
string cleanedName = btn.Name.Remove(0,1);
|
||||||
|
int id = Convert.ToInt32(cleanedName);
|
||||||
|
//MessageBox.Show("Select or Deslect layer "+id);
|
||||||
|
if (SelectedLayers.Contains(id))
|
||||||
|
{
|
||||||
|
SelectedLayers.Remove(id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SelectedLayers.Add(id);
|
||||||
|
}
|
||||||
|
DisplayLayers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ using System.Drawing;
|
|||||||
|
|
||||||
namespace Paint_2
|
namespace Paint_2
|
||||||
{
|
{
|
||||||
public interface PaintTool
|
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; }
|
||||||
@@ -26,7 +26,7 @@ namespace Paint_2
|
|||||||
string Name { get; set; }
|
string Name { get; set; }
|
||||||
|
|
||||||
void Start(Color color, int width);
|
void Start(Color color, int width);
|
||||||
Bitmap Stop(Bitmap bmp);
|
void Stop();
|
||||||
void Add(Point point);
|
void Add(Point point);
|
||||||
void Undo();
|
void Undo();
|
||||||
void Redo();
|
void Redo();
|
||||||
|
|||||||
@@ -101,6 +101,5 @@ namespace Paint_2
|
|||||||
Point result = new Point(resultX, resultY);
|
Point result = new Point(resultX, resultY);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
<Compile Include="PaintToolUtils.cs" />
|
<Compile Include="PaintToolUtils.cs" />
|
||||||
<Compile Include="Pencil.cs" />
|
<Compile Include="Pencil.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Project.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Sketch.cs" />
|
<Compile Include="Sketch.cs" />
|
||||||
<EmbeddedResource Include="ColorPicker.resx">
|
<EmbeddedResource Include="ColorPicker.resx">
|
||||||
|
|||||||
@@ -83,14 +83,12 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
Utils.StandartClear();
|
Utils.StandartClear();
|
||||||
}
|
}
|
||||||
public Bitmap Stop(Bitmap bmp)
|
public void Stop()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Drawings.Count; i++)
|
for (int i = 0; i < Drawings.Count; i++)
|
||||||
{
|
{
|
||||||
List<Point> Drawing = Drawings[i];
|
List<Point> Drawing = Drawings[i];
|
||||||
//bmp = PostProcessing(Drawing, bmp, Widths[i]);
|
|
||||||
}
|
}
|
||||||
return bmp;
|
|
||||||
}
|
}
|
||||||
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
|
private Bitmap PostProcessing(List<Point> Drawing, Bitmap bmp, int width, Color color)
|
||||||
{
|
{
|
||||||
@@ -114,5 +112,13 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
Utils.StandartRedo();
|
Utils.StandartRedo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
Pencil result = new Pencil(Name);
|
||||||
|
result.Width = Width;
|
||||||
|
result.Color = Color;
|
||||||
|
return (Object)(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
344
Paint_2/Project.cs
Normal file
344
Paint_2/Project.cs
Normal file
@@ -0,0 +1,344 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Paint_2
|
||||||
|
{
|
||||||
|
public class Project
|
||||||
|
{
|
||||||
|
const string DEFAULT_FILEPATH = "C:/Paint2/Drawings/";
|
||||||
|
readonly Color DEFAULT_COLOR = Color.Firebrick;
|
||||||
|
const int DEFAULT_WIDTH = 0;
|
||||||
|
|
||||||
|
private List<PaintTool> _avaibleTools;
|
||||||
|
private List<int> _selectedLayers;
|
||||||
|
//private Sketch _currentSketch;
|
||||||
|
private List<Sketch> _layers;
|
||||||
|
private bool _eyedropping;
|
||||||
|
private bool _randomColor;
|
||||||
|
private Size _canvasSize;
|
||||||
|
private Random _random;
|
||||||
|
private bool _drawing;
|
||||||
|
private string _name;
|
||||||
|
|
||||||
|
public List<PaintTool> AvaibleTools { get => _avaibleTools; set => _avaibleTools = value; }
|
||||||
|
//public Sketch CurrentLayer { get => _currentSketch; set => _currentSketch = value; }
|
||||||
|
public List<Sketch> Layers { get => _layers; set => _layers = value; }
|
||||||
|
public bool Eyedropping { get => _eyedropping; set => _eyedropping = value; }
|
||||||
|
public bool RandomColor { get => _randomColor; set => _randomColor = value; }
|
||||||
|
public Size CanvasSize { get => _canvasSize; set => _canvasSize = value; }
|
||||||
|
public Random Random { get => _random; set => _random = value; }
|
||||||
|
public bool Drawing { get => _drawing; set => _drawing = value; }
|
||||||
|
public string Name { get => _name; set => _name = value; }
|
||||||
|
public List<int> LayersToPrint { get => _selectedLayers; set => _selectedLayers = value; }
|
||||||
|
|
||||||
|
public Project(string name, Size canvasSize)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
CanvasSize = canvasSize;
|
||||||
|
Random = new Random();
|
||||||
|
//We set all the avaible tools at first
|
||||||
|
AvaibleTools = new List<PaintTool>();
|
||||||
|
AvaibleTools.Add(new Pencil("Default Pencil"));
|
||||||
|
AvaibleTools.Add(new DotPencil("Dotted Line"));
|
||||||
|
AvaibleTools.Add(new BezierPencil("Bezier Generator"));
|
||||||
|
//We create a single first layer with the default toolSet
|
||||||
|
Layers = new List<Sketch>();
|
||||||
|
AddLayer();
|
||||||
|
//CurrentLayer = Layers[0];
|
||||||
|
LayersToPrint = new List<int>();
|
||||||
|
LayersToPrint.Add(0);
|
||||||
|
}
|
||||||
|
public void AddLayer()
|
||||||
|
{
|
||||||
|
List<PaintTool> newTools = new List<PaintTool>();
|
||||||
|
foreach (PaintTool tool in AvaibleTools)
|
||||||
|
{
|
||||||
|
newTools.Add((PaintTool)tool.Clone());
|
||||||
|
}
|
||||||
|
Layers.Add(new Sketch(String.Concat("Layer", Layers.Count + 1), CanvasSize, newTools));
|
||||||
|
}
|
||||||
|
public void RemoveLayer(int layerId)
|
||||||
|
{
|
||||||
|
if (layerId >= 0 && layerId < Layers.Count)
|
||||||
|
{
|
||||||
|
Layers.RemoveAt(layerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
public void ChangeLayer(int idLayer)
|
||||||
|
{
|
||||||
|
CurrentLayer = Layers[idLayer];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
public List<Sketch> GetAllLayers()
|
||||||
|
{
|
||||||
|
return Layers;
|
||||||
|
}
|
||||||
|
public void SwitchLayer(int idLayer)
|
||||||
|
{
|
||||||
|
if (LayersToPrint.Contains(idLayer))
|
||||||
|
{
|
||||||
|
LayersToPrint.Remove(idLayer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LayersToPrint.Add(idLayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void MouseDown(List<int> selectedLayers, Color hoveringColor, Point mousePosition, int toolWidth)
|
||||||
|
{
|
||||||
|
for (int layer = 0; layer < Layers.Count; layer++)
|
||||||
|
{
|
||||||
|
if (selectedLayers.Contains(layer))
|
||||||
|
{
|
||||||
|
if (Eyedropping)
|
||||||
|
{
|
||||||
|
Color pointedColor = hoveringColor;
|
||||||
|
if (Layers[layer].CurrentTool.Color != pointedColor)
|
||||||
|
{
|
||||||
|
Layers[layer].ChangePaintToolColor(pointedColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Drawing = true;
|
||||||
|
if (RandomColor)
|
||||||
|
{
|
||||||
|
Layers[layer].StartDrawing(mousePosition, Color.FromArgb(Random.Next(0, 256), Random.Next(0, 256), Random.Next(0, 256)), toolWidth);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Layers[layer].StartDrawing(mousePosition, Layers[layer].CurrentTool.Color, toolWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public void MouseUp(List<int> selectedLayers, Point mousePosition)
|
||||||
|
{
|
||||||
|
for (int layer = 0; layer < Layers.Count; layer++)
|
||||||
|
{
|
||||||
|
if (selectedLayers.Contains(layer))
|
||||||
|
{
|
||||||
|
if (!Eyedropping)
|
||||||
|
{
|
||||||
|
Layers[layer].AddDrawingPoint(mousePosition);
|
||||||
|
Drawing = false;
|
||||||
|
Layers[layer].StopDrawing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void TimerTick(List<int> selectedLayers, Point mousePosition)
|
||||||
|
{
|
||||||
|
for (int layer = 0; layer < Layers.Count; layer++)
|
||||||
|
{
|
||||||
|
if (selectedLayers.Contains(layer))
|
||||||
|
{
|
||||||
|
if (Drawing)
|
||||||
|
{
|
||||||
|
Layers[layer].AddDrawingPoint(mousePosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public void ChangeColor(List<int> selectedLayers, Color newColor)
|
||||||
|
{
|
||||||
|
for (int layer = 0; layer < Layers.Count; layer++)
|
||||||
|
{
|
||||||
|
if (selectedLayers.Contains(layer))
|
||||||
|
{
|
||||||
|
Layers[layer].ChangePaintToolColor(newColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void ChangeWidth(List<int> selectedLayers, int width)
|
||||||
|
{
|
||||||
|
for (int layer = 0; layer < Layers.Count; layer++)
|
||||||
|
{
|
||||||
|
if (selectedLayers.Contains(layer))
|
||||||
|
{
|
||||||
|
Layers[layer].ChangePaintToolWidth(width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void ChangeTool(List<int> selectedLayers, int toolId)
|
||||||
|
{
|
||||||
|
for (int layer = 0; layer < Layers.Count; layer++)
|
||||||
|
{
|
||||||
|
if (selectedLayers.Contains(layer))
|
||||||
|
{
|
||||||
|
Layers[layer].ChangeTool(toolId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Bitmap ForcePaintAllLayers()
|
||||||
|
{
|
||||||
|
Bitmap result = new Bitmap(CanvasSize.Width, CanvasSize.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(result);
|
||||||
|
foreach (Sketch layer in Layers)
|
||||||
|
{
|
||||||
|
gr.DrawImage(layer.ForcePaint(), Point.Empty);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public Bitmap ForcePaintLayers()
|
||||||
|
{
|
||||||
|
Bitmap result = new Bitmap(CanvasSize.Width, CanvasSize.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(result);
|
||||||
|
for (int layer = 0; layer < Layers.Count; layer++)
|
||||||
|
{
|
||||||
|
if (LayersToPrint.Contains(layer))
|
||||||
|
{
|
||||||
|
gr.DrawImage(Layers[layer].ForcePaint(), Point.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public Bitmap PaintAllLayers()
|
||||||
|
{
|
||||||
|
Bitmap result = new Bitmap(CanvasSize.Width, CanvasSize.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(result);
|
||||||
|
foreach (Sketch layer in Layers)
|
||||||
|
{
|
||||||
|
gr.DrawImage(layer.Paint(), Point.Empty);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public Bitmap PaintLayers()
|
||||||
|
{
|
||||||
|
Bitmap result = new Bitmap(CanvasSize.Width, CanvasSize.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(result);
|
||||||
|
for (int layer = 0; layer < Layers.Count; layer++)
|
||||||
|
{
|
||||||
|
if (LayersToPrint.Contains(layer))
|
||||||
|
{
|
||||||
|
gr.DrawImage(Layers[layer].Paint(), Point.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
foreach (Sketch layer in Layers)
|
||||||
|
{
|
||||||
|
layer.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Color GetCurrentToolColor(List<int> selectedLayers)
|
||||||
|
{
|
||||||
|
if(selectedLayers.Count == 0)
|
||||||
|
{
|
||||||
|
return DEFAULT_COLOR;
|
||||||
|
}
|
||||||
|
Sketch CurrentLayer = Layers[selectedLayers[0]];
|
||||||
|
return CurrentLayer.CurrentTool.Color;
|
||||||
|
}
|
||||||
|
public int GetCurrentToolWidth(List<int> selectedLayers)
|
||||||
|
{
|
||||||
|
if (selectedLayers.Count == 0)
|
||||||
|
{
|
||||||
|
return DEFAULT_WIDTH;
|
||||||
|
}
|
||||||
|
Sketch CurrentLayer = Layers[selectedLayers[0]];
|
||||||
|
return CurrentLayer.CurrentTool.Width;
|
||||||
|
}
|
||||||
|
public List<Color> GetLayerColorHistory(List<int> selectedLayers,int colorsCount)
|
||||||
|
{
|
||||||
|
if(selectedLayers.Count == 0)
|
||||||
|
{
|
||||||
|
List<Color> result = new List<Color>();
|
||||||
|
for (int i = 0;i < colorsCount;i++)
|
||||||
|
{
|
||||||
|
result.Add(DEFAULT_COLOR);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sketch CurrentLayer = Layers[selectedLayers[0]];
|
||||||
|
return CurrentLayer.CurrentTool.GetLastColors(colorsCount);
|
||||||
|
}
|
||||||
|
public void Save(string fileName, Bitmap image)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(DEFAULT_FILEPATH))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(DEFAULT_FILEPATH);
|
||||||
|
}
|
||||||
|
if (!Directory.Exists(DEFAULT_FILEPATH + fileName))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(DEFAULT_FILEPATH + fileName);
|
||||||
|
}
|
||||||
|
image.Save(DEFAULT_FILEPATH + fileName + "/" + fileName + ".png", System.Drawing.Imaging.ImageFormat.Png);
|
||||||
|
}
|
||||||
|
public void SaveCopy(string fileName, Bitmap image)
|
||||||
|
{
|
||||||
|
int version = 1;
|
||||||
|
if (!Directory.Exists(DEFAULT_FILEPATH))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(DEFAULT_FILEPATH);
|
||||||
|
}
|
||||||
|
if (!Directory.Exists(DEFAULT_FILEPATH + fileName))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(DEFAULT_FILEPATH + fileName);
|
||||||
|
}
|
||||||
|
while (File.Exists(DEFAULT_FILEPATH + fileName + "/" + fileName + version + ".png"))
|
||||||
|
{
|
||||||
|
version += 1;
|
||||||
|
}
|
||||||
|
image.Save(DEFAULT_FILEPATH + fileName + "/" + fileName + version + ".png", System.Drawing.Imaging.ImageFormat.Png);
|
||||||
|
}
|
||||||
|
public void Resize(Size newSize)
|
||||||
|
{
|
||||||
|
CanvasSize = newSize;
|
||||||
|
foreach (Sketch layer in Layers)
|
||||||
|
{
|
||||||
|
layer.Resize(CanvasSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void SwitchRandom()
|
||||||
|
{
|
||||||
|
RandomColor = !RandomColor;
|
||||||
|
}
|
||||||
|
public void SwitchEyeDrop()
|
||||||
|
{
|
||||||
|
Eyedropping = !Eyedropping;
|
||||||
|
}
|
||||||
|
public void Undo(List<int> selectedLayers)
|
||||||
|
{
|
||||||
|
for (int layer = 0; layer < Layers.Count; layer++)
|
||||||
|
{
|
||||||
|
if (selectedLayers.Contains(layer))
|
||||||
|
{
|
||||||
|
Layers[layer].Undo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Redo(List<int> selectedLayers)
|
||||||
|
{
|
||||||
|
for (int layer = 0; layer < Layers.Count; layer++)
|
||||||
|
{
|
||||||
|
if (selectedLayers.Contains(layer))
|
||||||
|
{
|
||||||
|
Layers[layer].Redo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string PrintAllLayers()
|
||||||
|
{
|
||||||
|
string result = "";
|
||||||
|
foreach (Sketch layer in Layers)
|
||||||
|
{
|
||||||
|
result += layer.Name;
|
||||||
|
result += Environment.NewLine;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,9 +28,10 @@ namespace Paint_2
|
|||||||
public Size SketchSize { get => _sketchSize; set => _sketchSize = value; }
|
public Size SketchSize { get => _sketchSize; set => _sketchSize = value; }
|
||||||
public string Name { get => _name; set => _name = value; }
|
public string Name { get => _name; set => _name = value; }
|
||||||
|
|
||||||
public Sketch(Size sketchSize, List<PaintTool> toolList)
|
public Sketch(string name,Size sketchSize, List<PaintTool> toolList)
|
||||||
{
|
{
|
||||||
IsDrawing = false;
|
IsDrawing = false;
|
||||||
|
Name = name;
|
||||||
SketchSize = sketchSize;
|
SketchSize = sketchSize;
|
||||||
Drawing = new Bitmap(SketchSize.Width, SketchSize.Height);
|
Drawing = new Bitmap(SketchSize.Width, SketchSize.Height);
|
||||||
ToolList = toolList;
|
ToolList = toolList;
|
||||||
@@ -48,7 +49,7 @@ namespace Paint_2
|
|||||||
CurrentTool = null;
|
CurrentTool = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Sketch(List<PaintTool> toolList) : this(new Size(500, 500), toolList)
|
public Sketch(List<PaintTool> toolList) : this("Layer 1",new Size(500, 500), toolList)
|
||||||
{
|
{
|
||||||
//empty
|
//empty
|
||||||
}
|
}
|
||||||
@@ -92,10 +93,9 @@ namespace Paint_2
|
|||||||
{
|
{
|
||||||
CurrentTool.Start(CurrentTool.Color, width);
|
CurrentTool.Start(CurrentTool.Color, width);
|
||||||
}
|
}
|
||||||
public Bitmap StopDrawing(Bitmap bmp)
|
public void StopDrawing()
|
||||||
{
|
{
|
||||||
bmp = CurrentTool.Stop(bmp);
|
CurrentTool.Stop();
|
||||||
return bmp;
|
|
||||||
}
|
}
|
||||||
public void AddDrawingPoint(Point location)
|
public void AddDrawingPoint(Point location)
|
||||||
{
|
{
|
||||||
@@ -127,5 +127,9 @@ namespace Paint_2
|
|||||||
//Todo
|
//Todo
|
||||||
return Color.FromArgb(0x34, 0xF4, 0xFF);
|
return Color.FromArgb(0x34, 0xF4, 0xFF);
|
||||||
}
|
}
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user