Пример #1
0
        /// <summary>
        /// Játék betöltésének eseménykezelője.
        /// </summary>
        private async void ViewModel_LoadGame(object sender, System.EventArgs e)
        {
            Boolean restartTimer = _timer.IsEnabled;

            _timer.Stop();

            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog(); // dialógusablak
                openFileDialog.Title  = "Loading minefield table";
                openFileDialog.Filter = "Minefield table|*.mftl";
                if (openFileDialog.ShowDialog() == true)
                {
                    // játék betöltése
                    await _model.LoadGameAsync(openFileDialog.FileName);

                    _timer.Start();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Loading was not successful!", "Minefield", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (restartTimer) // ha szükséges, elindítjuk az időzítőt
            {
                _timer.Start();
            }
        }
Пример #2
0
        private async void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            _timer.Stop();

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    await _model.LoadGameAsync(openFileDialog1.FileName);
                }
                catch (Exception)
                {
                    MessageBox.Show("Játék betöltése sikertelen!" + Environment.NewLine + "Hibás az elérési út, vagy a fájlformátum.", "Hiba!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _model.NewGame();
                }
            }

            _model.Pause();
            viewUpdate(this, null);
        }