public ReplaceString Return() { ReplaceString replaceString = new ReplaceString() { SearchStringText = searchStringEdit.Text, ReplaceStringText = replaceStringEdit.Text }; return(replaceString); }
private void replaceStringBtn_Click(object sender, EventArgs e) { if (PathToDirectory.Count > 0) { ClearCheckString(); ActiveButton(false); ReplaceString replaceStringModel = new ReplaceString(); using (ReplaceStringFm replaceStringFm = new ReplaceStringFm(false)) { if (replaceStringFm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { replaceStringModel = replaceStringFm.Return(); } else { ActiveButton(true); return; } } progressLbl.Text = "Производим замену строки"; progressLbl.Refresh(); updateProgress.Properties.Step = 1; updateProgress.Properties.PercentView = true; updateProgress.Properties.Maximum = PathToDirectory.Count; updateProgress.Properties.Minimum = 0; foreach (var item in PathToDirectory) { if (SearchRussianString(item.Path, replaceStringModel.SearchStringText, replaceStringModel.ReplaceStringText)) { item.CheckString = true; } updateProgress.PerformStep(); updateProgress.Update(); } updateProgress.EditValue = 0; LoadData(); progressLbl.Text = "Замена произведена, ячейки где была выполнена замена - отмечены"; progressLbl.Refresh(); ActiveButton(true); } else { MessageBox.Show("Не найдено файлы в папке!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }