private void Initialize() { dataGridViewMain.AutoGenerateColumns = false; dataGridViewWinner.AutoGenerateColumns = false; pictureBoxSelectedImage.Image = Properties.Resources.DefaultImage; string[] seedStringArray = null; int randomNumberSeedCount = 0; if (int.TryParse(AppConfiguration.GetAppConfig("Random_number_seed_count"), out randomNumberSeedCount)) { seedStringArray = new string[randomNumberSeedCount]; for (int i = 0; i < randomNumberSeedCount; i++) { seedStringArray[i] = AppConfiguration.GetAppConfig($@"Seed_{(i+1).ToString("00")}"); } } randomNumberGenerator = new RandomNumberGenerator(seedStringArray); saveDirectoryPath = AppConfiguration.GetAppConfig("Save_directory_path"); saveDirectoryPath = KeywordPathManager.GetOriginalPath(saveDirectoryPath); //null, empty인 경우 바탕화면으로 설정됨. jsonFilePath = AppConfiguration.GetAppConfig("Json_file_path"); if (string.IsNullOrEmpty(jsonFilePath) == false) { jsonFilePath = KeywordPathManager.GetOriginalPath(jsonFilePath); JsonCharacter jsonCharacter = new JsonCharacter(); if (JsonCharacter.LoadJsonFile(jsonFilePath, out jsonCharacter) == false) { MessageBox.Show($@"Json 파일 읽어오기 실패.{Environment.NewLine}{AppConfiguration.GetAppConfig("Json_file_path")}"); jsonFilePath = string.Empty; } else { JsonCharacter.SetInstance(jsonCharacter); } } dataGridViewMain.DataSource = new BindingList <Character>(JsonCharacter.GetInstance().characterList); }
private void buttonLoad_Click(object sender, EventArgs e) { openJsonFileDialog.InitialDirectory = saveDirectoryPath; openJsonFileDialog.FileName = string.Empty; if (DialogResult.OK != openJsonFileDialog.ShowDialog()) { return; } jsonFilePath = openJsonFileDialog.FileName; JsonCharacter jsonCharacter = new JsonCharacter(); if (JsonCharacter.LoadJsonFile(jsonFilePath, out jsonCharacter) == false) { MessageBox.Show($@"Json 파일 오류. {AppConfiguration.GetAppConfig("Json_file_path")}"); } else { JsonCharacter.SetInstance(jsonCharacter); } dataGridViewMain.DataSource = new BindingList <Character>(JsonCharacter.GetInstance().characterList); AppConfiguration.SetAppConfig("Json_file_path", KeywordPathManager.GetKeywordPath(jsonFilePath)); }