Example #1
0
 /// <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);
     }
 }
Example #2
0
        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);
        }
Example #3
0
 private void restartToolStripMenuItem_Click(object sender, EventArgs e)
 {
     grid.StopAsync();
     Paras = ParameterLoader.FromFile("settings.cfg");
     grid = new Grid(Paras);
     grid.StartAsync(Threads);
 }
Example #4
0
 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);
 }