/// <summary> /// 新規追加ボタンがクリックされたときに通知を受け取る。 /// </summary> /// <param name="sender">送信元オブジェクト</param> /// <param name="e">イベントオブジェクト</param> private void OnButtonNewClick(object sender, EventArgs e) { var materialList = GetCurrentMaterialList(); var defaultName = GenerateName(materialList); var intputText = InputForm.InputForm.ShowDialog(this, Resources.MessageInputMaterialName, Resources.DialogTitleNewMaterial, defaultName); if (intputText == null) { // キャンセルされた。 return; } string newName = intputText.Trim(); try { CheckMaterialName(materialList, newName); var newRelativePath = System.IO.Path.Combine(materialList.SubDirectoryName, $"{newName}{MaterialEntryFile.EntryFileSuffix}"); var newEntryFilePath = System.IO.Path.Combine(AppData.Instance.MaterialDirectory, newRelativePath); var entryFile = MaterialUtils.CreateDefaultEntryFile( newEntryFilePath, materialList.MaterialType); entryFile.Save(); var newMaterial = new Material(newRelativePath, entryFile); materialList.Add(newMaterial); listViewMaterials.Items.Add(GenerateListViewMaterial(newMaterial)); } catch (Exception ex) { MessageBox.Show(this, ex.Message, Resources.DialogTitleError); } }