コード例 #1
0
        void FixRecord(GameLevel level)
        {
            Game.UpdateInformationControls();

            try
            {
                NameAskerWindows nameAsker = new NameAskerWindows();
                GameRecord       record    = new GameRecord();

                nameAsker.ShowDialog();
                record.SetData(nameAsker.PlayerName, level.Name, Game.Score, DateTime.Now);

                GameRecords records = new GameRecords(GameRecords.DEFAULT_FILE_NAME);
                records.AddRecord(record);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Ошибка сохранения результатов: " + exc.Message);
            }
        }
コード例 #2
0
        static public void Save(this GameRecords gameRecords)
        {
            try
            {
                if (gameRecords.Records != null)
                {
                    using (var writer = new StreamWriter(gameRecords.FileName))
                    {
                        var serialiser = new XmlSerializer(typeof(GameRecords));

                        serialiser.Serialize(writer, gameRecords);

                        writer.Close();
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("Ошибка при сериализции: " + exc.Message);
            }
        }
コード例 #3
0
        public GameRecordsPresenter()
        {
            InitializeComponent();

            gameRecords = new GameRecords(GameRecords.DEFAULT_FILE_NAME);
        }