void cleanButt_Click(object sender, EventArgs e) { if (_users != null) { _users.Items.Clear(); // users = null; LadderBoard = new LadderBoard(); } }
void Form2_FormClosing(object sender, FormClosingEventArgs e) { // was interrupted _gameSpeedTimer.Stop(); gameInfo.MainForm.Show(); if (GameInfo.IsInGame) { LadderBoard.AddValid(new KeyValuePair <string, int>("Foo", _gameTetris.GetScore)); } gameInfo.MainForm.GameInfo.IsInGame = false; gameInfo.MainForm.mainDropDownLadderStrip.PerformClick(); }
protected virtual void Form1_Load(object sender, EventArgs e) { // deserialization try { Stream objstreamdeserialize = new FileStream("data.bin", FileMode.Open, FileAccess.Read, FileShare.Read); LadderBoard = (LadderBoard)_objBinaryFormatter.Deserialize(objstreamdeserialize); objstreamdeserialize.Close(); } catch (Exception ea) { LadderBoard = new LadderBoard(); } }
// Tetris Game logic Controller void gameSpeedTimer_Tick(object sender, EventArgs e) { if (!_gameTetris.PlayGame(ref _currPart)) { GameInfo.IsInGame = false; _gameSpeedTimer.Stop(); LadderBoard.AddValid(new KeyValuePair <string, int>("Foo", _gameTetris.GetScore)); MessageBox.Show("You lost :("); } else { try { _scoreLabel.Text = _scoreLabel.Text.Substring(0, 7) + _gameTetris.GetScore.ToString(); } catch { _scoreLabel.Text = "end"; } } }