Beispiel #1
0
        private void setListOfCoins()
        {
            List <int> coinList = returnPos(data, ccStart); //marks first "cLDc" tag in file.

            coinList.Sort();
            List <int> endCoin = returnPos(data, ccEnd);//ending sequence for the CloudCoins

            endCoin.Sort();
            List <CoinClass> coinlist = new List <CoinClass>();

            using (var startEnum = coinList.GetEnumerator())
                using (var endEnum = endCoin.GetEnumerator())
                {
                    while (startEnum.MoveNext() && endEnum.MoveNext())
                    {
                        var    start    = startEnum.Current;
                        var    end      = endEnum.Current;
                        int    startC   = start + 4;                              //Marks the first instance of cLDc in the png file + 4 to negate the cLDc type.
                        int    endC     = end;                                    //Marks the first instace of the end sequence.
                        int    diff     = (endC - startC);
                        byte[] coinData = data.Skip(startC).Take(diff).ToArray(); //the difference between the numbers will be the length of the coin.

                        try                                                       //save the png.
                        {
                            CoinClass cc = new CoinClass(coinData);
                            coinlist.Add(cc);
                        }//end try
                        catch (Exception ex)
                        {
                            Console.WriteLine("Exception caught in process: {0}", ex);
                        }//end catch
                    }
                }
            listOfCoins = coinlist;
        }//End setListOfCoins()
Beispiel #2
0
        }// end selectNewPNG()

        public void stageCoins()
        {
            listOfStagedCoins = new List <CoinClass>();
            string ccPath   = "";
            bool   addCoins = true;

            try
            {
                string[] ccPaths = Directory.GetFiles("./Bank", "*.stack");
                Utils.consolePrintList(ccPaths, true, "Coins found in bank folder: ", true); //print out a list of the available coins.
                bool getAll = Utils.getEnter("Press enter to select all files. or any other key to continue.");
                if (getAll)
                {
                    foreach (string coinPath in ccPaths)
                    {
                        // Console.WriteLine(coinPath);
                        coin = new CoinClass(coinPath);
                        Console.WriteLine("stage Coins: ");
                        listOfStagedCoins.Add(coin);
                    }
                    addCoins = false;
                    setHasStagedCoins();
                }//end if
                else
                {
                    while (addCoins)
                    {
                        int choice = Utils.getUserInput(ccPaths.Length, "Select the file you wish to use. or enter 0(zero when done)");
                        Console.WriteLine("Choice at switch: " + choice);
                        switch (choice)
                        {
                        case 0:
                            addCoins = false;
                            break;

                        default:
                            ccPath = ccPaths[choice - 1];     //Choose the cloudcoin to be added to the png.
                            coin   = new CoinClass(ccPath);
                            listOfStagedCoins.Add(coin);
                            Console.WriteLine("staged: ");
                            break;
                        }
                        setHasStagedCoins();
                    } //end while
                }     //end else



                Console.WriteLine("--");
                Console.WriteLine("staged coins? " + hasStagedCoins);
                foreach (CoinClass coin in listOfStagedCoins)
                {
                    Console.WriteLine("--");
                    Console.WriteLine("Name:       " + coin.name + "\r\n" +
                                      "Tag:       " + coin.tag + "\r\n" +
                                      "Sn:       " + coin.sn + "\r\n" +
                                      "Value:     " + coin.strVal + "              "
                                      );
                    Console.WriteLine("-staged-");
                    setStagedVal();
                }
                return;
            }//end try
            catch (Exception e)
            {
                Console.Out.WriteLine("The process failed: {0}", e.ToString());
            } //end catch
        }     // end getCoins();