private void btnLoadGame_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "TheHardestGame file (*.hdr) | *.hdr"; openFileDialog1.Title = "Save game progress"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { FileName = openFileDialog1.FileName; System.Runtime.Serialization.IFormatter fmt = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); System.IO.FileStream strm = new System.IO.FileStream(FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.None); gameDoc = (GameDoc)fmt.Deserialize(strm); strm.Close(); } catch (Exception ex) { MessageBox.Show("Error: Could not read file \"" + FileName + "\" form disk Original error:" + ex.Message); FileName = null; } } Invalidate(true); }
public Level1() { InitializeComponent(); DoubleBuffered = true; gameDoc = new GameDoc(); timer = new Timer(); timer.Interval = 10; timer.Tick += new EventHandler(timer_Tick); timer.Start(); this.BackColor = Color.White; }
//private int TimerCount; //private bool timerActive; public Level1() { InitializeComponent(); panel1.Hide(); DoubleBuffered = true; gameDoc = new GameDoc(); timer = new Timer(); timer.Interval = 10; //TimerCount = 0; timer.Tick += new EventHandler(timer_Tick); timer.Stop(); //timerActive = true; this.BackColor = Color.White; }