/// <summary> /// Saves the grid to file /// </summary> /// <param name="path">Path to file</param> /// <param name="grid">Instance of grid</param> public static void Save(string path, Grid grid) { using (FileStream fileStream = new FileStream(path, FileMode.OpenOrCreate,FileAccess.Write, FileShare.None)) { BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(fileStream, grid.Parameters); binaryFormatter.Serialize(fileStream, grid.Cells); } }
private void Form1_Load(object sender, EventArgs e) { grid = File.Exists("save.bin") ? GridSerializer.Load("save.bin") : new Grid(Paras); Task.Factory.StartNew(new Action(() => { while (true) { try { Thread.Sleep(2000); Invoke(new UpdateDel(UpdateList)); } catch { } } })); grid.StartAsync(Threads); }
private void restartToolStripMenuItem_Click(object sender, EventArgs e) { grid.StopAsync(); Paras = ParameterLoader.FromFile("settings.cfg"); grid = new Grid(Paras); grid.StartAsync(Threads); }
private void loadFromToolStripMenuItem_Click(object sender, EventArgs e) { grid.StopAsync(); using (OpenFileDialog ofd = new OpenFileDialog()) { if (ofd.ShowDialog() == DialogResult.OK) { grid = GridSerializer.Load(ofd.FileName); } } grid.StartAsync(Threads); }