Skip to content
Snippets Groups Projects
Commit 5dd73f4c authored by Riley Mcgee's avatar Riley Mcgee
Browse files

Basic Refactoring and some code cleaning in model

parent 61a8dea0
No related branches found
No related tags found
No related merge requests found
...@@ -3,8 +3,10 @@ using System; ...@@ -3,8 +3,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Gifitti.Models namespace Gifitti.Models
...@@ -45,9 +47,13 @@ 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() public void resetToOriginalGif()
{ {
gifImage = originalGif; gifImage = originalGif.Clone() as Image;
} }
/// <summary> /// <summary>
...@@ -57,8 +63,19 @@ namespace Gifitti.Models ...@@ -57,8 +63,19 @@ namespace Gifitti.Models
/// <param name="path">String representation of path to save the gif to. /// <param name="path">String representation of path to save the gif to.
/// Name and extension of gif mandatory. /// Name and extension of gif mandatory.
/// </param> /// </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) 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. //TODO take in image setting components as well as frames being viewed etc.
//Build GIF //Build GIF
using (MagickImageCollection collection = new MagickImageCollection()) using (MagickImageCollection collection = new MagickImageCollection())
......
...@@ -41,7 +41,6 @@ namespace Gifitti.View_Models ...@@ -41,7 +41,6 @@ namespace Gifitti.View_Models
string file = openFileDialog1.FileName; string file = openFileDialog1.FileName;
try try
{ {
gm = new GifModel(file); gm = new GifModel(file);
gm.ReverseAtEnd = false; gm.ReverseAtEnd = false;
Image loadedGif = gm.gifImage; 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