diff --git a/src/Gifitti/Gifitti/Models/GifModel.cs b/src/Gifitti/Gifitti/Models/GifModel.cs index 05bbab10253430591d7216cb46c7ca779036a3ac..e55a173bc1c63e760995b11e8e735e36bf861a84 100644 --- a/src/Gifitti/Gifitti/Models/GifModel.cs +++ b/src/Gifitti/Gifitti/Models/GifModel.cs @@ -34,6 +34,10 @@ namespace Gifitti.Models /// <param name="path">Location of the GIF being loaded.</param> public GifModel(String path) { + Console.WriteLine(Path.GetExtension(path)); + + if (!Path.GetExtension(path).ToLower().Equals(".gif")) + throw new FileLoadException("Invalid Extension Specified"); //Save the original Gif originalGif = Image.FromFile(path); this.gifImage = originalGif.Clone() as Image; diff --git a/src/Gifitti/Gifitti/View_Models/MainForm.Designer.cs b/src/Gifitti/Gifitti/View_Models/MainForm.Designer.cs index cf3b76384ea5f9fec0f7925696de4e446baf105b..4101995c550af6b58b5328191ccba6546ed36cfd 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, 551); - this.textBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBox1.Location = new System.Drawing.Point(214, 448); + 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, 551); - this.textBox2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBox2.Location = new System.Drawing.Point(240, 448); + 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, 548); - this.button3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.button3.Location = new System.Drawing.Point(266, 445); + 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(283, 532); + this.label1.Location = new System.Drawing.Point(212, 432); + 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, 532); + this.label2.Location = new System.Drawing.Point(239, 432); + 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, 545); + this.label3.Location = new System.Drawing.Point(160, 443); + 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,10 +223,10 @@ namespace Gifitti.View_Models // trackBar1 // this.trackBar1.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.trackBar1.Location = new System.Drawing.Point(437, 551); - this.trackBar1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.trackBar1.Location = new System.Drawing.Point(328, 448); + 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.Scroll += new System.EventHandler(this.trackBar1_Scroll); @@ -233,9 +236,10 @@ namespace Gifitti.View_Models // this.label4.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(472, 532); + this.label4.Location = new System.Drawing.Point(354, 432); + 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"; // @@ -245,17 +249,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, 544); + this.label6.Location = new System.Drawing.Point(65, 442); + 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); @@ -266,7 +271,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 72d87ed29d5af0c98f2aa3e963e615ed94ce5a9b..7ade0118729a90b897aed3358e0917bf2061bfc7 100644 --- a/src/Gifitti/Gifitti/View_Models/MainForm.cs +++ b/src/Gifitti/Gifitti/View_Models/MainForm.cs @@ -256,15 +256,23 @@ namespace Gifitti.View_Models string file = openGifFileDialog.FileName; try { - gm = new GifModel(file); - gm.ReverseAtEnd = false; - Image loadedGif = gm.gifImage; - globalGif = loadedGif; - //gifView.Image = loadedGif; - - gifView.Width = loadedGif.Width; - gifView.Height = loadedGif.Height; - ClientSize = new Size(loadedGif.Width + widthBuffer, loadedGif.Height + heightBuffer); + try + { + gm = new GifModel(file); + gm.ReverseAtEnd = false; + Image loadedGif = gm.gifImage; + globalGif = loadedGif; + //gifView.Image = loadedGif; + + gifView.Width = loadedGif.Width; + gifView.Height = loadedGif.Height; + ClientSize = new Size(loadedGif.Width + widthBuffer, loadedGif.Height + heightBuffer); + } + catch (FileLoadException) + { + MessageBox.Show("Specify a GIF file."); + return; + } } catch (IOException)