private HighScore desHighScores() { string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); HighScore temp = null; try { using (FileStream fs = File.OpenRead(path + "\\HighScore.hrvs")) { IFormatter formatter = new BinaryFormatter(); temp = (HighScore)formatter.Deserialize(fs); } File.Delete(path + "\\HighScore.hrvs"); return temp; } catch(FileNotFoundException) { return new HighScore(); } }
public Form1() { InitializeComponent(); sp = new SoundPlayer(Properties.Resources.clicksound); hscore = desHighScores(); this.DoubleBuffered = true; colorp1 = Color.Blue; colorp2 = Color.Red; p1 = new Player("Player1"); p2 = new Player("Computer - Easy - 2"); finished = true; base.DoubleBuffered = true; SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); UpdateStyles(); timer = new System.Windows.Forms.Timer(); timer.Interval = 1000; timer.Tick += Timer_Tick; t1 = new ToolTip(); FileName = null; this.Icon = Properties.Resources.reversiicon; }