Example #1
0
        private void Button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "Structure Files (*.bmp, *.txt)|*.bmp; *.txt";
            openFileDialog1.Title  = "Select a structure file";


            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var name = openFileDialog1.FileName;

                if (name.Contains(".txt"))
                {
                    _currentSimullation.ImportFromFile(FileTypeEnum.Text, name);
                }
                else if (name.Contains(".bmp"))
                {
                    _currentSimullation.ImportFromFile(FileTypeEnum.Bmp, name);
                }

                var config = _currentSimullation.GetConfiguration();
                numericUpDownWidth.Value  = config.Width;
                numericUpDownHeight.Value = config.Height;

                _isStartedSimulation = true;
                RenderStep();

                ChangeEnableGrowOptions(false);
                ChangeEnableGrowButtons(false);
                ChangeEnableSubstructure(true);

                config = _currentSimullation.GetConfiguration();
                numericUpDownWidth.Value         = config.Width;
                numericUpDownHeight.Value        = config.Height;
                numericUpDownNumberOfGrain.Value = config.NumberOfGrains;
            }
        }