Added Resizable canvas

This commit is contained in:
2022-05-30 14:58:51 +02:00
parent dc9e6daafa
commit 77f940c201
3 changed files with 193 additions and 207 deletions

View File

@@ -34,19 +34,16 @@
this.canvas = new System.Windows.Forms.PictureBox();
this.btnSaveCopy = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.btnResize = new System.Windows.Forms.Button();
this.nupHeight = new System.Windows.Forms.NumericUpDown();
this.nupWidth = new System.Windows.Forms.NumericUpDown();
this.lblSelectedColor = new System.Windows.Forms.Label();
this.btnImportImage = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.panelFile = new System.Windows.Forms.Panel();
this.label10 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.panelDrawing = new System.Windows.Forms.Panel();
this.label11 = new System.Windows.Forms.Label();
this.panel4 = new System.Windows.Forms.Panel();
this.panelSelectedColor = new System.Windows.Forms.Panel();
this.btnSelectedColor = new System.Windows.Forms.Button();
this.label14 = new System.Windows.Forms.Label();
this.panel5 = new System.Windows.Forms.Panel();
this.panelHoverColor = new System.Windows.Forms.Panel();
this.btnHoveringColor = new System.Windows.Forms.Button();
this.lblHoveringColor = new System.Windows.Forms.Label();
this.label15 = new System.Windows.Forms.Label();
@@ -70,21 +67,21 @@
this.label13 = new System.Windows.Forms.Label();
this.btnSetColor = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.panel3 = new System.Windows.Forms.Panel();
this.lsbTools = new System.Windows.Forms.ListBox();
this.panelTools = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.lsbTools = new System.Windows.Forms.ListBox();
this.lblWidth = new System.Windows.Forms.Label();
this.lblHeight = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.canvas)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupHeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupWidth)).BeginInit();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.panel4.SuspendLayout();
this.panel5.SuspendLayout();
this.panelFile.SuspendLayout();
this.panelDrawing.SuspendLayout();
this.panelSelectedColor.SuspendLayout();
this.panelHoverColor.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nupGreen)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupBlue)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupRed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupPencilWidth)).BeginInit();
this.panel3.SuspendLayout();
this.panelTools.SuspendLayout();
this.SuspendLayout();
//
// tbxProjectName
@@ -95,7 +92,7 @@
this.tbxProjectName.Location = new System.Drawing.Point(10, 24);
this.tbxProjectName.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
this.tbxProjectName.Name = "tbxProjectName";
this.tbxProjectName.Size = new System.Drawing.Size(230, 27);
this.tbxProjectName.Size = new System.Drawing.Size(230, 23);
this.tbxProjectName.TabIndex = 0;
this.tbxProjectName.Text = "Untitled Project";
//
@@ -144,74 +141,22 @@
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 22);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(110, 22);
this.label1.Size = new System.Drawing.Size(88, 18);
this.label1.TabIndex = 5;
this.label1.Text = "Dimensions";
//
// btnResize
//
this.btnResize.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.btnResize.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnResize.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.btnResize.Location = new System.Drawing.Point(304, 14);
this.btnResize.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
this.btnResize.Name = "btnResize";
this.btnResize.Size = new System.Drawing.Size(94, 38);
this.btnResize.TabIndex = 3;
this.btnResize.Text = "Resize";
this.btnResize.UseVisualStyleBackColor = false;
//
// nupHeight
//
this.nupHeight.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.nupHeight.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupHeight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.nupHeight.Location = new System.Drawing.Point(213, 22);
this.nupHeight.Maximum = new decimal(new int[] {
10000,
0,
0,
0});
this.nupHeight.Name = "nupHeight";
this.nupHeight.Size = new System.Drawing.Size(86, 23);
this.nupHeight.TabIndex = 5;
this.nupHeight.Value = new decimal(new int[] {
710,
0,
0,
0});
//
// nupWidth
//
this.nupWidth.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.nupWidth.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nupWidth.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.nupWidth.Location = new System.Drawing.Point(122, 23);
this.nupWidth.Maximum = new decimal(new int[] {
10000,
0,
0,
0});
this.nupWidth.Name = "nupWidth";
this.nupWidth.Size = new System.Drawing.Size(85, 23);
this.nupWidth.TabIndex = 4;
this.nupWidth.Value = new decimal(new int[] {
1100,
0,
0,
0});
//
// lblSelectedColor
//
this.lblSelectedColor.AutoSize = true;
this.lblSelectedColor.Location = new System.Drawing.Point(6, 22);
this.lblSelectedColor.Name = "lblSelectedColor";
this.lblSelectedColor.Size = new System.Drawing.Size(290, 22);
this.lblSelectedColor.Size = new System.Drawing.Size(232, 18);
this.lblSelectedColor.TabIndex = 1;
this.lblSelectedColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
//
// btnImportImage
//
this.btnImportImage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnImportImage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.btnImportImage.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnImportImage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
@@ -223,17 +168,17 @@
this.btnImportImage.Text = "Import Image";
this.btnImportImage.UseVisualStyleBackColor = false;
//
// panel1
// panelFile
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.panel1.Controls.Add(this.label10);
this.panel1.Controls.Add(this.btnSaveCopy);
this.panel1.Controls.Add(this.tbxProjectName);
this.panel1.Controls.Add(this.btnSave);
this.panel1.Location = new System.Drawing.Point(12, 7);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(493, 60);
this.panel1.TabIndex = 8;
this.panelFile.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.panelFile.Controls.Add(this.label10);
this.panelFile.Controls.Add(this.btnSaveCopy);
this.panelFile.Controls.Add(this.tbxProjectName);
this.panelFile.Controls.Add(this.btnSave);
this.panelFile.Location = new System.Drawing.Point(12, 7);
this.panelFile.Name = "panelFile";
this.panelFile.Size = new System.Drawing.Size(493, 60);
this.panelFile.TabIndex = 8;
//
// label10
//
@@ -241,22 +186,21 @@
this.label10.Font = new System.Drawing.Font("Cascadia Code", 10F);
this.label10.Location = new System.Drawing.Point(6, 0);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(50, 22);
this.label10.Size = new System.Drawing.Size(40, 18);
this.label10.TabIndex = 29;
this.label10.Text = "File";
//
// panel2
// panelDrawing
//
this.panel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.panel2.Controls.Add(this.label1);
this.panel2.Controls.Add(this.btnResize);
this.panel2.Controls.Add(this.label11);
this.panel2.Controls.Add(this.nupHeight);
this.panel2.Controls.Add(this.nupWidth);
this.panel2.Location = new System.Drawing.Point(511, 7);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(410, 60);
this.panel2.TabIndex = 30;
this.panelDrawing.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.panelDrawing.Controls.Add(this.lblHeight);
this.panelDrawing.Controls.Add(this.label1);
this.panelDrawing.Controls.Add(this.lblWidth);
this.panelDrawing.Controls.Add(this.label11);
this.panelDrawing.Location = new System.Drawing.Point(511, 7);
this.panelDrawing.Name = "panelDrawing";
this.panelDrawing.Size = new System.Drawing.Size(228, 47);
this.panelDrawing.TabIndex = 30;
//
// label11
//
@@ -264,20 +208,21 @@
this.label11.Font = new System.Drawing.Font("Cascadia Code", 10F);
this.label11.Location = new System.Drawing.Point(6, 0);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(80, 22);
this.label11.Size = new System.Drawing.Size(64, 18);
this.label11.TabIndex = 29;
this.label11.Text = "Drawing";
//
// panel4
// panelSelectedColor
//
this.panel4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.panel4.Controls.Add(this.btnSelectedColor);
this.panel4.Controls.Add(this.lblSelectedColor);
this.panel4.Controls.Add(this.label14);
this.panel4.Location = new System.Drawing.Point(382, 606);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(363, 50);
this.panel4.TabIndex = 31;
this.panelSelectedColor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.panelSelectedColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.panelSelectedColor.Controls.Add(this.btnSelectedColor);
this.panelSelectedColor.Controls.Add(this.lblSelectedColor);
this.panelSelectedColor.Controls.Add(this.label14);
this.panelSelectedColor.Location = new System.Drawing.Point(382, 606);
this.panelSelectedColor.Name = "panelSelectedColor";
this.panelSelectedColor.Size = new System.Drawing.Size(363, 50);
this.panelSelectedColor.TabIndex = 31;
//
// btnSelectedColor
//
@@ -296,20 +241,21 @@
this.label14.Font = new System.Drawing.Font("Cascadia Code", 10F);
this.label14.Location = new System.Drawing.Point(6, 0);
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.Text = "Selected color";
//
// panel5
// panelHoverColor
//
this.panel5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.panel5.Controls.Add(this.btnHoveringColor);
this.panel5.Controls.Add(this.lblHoveringColor);
this.panel5.Controls.Add(this.label15);
this.panel5.Location = new System.Drawing.Point(12, 606);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(370, 50);
this.panel5.TabIndex = 32;
this.panelHoverColor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.panelHoverColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.panelHoverColor.Controls.Add(this.btnHoveringColor);
this.panelHoverColor.Controls.Add(this.lblHoveringColor);
this.panelHoverColor.Controls.Add(this.label15);
this.panelHoverColor.Location = new System.Drawing.Point(12, 606);
this.panelHoverColor.Name = "panelHoverColor";
this.panelHoverColor.Size = new System.Drawing.Size(370, 50);
this.panelHoverColor.TabIndex = 32;
//
// btnHoveringColor
//
@@ -327,7 +273,7 @@
this.lblHoveringColor.AutoSize = true;
this.lblHoveringColor.Location = new System.Drawing.Point(6, 22);
this.lblHoveringColor.Name = "lblHoveringColor";
this.lblHoveringColor.Size = new System.Drawing.Size(290, 22);
this.lblHoveringColor.Size = new System.Drawing.Size(232, 18);
this.lblHoveringColor.TabIndex = 1;
this.lblHoveringColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
//
@@ -337,7 +283,7 @@
this.label15.Font = new System.Drawing.Font("Cascadia Code", 10F);
this.label15.Location = new System.Drawing.Point(6, 0);
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.Text = "Hovering color";
//
@@ -359,7 +305,7 @@
0,
0});
this.nupGreen.Name = "nupGreen";
this.nupGreen.Size = new System.Drawing.Size(85, 21);
this.nupGreen.Size = new System.Drawing.Size(85, 17);
this.nupGreen.TabIndex = 14;
this.nupGreen.Value = new decimal(new int[] {
255,
@@ -380,7 +326,7 @@
0,
0});
this.nupBlue.Name = "nupBlue";
this.nupBlue.Size = new System.Drawing.Size(85, 21);
this.nupBlue.Size = new System.Drawing.Size(85, 17);
this.nupBlue.TabIndex = 15;
this.nupBlue.Value = new decimal(new int[] {
255,
@@ -401,7 +347,7 @@
0,
0});
this.nupRed.Name = "nupRed";
this.nupRed.Size = new System.Drawing.Size(85, 21);
this.nupRed.Size = new System.Drawing.Size(85, 17);
this.nupRed.TabIndex = 13;
this.nupRed.Value = new decimal(new int[] {
255,
@@ -422,7 +368,7 @@
0,
0});
this.nupPencilWidth.Name = "nupPencilWidth";
this.nupPencilWidth.Size = new System.Drawing.Size(141, 21);
this.nupPencilWidth.Size = new System.Drawing.Size(141, 17);
this.nupPencilWidth.TabIndex = 17;
this.nupPencilWidth.Value = new decimal(new int[] {
10,
@@ -437,7 +383,7 @@
this.label7.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label7.Location = new System.Drawing.Point(10, 144);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(36, 20);
this.label7.Size = new System.Drawing.Size(28, 16);
this.label7.TabIndex = 12;
this.label7.Text = "RGB";
//
@@ -447,7 +393,7 @@
this.label8.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label8.Location = new System.Drawing.Point(30, 257);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(99, 20);
this.label8.Size = new System.Drawing.Size(77, 16);
this.label8.TabIndex = 18;
this.label8.Text = "Set pencil";
//
@@ -457,7 +403,7 @@
this.label6.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label6.Location = new System.Drawing.Point(10, 93);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(36, 20);
this.label6.Size = new System.Drawing.Size(28, 16);
this.label6.TabIndex = 11;
this.label6.Text = "Hex";
//
@@ -467,7 +413,7 @@
this.label9.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label9.Location = new System.Drawing.Point(10, 286);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(54, 20);
this.label9.Size = new System.Drawing.Size(42, 16);
this.label9.TabIndex = 19;
this.label9.Text = "Width";
//
@@ -477,7 +423,7 @@
this.label5.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point(30, 73);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(90, 20);
this.label5.Size = new System.Drawing.Size(70, 16);
this.label5.TabIndex = 9;
this.label5.Text = "Set color";
//
@@ -523,7 +469,7 @@
this.label4.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(10, 25);
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.Text = "Colors history";
//
@@ -547,19 +493,20 @@
this.tbxColorHex.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.tbxColorHex.Location = new System.Drawing.Point(10, 116);
this.tbxColorHex.Name = "tbxColorHex";
this.tbxColorHex.Size = new System.Drawing.Size(85, 25);
this.tbxColorHex.Size = new System.Drawing.Size(85, 21);
this.tbxColorHex.TabIndex = 10;
this.tbxColorHex.Text = "#FFFFFF";
//
// btnClear
//
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)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.btnClear.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnClear.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnClear.Font = new System.Drawing.Font("Cascadia Code", 10.5F);
this.btnClear.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.btnClear.Location = new System.Drawing.Point(10, 599);
this.btnClear.Location = new System.Drawing.Point(926, 606);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(147, 31);
this.btnClear.Size = new System.Drawing.Size(163, 48);
this.btnClear.TabIndex = 27;
this.btnClear.Text = "Clear";
this.btnClear.UseVisualStyleBackColor = false;
@@ -571,7 +518,7 @@
this.label13.Font = new System.Drawing.Font("Cascadia Code", 10F);
this.label13.Location = new System.Drawing.Point(6, 0);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(60, 22);
this.label13.Size = new System.Drawing.Size(48, 18);
this.label13.TabIndex = 29;
this.label13.Text = "Tools";
//
@@ -603,47 +550,34 @@
this.button1.UseVisualStyleBackColor = false;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// panel3
// panelTools
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.panel3.Controls.Add(this.label2);
this.panel3.Controls.Add(this.lsbTools);
this.panel3.Controls.Add(this.button1);
this.panel3.Controls.Add(this.btnSetColor);
this.panel3.Controls.Add(this.label13);
this.panel3.Controls.Add(this.btnClear);
this.panel3.Controls.Add(this.tbxColorHex);
this.panel3.Controls.Add(this.btnColorHistory1);
this.panel3.Controls.Add(this.label4);
this.panel3.Controls.Add(this.btnColorHistory2);
this.panel3.Controls.Add(this.btnColorHistory3);
this.panel3.Controls.Add(this.btnColorHistory4);
this.panel3.Controls.Add(this.label5);
this.panel3.Controls.Add(this.label9);
this.panel3.Controls.Add(this.label6);
this.panel3.Controls.Add(this.label8);
this.panel3.Controls.Add(this.label7);
this.panel3.Controls.Add(this.nupPencilWidth);
this.panel3.Controls.Add(this.nupRed);
this.panel3.Controls.Add(this.nupBlue);
this.panel3.Controls.Add(this.nupGreen);
this.panel3.Location = new System.Drawing.Point(926, 12);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(163, 642);
this.panel3.TabIndex = 31;
//
// lsbTools
//
this.lsbTools.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.lsbTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lsbTools.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.lsbTools.FormattingEnabled = true;
this.lsbTools.ItemHeight = 22;
this.lsbTools.Location = new System.Drawing.Point(10, 358);
this.lsbTools.Name = "lsbTools";
this.lsbTools.Size = new System.Drawing.Size(141, 222);
this.lsbTools.TabIndex = 32;
this.lsbTools.SelectedIndexChanged += new System.EventHandler(this.lsbTools_SelectedIndexChanged);
this.panelTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.panelTools.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
this.panelTools.Controls.Add(this.label2);
this.panelTools.Controls.Add(this.lsbTools);
this.panelTools.Controls.Add(this.button1);
this.panelTools.Controls.Add(this.btnSetColor);
this.panelTools.Controls.Add(this.label13);
this.panelTools.Controls.Add(this.tbxColorHex);
this.panelTools.Controls.Add(this.btnColorHistory1);
this.panelTools.Controls.Add(this.label4);
this.panelTools.Controls.Add(this.btnColorHistory2);
this.panelTools.Controls.Add(this.btnColorHistory3);
this.panelTools.Controls.Add(this.btnColorHistory4);
this.panelTools.Controls.Add(this.label5);
this.panelTools.Controls.Add(this.label9);
this.panelTools.Controls.Add(this.label6);
this.panelTools.Controls.Add(this.label8);
this.panelTools.Controls.Add(this.label7);
this.panelTools.Controls.Add(this.nupPencilWidth);
this.panelTools.Controls.Add(this.nupRed);
this.panelTools.Controls.Add(this.nupBlue);
this.panelTools.Controls.Add(this.nupGreen);
this.panelTools.Location = new System.Drawing.Point(927, 7);
this.panelTools.Name = "panelTools";
this.panelTools.Size = new System.Drawing.Size(163, 593);
this.panelTools.TabIndex = 31;
//
// label2
//
@@ -651,45 +585,77 @@
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(10, 335);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(54, 20);
this.label2.Size = new System.Drawing.Size(42, 16);
this.label2.TabIndex = 33;
this.label2.Text = "Tools";
//
// lsbTools
//
this.lsbTools.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(41)))), ((int)(((byte)(41)))));
this.lsbTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lsbTools.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.lsbTools.FormattingEnabled = true;
this.lsbTools.ItemHeight = 18;
this.lsbTools.Location = new System.Drawing.Point(10, 358);
this.lsbTools.Name = "lsbTools";
this.lsbTools.Size = new System.Drawing.Size(141, 218);
this.lsbTools.TabIndex = 32;
this.lsbTools.SelectedIndexChanged += new System.EventHandler(this.lsbTools_SelectedIndexChanged);
//
// lblWidth
//
this.lblWidth.AutoSize = true;
this.lblWidth.Location = new System.Drawing.Point(100, 6);
this.lblWidth.Name = "lblWidth";
this.lblWidth.Size = new System.Drawing.Size(96, 18);
this.lblWidth.TabIndex = 33;
this.lblWidth.Text = "width: 2000";
//
// lblHeight
//
this.lblHeight.AutoSize = true;
this.lblHeight.Location = new System.Drawing.Point(100, 24);
this.lblHeight.Name = "lblHeight";
this.lblHeight.Size = new System.Drawing.Size(104, 18);
this.lblHeight.TabIndex = 34;
this.lblHeight.Text = "Height: 2000";
//
// PaintForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 22F);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
this.ClientSize = new System.Drawing.Size(1095, 663);
this.Controls.Add(this.panel5);
this.Controls.Add(this.panel4);
this.Controls.Add(this.panel3);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.panelHoverColor);
this.Controls.Add(this.panelSelectedColor);
this.Controls.Add(this.panelTools);
this.Controls.Add(this.panelDrawing);
this.Controls.Add(this.panelFile);
this.Controls.Add(this.btnClear);
this.Controls.Add(this.btnImportImage);
this.Controls.Add(this.canvas);
this.Font = new System.Drawing.Font("Cascadia Code", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(214)))), ((int)(((byte)(214)))));
this.Margin = new System.Windows.Forms.Padding(4);
this.MinimumSize = new System.Drawing.Size(1111, 702);
this.Name = "PaintForm";
this.Text = "Paint 2";
this.Resize += new System.EventHandler(this.PaintForm_Resize);
((System.ComponentModel.ISupportInitialize)(this.canvas)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nupHeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nupWidth)).EndInit();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.panel4.ResumeLayout(false);
this.panel4.PerformLayout();
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panelFile.ResumeLayout(false);
this.panelFile.PerformLayout();
this.panelDrawing.ResumeLayout(false);
this.panelDrawing.PerformLayout();
this.panelSelectedColor.ResumeLayout(false);
this.panelSelectedColor.PerformLayout();
this.panelHoverColor.ResumeLayout(false);
this.panelHoverColor.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nupGreen)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nupBlue)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nupRed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nupPencilWidth)).EndInit();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.panelTools.ResumeLayout(false);
this.panelTools.PerformLayout();
this.ResumeLayout(false);
}
@@ -701,18 +667,15 @@
private System.Windows.Forms.PictureBox canvas;
private System.Windows.Forms.Button btnSaveCopy;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnResize;
private System.Windows.Forms.NumericUpDown nupHeight;
private System.Windows.Forms.NumericUpDown nupWidth;
private System.Windows.Forms.Label lblSelectedColor;
private System.Windows.Forms.Button btnImportImage;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panelFile;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panelDrawing;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Panel panelSelectedColor;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panelHoverColor;
private System.Windows.Forms.Label lblHoveringColor;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Timer tmrRefresh;
@@ -737,9 +700,11 @@
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Button btnSetColor;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Panel panelTools;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ListBox lsbTools;
private System.Windows.Forms.Label lblHeight;
private System.Windows.Forms.Label lblWidth;
}
}

