private void bt_SaveTo_Click(object sender, EventArgs e) { try { GridStorageHelper store = new GridStorageHelper(); string to = DialogHelper.GetSavePath("Save grid...", "Grid|*.xgrid"); store.SaveGrid(grid, to); } catch (FileNotFoundException) { MessageBox.Show("The file was not found.", "LifeGame", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception x) { MessageBox.Show("An error occured : " + x.Message); } }
private void LoadGrid(object to) { Grid buffer; GridStorageHelper store = new GridStorageHelper(); store.BitsIterationPassed += GridStorageHelper_BitsIterationPassed; store.CellsIterationPassed += GridStorageHelper_CellsIterationPassed; buffer = store.LoadGrid((string)to); if (finished) { this.Invoke(new Action(() => { RaiseLoadFinishedEvent(buffer); this.Close(); } )); } }