private void AddInputModel(string filePath) { var svfModel = new SvfModel { ModelTitle = $@"Model {svfModelBindingSource.Count + 1}#", ModelPath = filePath }; if (svfModel.ModelPath.EndsWith(@"zip")) { svfModel.ModelTitle = Path.GetFileNameWithoutExtension(svfModel.ModelPath); } foreach (SvfModel item in svfModelBindingSource) { if (item == null) { continue; } if (item.ModelPath == svfModel.ModelPath) { MessageBox.Show(this, @"This model already add to list!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } svfModelBindingSource.Add(svfModel); }
private void btnAdd_Click(object sender, EventArgs e) { if (dlgSelectFile.ShowDialog(this) == DialogResult.OK) { foreach (var filePath in dlgSelectFile.FileNames) { var svfModel = new SvfModel { ModelTitle = $@"Model {svfModelBindingSource.Count + 1}#", ModelPath = filePath }; if (svfModel.ModelPath.EndsWith(@"zip")) { svfModel.ModelTitle = Path.GetFileNameWithoutExtension(svfModel.ModelPath); } foreach (SvfModel item in svfModelBindingSource) { if (item == null) { continue; } if (item.ModelPath == svfModel.ModelPath) { MessageBox.Show(this, @"This model already add to list!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } svfModelBindingSource.Add(svfModel); } } }