View File

@@ -19,6 +19,7 @@ namespace Paint_2
{
public partial class PaintForm : Form
{
const int WINDOW_OFFSET = 10;
const string DEFAULT_FILEPATH = "C:/Paint2/Drawings/";
Sketch sketch;
List<PaintTool> toolList;
@@ -28,16 +29,14 @@ namespace Paint_2
public PaintForm()
{
InitializeComponent();
rnd = new Random();
nupWidth.Value = canvas.Width;
nupHeight.Value = canvas.Height;
toolList = new List<PaintTool>();
toolList.Add(new Pencil("Default Pencil"));
toolList.Add(new DotPencil("Dotted Line"));
sketch = new Sketch(new Size((int)nupWidth.Value, (int)nupHeight.Value), toolList);
canvas.Image = sketch.Drawing;
sketch = new Sketch(new Size(canvas.Width, canvas.Height), toolList);
tmrRefresh.Enabled = true;
RefreshUi();
}
private Point MousePositionToCanvasPosition()
{
@@ -95,13 +94,17 @@ namespace Paint_2
btnColorHistory4.BackColor = colorHistory[3];
lsbTools.DataSource = toolList;
lblWidth.Text = "Width: "+canvas.Width.ToString();
lblHeight.Text = "Height: "+canvas.Height.ToString();
}
private Color GetHoverColor()
{
Point cursorLocation = MousePositionToCanvasPosition();
Color pixel;
if (cursorLocation.X > 0 && cursorLocation.X < canvas.Width && cursorLocation.Y > 0 && cursorLocation.Y < canvas.Height)
if (cursorLocation.X > 0 && cursorLocation.X < canvas.Width && cursorLocation.Y > 0 && cursorLocation.Y < canvas.Height && cursorLocation.X < Width && cursorLocation.Y < Height)
{
int DEBUG = Width;
pixel = (canvas.Image as Bitmap).GetPixel(cursorLocation.X, cursorLocation.Y);
}
else
@@ -184,7 +187,8 @@ namespace Paint_2
private void btnSaveCopy_Click(object sender, EventArgs e)
{
string fileName = tbxProjectName.Text + "_copy";
string fileName = tbxProjectName.Text;
int version = 1;
Bitmap image = (Bitmap)canvas.Image;
if (!Directory.Exists(DEFAULT_FILEPATH))
@@ -195,8 +199,11 @@ namespace Paint_2
{
Directory.CreateDirectory(DEFAULT_FILEPATH + fileName);
}
image.Save(DEFAULT_FILEPATH + fileName + "/" + fileName + ".png", System.Drawing.Imaging.ImageFormat.Png);
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)
@@ -204,5 +211,12 @@ namespace Paint_2
sketch.ChangeTool(lsbTools.SelectedIndex);
RefreshUi();
}
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));
sketch.Resize(canvas.Size);
RefreshUi();
}
}
}

View File

@@ -51,6 +51,13 @@ namespace Paint_2
{
//empty
}
public void Resize(Size newSize)
{
if (newSize.Width > 0 && newSize.Height > 0)
{
Drawing = new Bitmap(newSize.Width, newSize.Height);
}
}
public void ChangeTool(int toolId)
{
try