diff --git a/src/Gifitti/Gifitti/Models/GifModel.cs b/src/Gifitti/Gifitti/Models/GifModel.cs index 09ae8ca3d36b1bb88bc2108100ed9dddfe175685..8ae9d4732b6c02b21228261312b11b1e66655bd5 100644 --- a/src/Gifitti/Gifitti/Models/GifModel.cs +++ b/src/Gifitti/Gifitti/Models/GifModel.cs @@ -3,8 +3,10 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; +using System.IO; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace Gifitti.Models @@ -45,9 +47,13 @@ namespace Gifitti.Models } } + /// <summary> + /// Changes the loaded GIF to be what was originally loaded by the User. + /// If a new file is opened the current original GIF is overloaded. + /// </summary> public void resetToOriginalGif() { - gifImage = originalGif; + gifImage = originalGif.Clone() as Image; } /// <summary> @@ -57,8 +63,19 @@ namespace Gifitti.Models /// <param name="path">String representation of path to save the gif to. /// Name and extension of gif mandatory. /// </param> + /// <exception cref="DirectoryNotFoundException"> + /// Thrown if the path is not valid for the local system, + /// OR the file has an extension other than [G|g][I|i][F|f] + /// </exception> public void saveGif(string path) { + //Error Handel on path + Regex savePathTest = new Regex(@"^(([^\/\\]+)[\/\\])*([^\/\\]*)\.[g|G][i|I][f|F]$"); + if (!savePathTest.IsMatch(path)) + { + throw new DirectoryNotFoundException(); + } + //TODO take in image setting components as well as frames being viewed etc. //Build GIF using (MagickImageCollection collection = new MagickImageCollection()) diff --git a/src/Gifitti/Gifitti/View_Models/Form1.cs b/src/Gifitti/Gifitti/View_Models/Form1.cs index 9b48bdee900c75c6b55845673f575cba6326beb8..bce43cd70838934696b6be6e902000bdb9e5e70c 100644 --- a/src/Gifitti/Gifitti/View_Models/Form1.cs +++ b/src/Gifitti/Gifitti/View_Models/Form1.cs @@ -41,7 +41,6 @@ namespace Gifitti.View_Models string file = openFileDialog1.FileName; try { - gm = new GifModel(file); gm.ReverseAtEnd = false; Image loadedGif = gm.gifImage;