private void frmScores_FormClosing(object sender, FormClosingEventArgs e) { if (btnAdd.Enabled) { HighScoreList.add(new HighScores(txtName.Text, curScore, coinsAdded, difficulty)); } GTools.saveHighScores(GTools.saveFile); }
public static void loadHighScores(string savePath, string saveFile) { Directory.CreateDirectory(savePath); try { if (System.IO.File.Exists(saveFile)) { HighScoreList.hsList.Clear(); HighScoreList.hsList = JsonConvert.DeserializeObject <List <HighScores> >(System.IO.File.ReadAllText(saveFile)); HighScoreList.hsList = HighScoreList.hsList.OrderByDescending(p => p.score).ToList(); } else { GTools.createFile(saveFile, "[ ]"); loadHighScores(savePath, saveFile); } } catch (Exception exc) { System.Diagnostics.Debug.WriteLine(exc.Message + " Load User Error.\n"); } }
private void dgvInit() { dtDriveFiles = null; dtDriveFiles = GTools.ToDataTable <HighScores>(HighScoreList.hsList); dgvHighScores.DataSource = dtDriveFiles; }
private void frmMain_FormClosing(object sender, FormClosingEventArgs e) { GTools.saveHighScores(saveFile); }
public frmMain() { InitializeComponent(); GTools.loadHighScores(savePath, saveFile); }