From c8fa5319625df1ab101bf20d5af65b3d40679c59 Mon Sep 17 00:00:00 2001 From: Pavle Arezina <arezinp@mcmaster.ca> Date: Sun, 27 Nov 2016 22:35:14 -0500 Subject: [PATCH] Negative values will not crash gif system --- .../Gifitti/View_Models/MainForm.Designer.cs | 60 ++++++++++--------- src/Gifitti/Gifitti/View_Models/MainForm.cs | 4 +- .../Gifitti/View_Models/SaveAsXbyYPrompt.cs | 4 +- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/Gifitti/Gifitti/View_Models/MainForm.Designer.cs b/src/Gifitti/Gifitti/View_Models/MainForm.Designer.cs index a9311e7..0e94ee4 100644 --- a/src/Gifitti/Gifitti/View_Models/MainForm.Designer.cs +++ b/src/Gifitti/Gifitti/View_Models/MainForm.Designer.cs @@ -66,10 +66,10 @@ namespace Gifitti.View_Models // // gifView // - this.gifView.Location = new System.Drawing.Point(12, 12); - this.gifView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.gifView.Location = new System.Drawing.Point(9, 10); + this.gifView.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.gifView.Name = "gifView"; - this.gifView.Size = new System.Drawing.Size(608, 470); + this.gifView.Size = new System.Drawing.Size(456, 382); this.gifView.TabIndex = 2; this.gifView.TabStop = false; // @@ -151,10 +151,10 @@ namespace Gifitti.View_Models // this.textBox1.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.textBox1.Enabled = false; - this.textBox1.Location = new System.Drawing.Point(285, 567); - this.textBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBox1.Location = new System.Drawing.Point(214, 461); + this.textBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(29, 22); + this.textBox1.Size = new System.Drawing.Size(23, 20); this.textBox1.TabIndex = 3; this.textBox1.TextChanged += new System.EventHandler(this.StartFrameTextChanged); // @@ -162,10 +162,10 @@ namespace Gifitti.View_Models // this.textBox2.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.textBox2.Enabled = false; - this.textBox2.Location = new System.Drawing.Point(320, 567); - this.textBox2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBox2.Location = new System.Drawing.Point(240, 461); + this.textBox2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(29, 22); + this.textBox2.Size = new System.Drawing.Size(23, 20); this.textBox2.TabIndex = 4; this.textBox2.TextChanged += new System.EventHandler(this.StopFrameTextChanged); // @@ -173,10 +173,10 @@ namespace Gifitti.View_Models // this.button3.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.button3.Enabled = false; - this.button3.Location = new System.Drawing.Point(355, 564); - this.button3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.button3.Location = new System.Drawing.Point(266, 458); + this.button3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(67, 30); + this.button3.Size = new System.Drawing.Size(50, 24); this.button3.TabIndex = 5; this.button3.Text = "Stop"; this.button3.UseVisualStyleBackColor = true; @@ -186,9 +186,10 @@ namespace Gifitti.View_Models // this.label1.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(282, 548); + this.label1.Location = new System.Drawing.Point(212, 445); + this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(38, 17); + this.label1.Size = new System.Drawing.Size(29, 13); this.label1.TabIndex = 6; this.label1.Text = "Start"; // @@ -196,9 +197,10 @@ namespace Gifitti.View_Models // this.label2.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(319, 548); + this.label2.Location = new System.Drawing.Point(239, 445); + this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(33, 17); + this.label2.Size = new System.Drawing.Size(26, 13); this.label2.TabIndex = 7; this.label2.Text = "End"; // @@ -206,9 +208,10 @@ namespace Gifitti.View_Models // this.label3.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(213, 561); + this.label3.Location = new System.Drawing.Point(160, 456); + this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(66, 34); + this.label3.Size = new System.Drawing.Size(51, 26); this.label3.TabIndex = 8; this.label3.Text = "Frame \r\nSelection"; // @@ -220,9 +223,10 @@ namespace Gifitti.View_Models // trackBar1 // this.trackBar1.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.trackBar1.Location = new System.Drawing.Point(437, 561); + this.trackBar1.Location = new System.Drawing.Point(328, 456); + this.trackBar1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.trackBar1.Name = "trackBar1"; - this.trackBar1.Size = new System.Drawing.Size(183, 56); + this.trackBar1.Size = new System.Drawing.Size(137, 45); this.trackBar1.TabIndex = 9; this.trackBar1.Value = 10; this.trackBar1.ValueChanged += new System.EventHandler(this.GifFPSSliderUpdate); @@ -231,9 +235,10 @@ namespace Gifitti.View_Models // this.label4.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(478, 551); + this.label4.Location = new System.Drawing.Point(358, 448); + this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(110, 17); + this.label4.Size = new System.Drawing.Size(85, 13); this.label4.TabIndex = 10; this.label4.Text = "Playback Speed"; // @@ -243,17 +248,18 @@ namespace Gifitti.View_Models this.label6.AutoSize = true; this.label6.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F); - this.label6.Location = new System.Drawing.Point(87, 560); + this.label6.Location = new System.Drawing.Point(65, 455); + this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(96, 29); + this.label6.Size = new System.Drawing.Size(72, 24); this.label6.TabIndex = 12; this.label6.Text = "GIFITTI"; // // MainForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(632, 577); + this.ClientSize = new System.Drawing.Size(474, 469); this.Controls.Add(this.label6); this.Controls.Add(this.label4); this.Controls.Add(this.trackBar1); @@ -264,7 +270,7 @@ namespace Gifitti.View_Models this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox1); this.Controls.Add(this.gifView); - this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.Menu = this.mainMenu1; this.Name = "MainForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; diff --git a/src/Gifitti/Gifitti/View_Models/MainForm.cs b/src/Gifitti/Gifitti/View_Models/MainForm.cs index fdc84f0..f35e3a4 100644 --- a/src/Gifitti/Gifitti/View_Models/MainForm.cs +++ b/src/Gifitti/Gifitti/View_Models/MainForm.cs @@ -178,7 +178,7 @@ namespace Gifitti.View_Models { int start = 0; bool pass = int.TryParse(textBox1.Text, out start); - if (pass) + if (pass & start >= 0) { gm.startFrame = start; } @@ -193,7 +193,7 @@ namespace Gifitti.View_Models { int end = 0; bool pass = int.TryParse(textBox2.Text, out end); - if (pass) + if (pass & end >= 0) { gm.endFrame = end; } diff --git a/src/Gifitti/Gifitti/View_Models/SaveAsXbyYPrompt.cs b/src/Gifitti/Gifitti/View_Models/SaveAsXbyYPrompt.cs index fc8dba7..a2e8e4f 100644 --- a/src/Gifitti/Gifitti/View_Models/SaveAsXbyYPrompt.cs +++ b/src/Gifitti/Gifitti/View_Models/SaveAsXbyYPrompt.cs @@ -61,7 +61,7 @@ namespace Gifitti.View_Models private void widthChanged(object sender, EventArgs e) { int w = 0; - if (int.TryParse(WidthTextBox.Text, out w)){ + if (int.TryParse(WidthTextBox.Text, out w) & w >= 0){ width = w; } } @@ -69,7 +69,7 @@ namespace Gifitti.View_Models private void heightChanged(object sender, EventArgs e) { int h = 0; - if (int.TryParse(HeightTextBox.Text,out h)) + if (int.TryParse(HeightTextBox.Text,out h) & h >= 0) { height = h; } -- GitLab