public async void dothings() { CollageMaker cm = new CollageMaker(); string dir = Console.ReadLine().Trim(); cm.TryAddFilesFromDirectory(dir); cm.Draw(); Console.ReadLine(); return; }
/// <summary> /// Instance main method. /// </summary> public async void Run() { try { Console.WriteLine("1.4.7 Collage Maker"); Console.WriteLine(); string DirectoryPath; while (true) { Console.WriteLine("Please enter the absolute directory path of the images you wish to collage."); DirectoryPath = Console.ReadLine().Trim(new char[] { '"', ' ' });// Trims whitespace and quotes off the end of the path. if (Directory.Exists(DirectoryPath)) { break; } else { Console.WriteLine("Directory does not exist, please try again."); } } CollageMaker cm = new CollageMaker(); int cnt = cm.TryAddFilesFromDirectory(DirectoryPath); Console.WriteLine("Directory contained {0} images", cnt.ToString()); if (cnt < 2) { Console.WriteLine("Need more images to continue. Please add images and re-start the program. "); Console.Write("Press any key to exit..."); Console.ReadKey(); return; // exits the program. } Console.WriteLine("Press enter to display the list of images loaded..."); Console.ReadLine(); Console.Clear(); foreach (var kvp in cm.CollageDictionary) { Console.WriteLine("{0} \t \t {1}", kvp.Key.ToString(), kvp.Value.FileName); } Console.WriteLine("Press enter to continue..."); Console.ReadLine(); while (true) { Console.Write("Please enter the height (in pixels) of the new collage:"); int i; if (int.TryParse(Console.ReadLine().Trim(), out i)) { cm.SetPicHeight(i); break; } else { Console.WriteLine("Invalid input. Try again."); } } while (true) { Console.Write("Please enter the size of each image (in pixels) in the new collage:"); int i; if (int.TryParse(Console.ReadLine().Trim(), out i)) { cm.SetPicWidth(i); break; } else { Console.WriteLine("Invalid input. Try again."); } } Console.WriteLine("Please enter the path of the new image. If the file does not exist, it will be created. If the file exists, the file will be overwritten."); string savepath = Console.ReadLine().Trim(new char[] { '"', ' ' }); Console.WriteLine("Press enter to draw collage. Do not close the program until it has been completed."); Console.ReadLine(); await cm.Draw(savepath); // Had to emergency edit to make this work. Console.WriteLine("File saved to: {0}.", savepath); Console.WriteLine("Program Complete, press enter to exit."); Console.ReadLine(); return; } catch (Exception e) { Console.WriteLine("Errors!"); Console.WriteLine(e.Message + e.Source); Console.WriteLine(e.StackTrace); Console.WriteLine("Press any key to exit"); Console.ReadLine(); return; } }