Browse Source

Added functionality to create a canvas. Bugs remain

Martin Edlund 5 years ago
parent
commit
11687e28bd

+ 18 - 10
SketchAssistant/SketchAssistant/Form1.Designer.cs

@@ -29,6 +29,7 @@ namespace SketchAssistant
         private void InitializeComponent()
         {
             this.components = new System.ComponentModel.Container();
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
             this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
             this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
             this.pictureBoxRight = new System.Windows.Forms.PictureBox();
@@ -37,11 +38,11 @@ namespace SketchAssistant
             this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStrip1 = new System.Windows.Forms.ToolStrip();
-            this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
             this.statusStrip1 = new System.Windows.Forms.StatusStrip();
             this.toolStripLoadStatus = new System.Windows.Forms.ToolStripStatusLabel();
             this.backgroundWorker2 = new System.ComponentModel.BackgroundWorker();
             this.timer1 = new System.Windows.Forms.Timer(this.components);
+            this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
             this.tableLayoutPanel1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBoxRight)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBoxLeft)).BeginInit();
@@ -77,6 +78,7 @@ namespace SketchAssistant
             this.pictureBoxRight.Margin = new System.Windows.Forms.Padding(0);
             this.pictureBoxRight.Name = "pictureBoxRight";
             this.pictureBoxRight.Size = new System.Drawing.Size(344, 434);
+            this.pictureBoxRight.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
             this.pictureBoxRight.TabIndex = 6;
             this.pictureBoxRight.TabStop = false;
             // 
@@ -123,19 +125,13 @@ namespace SketchAssistant
             // toolStrip1
             // 
             this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.toolStripLabel1});
+            this.toolStripButton1});
             this.toolStrip1.Location = new System.Drawing.Point(0, 24);
             this.toolStrip1.Name = "toolStrip1";
             this.toolStrip1.Size = new System.Drawing.Size(696, 25);
             this.toolStrip1.TabIndex = 3;
             this.toolStrip1.Text = "toolStrip1";
             // 
-            // toolStripLabel1
-            // 
-            this.toolStripLabel1.Name = "toolStripLabel1";
-            this.toolStripLabel1.Size = new System.Drawing.Size(69, 22);
-            this.toolStripLabel1.Text = "Placeholder";
-            // 
             // statusStrip1
             // 
             this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -156,9 +152,20 @@ namespace SketchAssistant
             // 
             // timer1
             // 
-            this.timer1.Interval = 10;
+            this.timer1.Enabled = true;
+            this.timer1.Interval = 1;
             this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
             // 
+            // toolStripButton1
+            // 
+            this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
+            this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
+            this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
+            this.toolStripButton1.Name = "toolStripButton1";
+            this.toolStripButton1.Size = new System.Drawing.Size(76, 22);
+            this.toolStripButton1.Text = "New Canvas";
+            this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
+            // 
             // Form1
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -174,6 +181,7 @@ namespace SketchAssistant
             this.Name = "Form1";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Text = "Sketch Assistant";
+            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
             this.Load += new System.EventHandler(this.Form1_Load);
             this.tableLayoutPanel1.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.pictureBoxRight)).EndInit();
@@ -196,13 +204,13 @@ namespace SketchAssistant
         private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem loadToolStripMenuItem;
         private System.Windows.Forms.ToolStrip toolStrip1;
-        private System.Windows.Forms.ToolStripLabel toolStripLabel1;
         private System.Windows.Forms.StatusStrip statusStrip1;
         private System.Windows.Forms.ToolStripStatusLabel toolStripLoadStatus;
         private System.ComponentModel.BackgroundWorker backgroundWorker2;
         private System.Windows.Forms.PictureBox pictureBoxRight;
         private System.Windows.Forms.PictureBox pictureBoxLeft;
         private System.Windows.Forms.Timer timer1;
+        private System.Windows.Forms.ToolStripButton toolStripButton1;
     }
 }
 

+ 38 - 6
SketchAssistant/SketchAssistant/Form1.cs

@@ -25,12 +25,15 @@ namespace SketchAssistant
         OpenFileDialog openFileDialogLeft = new OpenFileDialog();
         //Image loaded on the left
         Image leftImage = null;
+        //Image on the right
+        Image rightImage = null;
 
         private void Form1_Load(object sender, EventArgs e)
         {
             this.DoubleBuffered = true;
             //Connect the Paint event of the left picture box to the event handler method.
             pictureBoxLeft.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxLeft_Paint);
+            pictureBoxRight.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxRight_Paint);
         }
 
         private void pictureBoxLeft_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
