コード例 #1
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            bool hasValidFiles = true;

            try
            {
                if (this.ValidateChildren(ValidationConstraints.Enabled))
                {
                    List <string> content = new List <string>();
                    for (int i = 0; i < audioPathDataGridView.RowCount; i++)
                    {
                        if (!File.Exists(audioPathDataGridView.Rows[i].Cells[1].Value.ToString()))
                        {
                            hasValidFiles = false;
                        }
                        content.Add(audioPathDataGridView.Rows[i].Cells[1].Value.ToString());
                    }

                    audioList = new StrList(content, this.audioListNameTextBox.Text, "_audio");

                    if (audioList.saveContent(hasValidFiles))
                    {
                        MessageBox.Show(LocRM.GetString("list", currentCulture) + this.audioListNameTextBox.Text + "_audio" + LocRM.GetString("listSaveSuccess", currentCulture));
                        this.Parent.Controls.Remove(this);
                        ListController.recoverEditingProgram(this.audioListNameTextBox.Text);
                    }
                    else
                    {
                        MessageBox.Show(LocRM.GetString("list", currentCulture) + this.audioListNameTextBox.Text + "_audio'" + LocRM.GetString("notCreated", currentCulture));
                    }
                }
                else
                {
                    MessageBox.Show(LocRM.GetString("fieldNotRight", currentCulture));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }