private void btnLoad_Click(object sender, EventArgs e) { // Displays an OpenFileDialog so the user can select a game file OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "BIN|*.bin"; openFileDialog1.Title = "Select a game bin file"; // Show the Dialog if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ClearTable(); AllData ad = new AllData(); IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read, FileShare.Read); ad = (AllData)formatter.Deserialize(stream); stream.Close(); foreach (var item in ad) { string sType = item.GetType().Name; if (sType == "StoneList") { sel = new StoneList(); foreach (var element in item as StoneList) { Debug.Print(element.ToString()); sel.AddStone(element); } } else if (sType == "StockList") { skl = new StockList(); foreach (var element in item as StockList) { Debug.Print(element.ToString()); skl.AddStock(element); } } else if (sType == "Scores") { sc = new Scores(); sc = item as Scores; } } RestoreGame(); // Debug only //ListClasses(); } }
private void StonesInOrder() { skl = new StockList(); //Stones set to stock on order for (int k = 0; k < 2; ++k) { for (int i = 0; i < 6; ++i) { for (int j = 0; j < 6; ++j) { Stock s = new Stock(k * 36 + (i) * 6 + j, sFruitName[i], cStoneColor[j]); skl.AddStock(s); } } } //// Debug Only //foreach (var stock in skl) //{ // Debug.Print("In Order: " + stock.ToString()); //} }