/// <summary> /// <c>PixelManager</c> initiliser, creates the class and returns it. /// </summary> /// <para> /// It should be noted that if the action was created under encoding then it will generate 1000 random pixels to use. /// </para> /// <param name="manager">The parent manager <c>SteganographyManager</c> or any children.</param> public PixelManager(SteganographyManager manager) { Console.WriteLine("Initialising pixel manager."); parent = manager; //Setup Class Params setupClass(); if (parent.getAction() == SteganographyManager.Action.Encoding) { //Setup Manager For Each Letter setupHexCharacters(); //Choose Initial Pixels Console.WriteLine("Choosing 1000 random pixels (this may increase later on)."); addPixels(1000); Console.WriteLine(""); } valid = true; }
/// <summary> /// Constructor for the <c>StegFileManager</c> class, which will open/create the file and the relevant streamers. /// There are four possible different actions which can be taked. /// 1. Decoding Mode - Read File /// 2. Decoding Mode - Write File /// 3. Encoding Mode - Read File /// 4. Encoding Mode - Write File /// </summary> /// <param name="parent">The parent <c>SteganographyManager</c> class.</param> /// <param name="type">Type of file (read or write).</param> /// <param name="location">Location of the file to be read / written to.</param> public StegFileManager(SteganographyManager parent, FileType type, string location) { parentAction = parent.getAction(); action = type; switch (parentAction) { case SteganographyManager.Action.Encoding when action == FileType.ReadFile: { Console.WriteLine("Opening file to encode."); checkValid(location, false); if (isValid()) { openFile(location); openBufferedStream(); } break; } case SteganographyManager.Action.Decoding when action == FileType.ReadFile: { Console.WriteLine("Opening file to decode."); checkValid(location, false); if (isValid()) { openFile(location); openBinaryReader(); } break; } case SteganographyManager.Action.Encoding when action == FileType.WriteFile: { Console.WriteLine("Creating file to write to."); checkValid(location, true); if (isValid()) { createFile(location); openBinaryWriter(); } break; } case SteganographyManager.Action.Decoding when action == FileType.WriteFile: { Console.WriteLine("Creating file to write to."); checkValid(location, true); if (isValid()) { createFile(location); openBufferedStream(); } break; } default: throw new ArgumentOutOfRangeException(); } }