private void btn_add_Click(object sender, EventArgs e) { OpenFileDialog file = new OpenFileDialog(); file.Filter = "Programs (*.exe)|*.exe|All Files (*.*)|*.*"; file.Multiselect = false; file.RestoreDirectory = true; if (file.ShowDialog() == DialogResult.OK) { PrgNamePath prg; int index = (file.FileName.LastIndexOf("\\")); if (index < 0) { return; } string name = file.FileName.Substring(index + 1); prg = new PrgNamePath(name, file.FileName, true); FindProgram findProgram = new FindProgram(prg); if (programs.Find(findProgram.FindItem) == null) { programs.Add(prg); lV_list.Items.Add(prg); } OnEnableApply(true); } }
// Constructor public FindProgramComponent() { _viewModel = new FindProgram { FindFileCommand = new RelayCommand(exe => OpenFileDialog()) }; _viewModel.PropertyChanged += ViewModel_PropertyChanged; }