private void Reset() { //Reset scores txtMessageDisplay.Text = "New game"; sc = new Scores(); // Empty lists //fil.Fields.Clear(); sel.Stones.Clear(); skl.Stocks.Clear(); //Rebuild Field and Stone List for (int i = 0; i < sRow.Length; ++i) { for (int j = 0; j < sColumn.Length; ++j) { Button b = (Button)FindControl(sColumn[j] + sRow[i]); b.Attributes.Add("fruit", ""); b.Style.Add("backround-image", "none"); //Field field = new Field(sColumn[j] + sRow[i], b); //fil.AddField(field); Stone stone = new Stone(sColumn[j] + sRow[i], "", Color.Black); sel.AddStone(stone); } } }
protected void btnLoad_Click(object sender, EventArgs e) { if (FileUploadControl.HasFile) { try { string filename = Path.GetFileName(FileUploadControl.FileName); AllData ad = new AllData(); IFormatter formatter = new BinaryFormatter(); ad = (AllData)formatter.Deserialize(FileUploadControl.FileContent); 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(); } catch (Exception ex) { Debug.Print(ex.ToString()); } } }