@@ -43,10 +46,13 @@ namespace SketchAssistant
 
         }
 
-        //TODO: Remove this placeholder when real buttons are in place
-        private void toolStripLabel1_Click(object sender, EventArgs e)
+        private void pictureBoxRight_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
         {
-
+            //Draw the right image
+            if (rightImage != null)
+            {
+                pictureBoxRight.Image = rightImage;
+            }
         }
 
         // A Table Layout with one row and two columns. 
@@ -86,16 +92,42 @@ namespace SketchAssistant
         {
 
         }
-        
-        //Timer that refreshes the picture box, so that it will always show the right contents in the right size
+
+        //Timer that refreshes the left picture box, so that it will always show the right contents in the right size
         private void timer1_Tick(object sender, EventArgs e)
         {
-            pictureBoxLeft.Update();
+            this.Refresh();
+            pictureBoxLeft.Refresh();
+            pictureBoxRight.Refresh();
         }
 
         private void pictureBoxLeft_Click(object sender, EventArgs e)
         {
 
         }
+
+        //Button to create a new Canvas. Will create an empty image 
+        //which is the size of the left image, if there is one.
+        //If there is no image loaded the canvas will be the size of the right picture box
+        private void toolStripButton1_Click(object sender, EventArgs e)
+        {
+            if (leftImage == null)
+            {
+                rightImage = new Bitmap(pictureBoxRight.Width, pictureBoxRight.Height);
+                using (Graphics grp = Graphics.FromImage(rightImage))
+                {
+                    grp.FillRectangle(Brushes.White, 0, 0, pictureBoxRight.Width + 10, pictureBoxRight.Height + 10);
+                }
+            }
+            else
+            {
+                rightImage = new Bitmap(leftImage.Width, leftImage.Height);
+                using (Graphics grp = Graphics.FromImage(rightImage))
+                {
+                    grp.FillRectangle(Brushes.White, 0, 0, leftImage.Width + 10, leftImage.Height + 10);
+                }
+            }
+            this.Refresh();
+        }
     }
 }

+ 17 - 1
SketchAssistant/SketchAssistant/Form1.resx

@@ -135,7 +135,23 @@
   <metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>786, 17</value>
   </metadata>
+  <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  <data name="toolStripButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+        YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
+        YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
+        0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
+        bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
+        VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
+        c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
+        Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
+        mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
+        kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
+        TgDQASA1MVpwzwAAAABJRU5ErkJggg==
+</value>
+  </data>
   <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>43</value>
+    <value>47</value>
   </metadata>
 </root>

+ 13 - 0
SketchAssistant/userstory3.md

@@ -0,0 +1,13 @@
+# Userstory 3  
+
+|**ID**|3|
+|-|-|
+|**Name**|Neue Zeichenleinwand|  
+|**Beschreibung**|Man kann ein Knopf in der Toolbar drücken, welcher im rechten Bereich des Hauptfensters eine leere Leinwand anzeigt.|
+|**Akzeptanzkriterium**|Wenn der entsprechende Knopf in der Toolbar gedrückt wird, wird der rechte Bereich des Hauptfensters mit einer neuen Zeichenleinwand gefüllt, welche komplett weiß ist. Die größe des Bereiches wird nicht angepasst und die Fenstergröße bleibt unverändert.|
+|Geschätzter Aufwand (Story Points)|6|
+|Entwickler|keiner|
+|Umgesetzt in Iteration|keine|
+|Tatsächlicher Aufwand (Std.)|keine|
+|Velocity (Std./Story Point)|keine|
+|Bemerkungen|Keine|

+ 13 - 0
userstory3.md

@@ -0,0 +1,13 @@
+# Userstory 3  
+
+|**ID**|3|
+|-|-|
+|**Name**|Neue Zeichenleinwand|  
+|**Beschreibung**|Man kann ein Knopf in der Toolbar drücken, welcher im rechten Bereich des Hauptfensters eine leere Leinwand anzeigt.|
+|**Akzeptanzkriterium**|Wenn der entsprechende Knopf in der Toolbar gedrückt wird, wird der rechte Bereich des Hauptfensters mit einer neuen Zeichenleinwand gefüllt, welche komplett weiß ist. Die größe des Bereiches wird nicht angepasst und die Fenstergröße bleibt unverändert.|
+|Geschätzter Aufwand (Story Points)|6|
+|Entwickler|Martin|
+|Umgesetzt in Iteration|keine|
+|Tatsächlicher Aufwand (Std.)|keine|
+|Velocity (Std./Story Point)|keine|
+|Bemerkungen|Keine|