private void Form1_Load(object sender, EventArgs e) { CheckForUpdateAsync(); if (!Program.IsDebug) { toolStripButton7.Visible = false; toolStripButton5.Visible = false; toolStripDropDownButton1.Visible = false; } Text += " ver. " + Application.ProductVersion; Program.TableDisplaySettings = new SettingsLoader().LoadSettings(); if (File.Exists(Path.Combine(Application.StartupPath, "Dictonaries\\Languages.txt"))) { toolStripComboBox1.Items.AddRange(File.ReadAllLines(Path.Combine(Application.StartupPath, "Dictonaries\\Languages.txt"))); string selectedLang = (string)Properties.Settings.Default["SelectedLang"]; if (!string.IsNullOrWhiteSpace(selectedLang)) { if (toolStripComboBox1.Items.Contains(selectedLang)) { toolStripComboBox1.SelectedItem = selectedLang; } } else if (toolStripComboBox1.Items.Count > 0) { toolStripComboBox1.SelectedIndex = 0; } } foreach (var item in Program.TableDisplaySettings) { listBox1.Items.Add(item); } replace_regex = new Form_regex_replace(); replace_regex.tools = Program.tools; }
private void заменаСИспользованиемRegexToolStripMenuItem_Click(object sender, EventArgs e) { if (replace_regex == null || replace_regex.IsDisposed) { replace_regex = new Form_regex_replace(); replace_regex.tools = Program.tools; } if (dataGridView1.SelectedCells.Count == 0) { return; } int cIndex = dataGridView1.SelectedCells[0].ColumnIndex; string cName = dataGridView1.Columns[cIndex].Name; if (currentTableSettings.TextTypeAndName.FindIndex(a => a.Value.Equals(cName)) != -1) { if (dataGridView1.SelectedCells[0].Value != DBNull.Value && !string.IsNullOrWhiteSpace((string)dataGridView1.SelectedCells[0].Value)) { replace_regex.SetOriginalString((string)dataGridView1.SelectedCells[0].Value); if (replace_regex.ShowDialog() == DialogResult.OK) { for (int i = 0; i < dataGridView1.RowCount; i++) { if (dataGridView1[cIndex, i].Value != DBNull.Value && !string.IsNullOrWhiteSpace((string)dataGridView1[cIndex, i].Value)) { string origText = (string)dataGridView1[cIndex, i].Value; string replText = replace_regex.ReplaceString(origText, true); if (replText.Equals(origText)) { continue; } dataGridView1[cName + "_trans", i].Value = replText; } } } } } }