private void SerializeNotCompletedGame() { BinaryFormatter binFormat = new BinaryFormatter(); NotCompletedGameCfg cfg = new NotCompletedGameCfg(_configuration, _players, NumberOfTeam, NumberOfMotion); using (Stream fStream = new FileStream(string.Format("({0})({1})({2})({3})({4})NCGConfig.dat", DateTime.Today.Day, DateTime.Today.Month, DateTime.Today.Year, DateTime.Now.TimeOfDay.Minutes, DateTime.Now.TimeOfDay.Seconds), FileMode.Create)) { binFormat.Serialize(fStream, cfg); fStream.Close(); } }
public GameWindow(NotCompletedGameCfg ncgcfg) { InitializeWindow(); _configuration = ncgcfg.Cfg; _players = ncgcfg.Players; NumberOfMotion = ncgcfg.NumberOFMotion; NumberOfTeam = ncgcfg.NumberOfTeam; InitializeTableParameters(); StartGame(); }
private NotCompletedGameCfg DeserializeNCGCfg(string fileName) { BinaryFormatter binFormat = new BinaryFormatter(); NotCompletedGameCfg configuration = new NotCompletedGameCfg(); using (Stream fStream = File.OpenRead(fileName)) { try { configuration = (NotCompletedGameCfg)binFormat.Deserialize(fStream); } catch { MessageBox.Show("Выберите файл с правильной конфигурацией ()", "Справка"); } } return(configuration); }