void runProgram() { Utils util = new Utils(); PngClass png = new PngClass(true); bool makingChanges = true; while (makingChanges) { int choice = 0; try { setStatus(png); choice = Utils.printOptions(); //Display user choices. } catch (Exception e) { Console.WriteLine("Exception: " + e); } switch (choice) { case 1: //add new png. png = new PngClass(); break; case 2: //select a png file. png = new PngClass(true); break; case 3: //select cloudcoins png.stageCoins(); break; case 4: //insert cloudcoins to png ([byte[] data][string Names][int length]) if (png.hasStagedCoins) { png.SaveCoins(); } png.updatePNG(); break; case 5: //retrieve cloudcoins from png png.removeCoins(); break; case 6: //quit makingChanges = false; //Select the png file. break; } if (png.hasCoins) { } } }// end runProgram
}// end runProgram private void setStatus(PngClass png) { //For saved coins. string sCount = "0"; string sVal = "0"; if (png.hasCoins) { List <CoinClass> coinList = png.listOfCoins; string[] hasCoinsStatus = new string[coinList.Count()]; int n = 0; foreach (CoinClass coin in coinList) { hasCoinsStatus[n] = "Name: " + coin.name + "\r\n" + "Value: " + coin.strVal; n++; }//end foreach } //For staged coins. string[] updateStagedCoins; if (png.hasStagedCoins) { int stagedVal = 0; int i = 0; updateStagedCoins = new string[png.listOfStagedCoins.Count()]; foreach (CoinClass coin in png.listOfStagedCoins) { updateStagedCoins[i] = coin.name + ": "; int temp = 0; Int32.TryParse(coin.strVal, out temp); stagedVal += temp; i++; } sVal = stagedVal.ToString(); sCount = i.ToString(); // Utils.consolePrintList(updateStagedCoins, false, "Staged coins: ", false); Console.WriteLine(" ----- "); } else { updateStagedCoins = new string[0]; } status = new string[] { "File: " + png.name + "." + png.tag, "Coins found: " + png.count, "Value of png: " + png.storedVal, "Coins staged: " + sCount, "Value of staged Coins: " + sVal }; Utils.consolePrintList(status_, false, "Updates: ", false); }//end status()