Added a few extra functions to "Modify selection"

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2392 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2014-01-17 17:27:33 +00:00
parent 9dd3c712bb
commit 100b22973e
3 changed files with 25 additions and 5 deletions

View File

@ -46,6 +46,10 @@ namespace Nikse.SubtitleEdit.Forms
comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.EndsWith);
comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.NoContains);
comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.RegEx);
if (!string.IsNullOrEmpty(Configuration.Settings.Language.ModifySelection.UnequalLines))
comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.UnequalLines);
if (!string.IsNullOrEmpty(Configuration.Settings.Language.ModifySelection.EqualLines))
comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.EqualLines);
}
checkBoxCaseSensitive.Checked = Configuration.Settings.Tools.ModifySelectionCaseSensitive;
@ -132,14 +136,15 @@ namespace Nikse.SubtitleEdit.Forms
string text = textBox1.Text;
if (comboBoxRule.SelectedIndex != 4)
text = text.Replace("\\r\\n", Environment.NewLine);
if (text.Length > 0)
{
for (int i = 0; i < _subtitle.Paragraphs.Count; i++)
{
if ((radioButtonSubtractFromSelection.Checked || radioButtonIntersect.Checked) && _subtitleListView.Items[i].Selected ||
!radioButtonSubtractFromSelection.Checked && !radioButtonIntersect.Checked)
{
Paragraph p = _subtitle.Paragraphs[i];
if (text.Length > 0)
{
if (comboBoxRule.SelectedIndex == 0) // Contains
{
if (checkBoxCaseSensitive.Checked && p.Text.Contains(text) || !checkBoxCaseSensitive.Checked && p.Text.ToLower().Contains(text.ToLower()))
@ -179,8 +184,19 @@ namespace Nikse.SubtitleEdit.Forms
AddToListView(p, i);
}
}
if (comboBoxRule.SelectedIndex == 5) // select unequal lines
{
if (i % 2 == 0)
AddToListView(p, i);
}
else if (comboBoxRule.SelectedIndex == 6) // select equal lines
{
if (i % 2 == 1)
AddToListView(p, i);
}
}
}
listViewFixes.EndUpdate();
if (!string.IsNullOrEmpty(Configuration.Settings.Language.ModifySelection.MatchingLinesX))
groupBoxPreview.Text = string.Format(Configuration.Settings.Language.ModifySelection.MatchingLinesX, listViewFixes.Items.Count);

View File

@ -1469,6 +1469,8 @@ namespace Nikse.SubtitleEdit.Logic
EndsWith = "Ends with",
NoContains = "Not contains",
RegEx = "Regular expression",
UnequalLines = "Unequal lines",
EqualLines = "Equal lines",
};
MultipleReplace = new LanguageStructure.MultipleReplace

View File

@ -1366,6 +1366,8 @@
public string EndsWith { get; set; }
public string NoContains { get; set; }
public string RegEx { get; set; }
public string UnequalLines { get; set; }
public string EqualLines { get; set; }
}
public class MultipleReplace