private void ImportRulesFile(string fileName) { var doc = new XmlDocument { XmlResolver = null }; doc.Load(fileName); foreach (XmlNode listNode in doc.DocumentElement.SelectNodes("MultipleSearchAndReplaceList/MultipleSearchAndReplaceItem")) { var item = new MultipleSearchAndReplaceSetting(); var subNode = listNode.SelectSingleNode(RuleEnabled); if (subNode != null) { item.Enabled = Convert.ToBoolean(subNode.InnerText); } subNode = listNode.SelectSingleNode(FindWhat); if (subNode != null) { item.FindWhat = subNode.InnerText; } subNode = listNode.SelectSingleNode(ReplaceWith); if (subNode != null) { item.ReplaceWith = subNode.InnerText; } subNode = listNode.SelectSingleNode(SearchType); if (subNode != null) { item.SearchType = subNode.InnerText; } Configuration.Settings.MultipleSearchAndReplaceList.Add(item); } }
private void buttonOpen_Click(object sender, EventArgs e) { openFileDialog1.Title = Configuration.Settings.Language.MultipleReplace.ImportRulesTitle; openFileDialog1.Filter = Configuration.Settings.Language.MultipleReplace.Rules + "|*.template"; if (openFileDialog1.ShowDialog(this) == DialogResult.OK) { var doc = new XmlDocument(); try { doc.Load(openFileDialog1.FileName); } catch (Exception exception) { MessageBox.Show(exception.Message); return; } foreach (XmlNode listNode in doc.DocumentElement.SelectNodes("MultipleSearchAndReplaceList/MultipleSearchAndReplaceItem")) { var item = new MultipleSearchAndReplaceSetting(); var subNode = listNode.SelectSingleNode("Enabled"); if (subNode != null) { item.Enabled = Convert.ToBoolean(subNode.InnerText); } subNode = listNode.SelectSingleNode("FindWhat"); if (subNode != null) { item.FindWhat = subNode.InnerText; } subNode = listNode.SelectSingleNode("ReplaceWith"); if (subNode != null) { item.ReplaceWith = subNode.InnerText; } subNode = listNode.SelectSingleNode("SearchType"); if (subNode != null) { item.SearchType = subNode.InnerText; } Configuration.Settings.MultipleSearchAndReplaceList.Add(item); } listViewReplaceList.ItemChecked -= ListViewReplaceListItemChecked; listViewReplaceList.BeginUpdate(); listViewReplaceList.Items.Clear(); foreach (var item in Configuration.Settings.MultipleSearchAndReplaceList) { AddToReplaceListView(item.Enabled, item.FindWhat, item.ReplaceWith, EnglishSearchTypeToLocal(item.SearchType)); } GeneratePreview(); listViewReplaceList.ItemChecked += ListViewReplaceListItemChecked; listViewReplaceList.EndUpdate(); } }
private void AddToRulesListView(MultipleSearchAndReplaceSetting rule) { var item = new ListViewItem(string.Empty) { Checked = rule.Enabled, Tag = rule }; item.SubItems.Add(rule.FindWhat); item.SubItems.Add(rule.ReplaceWith); item.SubItems.Add(EnglishSearchTypeToLocal(rule.SearchType)); listViewRules.Items.Add(item); }
private void ImportRulesFile(string fileName) { if (_currentGroup == null) { return; } var doc = new XmlDocument { XmlResolver = null }; doc.Load(fileName); foreach (XmlNode listNode in doc.DocumentElement.SelectNodes("MultipleSearchAndReplaceList/MultipleSearchAndReplaceItem")) { var item = new MultipleSearchAndReplaceSetting(); var subNode = listNode.SelectSingleNode(RuleEnabled); if (subNode != null) { item.Enabled = Convert.ToBoolean(subNode.InnerText); } subNode = listNode.SelectSingleNode(FindWhat); if (subNode != null) { item.FindWhat = subNode.InnerText; } subNode = listNode.SelectSingleNode(ReplaceWith); if (subNode != null) { item.ReplaceWith = subNode.InnerText; } subNode = listNode.SelectSingleNode(SearchType); if (subNode != null) { item.SearchType = subNode.InnerText; } subNode = listNode.SelectSingleNode(SearchType); if (subNode != null) { item.SearchType = subNode.InnerText; } subNode = listNode.SelectSingleNode(Description); if (subNode != null) { item.Description = subNode.InnerText; } AddToRulesListView(item); _currentGroup.Rules.Add(item); } }
private void ButtonAddClick(object sender, EventArgs e) { if (_currentGroup == null) { return; } string findText = textBoxFind.Text.RemoveControlCharacters(); if (findText.Length > 0) { string searchType = SearchTypeNormal; if (radioButtonCaseSensitive.Checked) { searchType = SearchTypeCaseSensitive; } else if (radioButtonRegEx.Checked) { searchType = SearchTypeRegularExpression; if (!RegexUtils.IsValidRegex(findText)) { MessageBox.Show(Configuration.Settings.Language.General.RegularExpressionIsNotValid); textBoxFind.Select(); return; } } var rule = new MultipleSearchAndReplaceSetting() { Enabled = true, FindWhat = findText, ReplaceWith = textBoxReplace.Text, SearchType = searchType, Description = textBoxDescription.Text }; _currentGroup.Rules.Add(rule); AddToRulesListView(rule); textBoxFind.Text = string.Empty; textBoxReplace.Text = string.Empty; textBoxDescription.Text = string.Empty; GeneratePreview(); textBoxFind.Select(); } }
private void ImportRulesFile(string fileName) { if (_currentGroup == null) return; var doc = new XmlDocument { XmlResolver = null }; doc.Load(fileName); foreach (XmlNode listNode in doc.DocumentElement.SelectNodes("MultipleSearchAndReplaceList/MultipleSearchAndReplaceItem")) { var item = new MultipleSearchAndReplaceSetting(); var subNode = listNode.SelectSingleNode(RuleEnabled); if (subNode != null) item.Enabled = Convert.ToBoolean(subNode.InnerText); subNode = listNode.SelectSingleNode(FindWhat); if (subNode != null) item.FindWhat = subNode.InnerText; subNode = listNode.SelectSingleNode(ReplaceWith); if (subNode != null) item.ReplaceWith = subNode.InnerText; subNode = listNode.SelectSingleNode(SearchType); if (subNode != null) item.SearchType = subNode.InnerText; AddToRulesListView(item); _currentGroup.Rules.Add(item); } }
private void ButtonAddClick(object sender, EventArgs e) { if (_currentGroup == null) return; string findText = textBoxFind.Text.RemoveControlCharacters(); if (findText.Length > 0) { string searchType = SearchTypeNormal; if (radioButtonCaseSensitive.Checked) searchType = SearchTypeCaseSensitive; else if (radioButtonRegEx.Checked) { searchType = SearchTypeRegularExpression; if (!Utilities.IsValidRegex(findText)) { MessageBox.Show(Configuration.Settings.Language.General.RegularExpressionIsNotValid); textBoxFind.Select(); return; } } var rule = new MultipleSearchAndReplaceSetting() { Enabled = true, FindWhat = findText, ReplaceWith = textBoxReplace.Text, SearchType = searchType }; _currentGroup.Rules.Add(rule); AddToRulesListView(rule); textBoxFind.Text = string.Empty; textBoxReplace.Text = string.Empty; GeneratePreview(); textBoxFind.Select(); } }
private void buttonImport_Click(object sender, EventArgs e) { openFileDialog1.Title = Configuration.Settings.Language.MultipleReplace.ImportRulesTitle; openFileDialog1.Filter = Configuration.Settings.Language.MultipleReplace.Rules + "|*.template"; if (openFileDialog1.ShowDialog(this) == DialogResult.OK) { var doc = new XmlDocument(); try { doc.Load(openFileDialog1.FileName); } catch (Exception exception) { MessageBox.Show(exception.Message); return; } foreach (XmlNode listNode in doc.DocumentElement.SelectNodes("MultipleSearchAndReplaceList/MultipleSearchAndReplaceItem")) { var item = new MultipleSearchAndReplaceSetting(); var subNode = listNode.SelectSingleNode(RuleEnabled); if (subNode != null) item.Enabled = Convert.ToBoolean(subNode.InnerText); subNode = listNode.SelectSingleNode(FindWhat); if (subNode != null) item.FindWhat = subNode.InnerText; subNode = listNode.SelectSingleNode(ReplaceWith); if (subNode != null) item.ReplaceWith = subNode.InnerText; subNode = listNode.SelectSingleNode(SearchType); if (subNode != null) item.SearchType = subNode.InnerText; Configuration.Settings.MultipleSearchAndReplaceList.Add(item); } listViewReplaceList.ItemChecked -= ListViewReplaceListItemChecked; listViewReplaceList.BeginUpdate(); listViewReplaceList.Items.Clear(); foreach (var item in Configuration.Settings.MultipleSearchAndReplaceList) AddToReplaceListView(item.Enabled, item.FindWhat, item.ReplaceWith, EnglishSearchTypeToLocal(item.SearchType)); GeneratePreview(); listViewReplaceList.ItemChecked += ListViewReplaceListItemChecked; listViewReplaceList.EndUpdate(); } }