Skip to content
Snippets Groups Projects
Commit ba342dfd authored by Pavle Arezina's avatar Pavle Arezina
Browse files

Resolved issue of Opening non Gifs, Model is now also disposable for memory leak resolving

parent 6d4dbaa4
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ namespace Gifitti.Models
/// <summary>
/// Software model of a GIF, Encapsulated with bassic opperations on GIF images.
/// </summary>
public class GifModel
public class GifModel : IDisposable
{
public Image gifImage { get; set; }
public Image originalGif { get; private set; }
......@@ -35,9 +35,6 @@ namespace Gifitti.Models
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;
......@@ -202,5 +199,10 @@ namespace Gifitti.Models
{
frames[index] = frame;
}
public void Dispose()
{
this.frames = null;
}
}
}
......@@ -67,7 +67,7 @@ namespace Gifitti.View_Models
// gifView
//
this.gifView.Location = new System.Drawing.Point(9, 10);
this.gifView.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.gifView.Margin = new System.Windows.Forms.Padding(2);
this.gifView.Name = "gifView";
this.gifView.Size = new System.Drawing.Size(456, 382);
this.gifView.TabIndex = 2;
......@@ -152,7 +152,7 @@ namespace Gifitti.View_Models
this.textBox1.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.textBox1.Enabled = false;
this.textBox1.Location = new System.Drawing.Point(214, 448);
this.textBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.textBox1.Margin = new System.Windows.Forms.Padding(2);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(23, 20);
this.textBox1.TabIndex = 3;
......@@ -163,7 +163,7 @@ namespace Gifitti.View_Models
this.textBox2.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.textBox2.Enabled = false;
this.textBox2.Location = new System.Drawing.Point(240, 448);
this.textBox2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.textBox2.Margin = new System.Windows.Forms.Padding(2);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(23, 20);
this.textBox2.TabIndex = 4;
......@@ -174,7 +174,7 @@ namespace Gifitti.View_Models
this.button3.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.button3.Enabled = false;
this.button3.Location = new System.Drawing.Point(266, 445);
this.button3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.button3.Margin = new System.Windows.Forms.Padding(2);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(50, 24);
this.button3.TabIndex = 5;
......@@ -224,7 +224,7 @@ namespace Gifitti.View_Models
//
this.trackBar1.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.trackBar1.Location = new System.Drawing.Point(328, 448);
this.trackBar1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.trackBar1.Margin = new System.Windows.Forms.Padding(2);
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(137, 45);
this.trackBar1.TabIndex = 9;
......@@ -271,7 +271,8 @@ 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(2, 2, 2, 2);
this.Margin = new System.Windows.Forms.Padding(2);
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
......
......@@ -258,6 +258,9 @@ namespace Gifitti.View_Models
{
try
{
if (!Path.GetExtension(file).ToLower().Equals(".gif"))
throw new FileLoadException("Invalid Extension Specified");
gm?.Dispose();
gm = new GifModel(file);
gm.ReverseAtEnd = false;
Image loadedGif = gm.gifImage;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment