Example #1
0
        private async void loadPatternButton_Click(object sender, EventArgs e)
        {
            this.StopGame();
            this.ResetGameImage();

            // Set file dialog's initial directory to the location of the provided patterns.
            var patternDirectory = Path.GetFullPath(
                Path.Combine(
                    Directory.GetCurrentDirectory(),
                    RelativePathFromBinToPatterns));

            openPatternFileDialog.InitialDirectory = patternDirectory;
            if (openPatternFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var file            = openPatternFileDialog.FileName;
            var fileInputSource = new FileGameInputSource(file, this.cellParser);

            this.UpdateGameState(
                null,
                await fileInputSource.GetInitialGameState());
        }