mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
parent
738e8404e7
commit
6206d0dc1e
@ -127,6 +127,24 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
FindNext();
|
||||
buttonFind.Focus();
|
||||
SetRegEx();
|
||||
}
|
||||
|
||||
private void SetRegEx()
|
||||
{
|
||||
if (radioButtonRegEx.Checked)
|
||||
{
|
||||
try
|
||||
{
|
||||
_regEx = new Regex(RegexUtils.FixNewLine(FindText), RegexOptions.Compiled, TimeSpan.FromSeconds(5));
|
||||
DialogResult = DialogResult.OK;
|
||||
_findAndReplaceMethods.FindDialogFind(FindText, FindReplaceType);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(exception.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FindNext()
|
||||
@ -148,19 +166,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
DialogResult = DialogResult.OK;
|
||||
_findAndReplaceMethods.FindDialogFind(FindText, FindReplaceType);
|
||||
}
|
||||
else if (radioButtonRegEx.Checked)
|
||||
{
|
||||
try
|
||||
{
|
||||
_regEx = new Regex(RegexUtils.FixNewLine(searchText), RegexOptions.Compiled, TimeSpan.FromSeconds(5));
|
||||
DialogResult = DialogResult.OK;
|
||||
_findAndReplaceMethods.FindDialogFind(FindText, FindReplaceType);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(exception.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TextBoxFind_KeyDown(object sender, KeyEventArgs e)
|
||||
@ -259,6 +264,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
labelCount.Text = string.Empty;
|
||||
return;
|
||||
}
|
||||
|
||||
SetRegEx();
|
||||
var count = GetFindDialogHelper(0).FindCount(_subtitle, checkBoxWholeWord.Checked);
|
||||
var colorIfFound = Configuration.Settings.General.UseDarkTheme ? Color.FromArgb(9, 128, 204) : Color.Blue;
|
||||
labelCount.ForeColor = count > 0 ? colorIfFound : Color.Red;
|
||||
@ -304,20 +311,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
DialogResult = DialogResult.OK;
|
||||
_findAndReplaceMethods.FindDialogFindPrevious(FindText);
|
||||
}
|
||||
else if (radioButtonRegEx.Checked)
|
||||
{
|
||||
try
|
||||
{
|
||||
_regEx = new Regex(RegexUtils.FixNewLine(searchText), RegexOptions.Compiled, TimeSpan.FromSeconds(5));
|
||||
DialogResult = DialogResult.OK;
|
||||
_findAndReplaceMethods.FindDialogFindPrevious(FindText);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(exception.Message);
|
||||
}
|
||||
}
|
||||
|
||||
SetRegEx();
|
||||
buttonFindPrev.Focus();
|
||||
}
|
||||
}
|
||||
|
@ -20966,6 +20966,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
_findHelper = new FindReplaceDialogHelper(new ReplaceType { FindType = FindType.RegEx }, string.Format(_language.DoubleWordsViaRegEx, regex), regex, string.Empty, _subtitleListViewIndex);
|
||||
_findHelper.FindReplaceType.SearchTranslation = true;
|
||||
_findHelper.FindReplaceType.SearchOriginal = _subtitleOriginal != null && _subtitleOriginal.Paragraphs.Count > 0;
|
||||
|
||||
ReloadFromSourceView();
|
||||
FindNext();
|
||||
@ -35212,8 +35214,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void toolStripMenuItemWebVttStyle_Click(object sender, EventArgs e)
|
||||
{
|
||||
var idx = FirstSelectedIndex;
|
||||
if (idx == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var styles = WebVttHelper.GetStyles(_subtitle.Header);
|
||||
using (var form = new WebVttStylePicker(styles))
|
||||
using (var form = new WebVttStylePicker(styles, _subtitle.GetParagraphOrDefault(idx)))
|
||||
{
|
||||
form.ShowDialog(this);
|
||||
}
|
||||
|
@ -190,6 +190,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
buttonReplace.Focus();
|
||||
SetRegEx();
|
||||
}
|
||||
|
||||
private void ButtonReplaceAllClick(object sender, EventArgs e)
|
||||
@ -205,6 +206,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
buttonReplaceAll.Focus();
|
||||
SetRegEx();
|
||||
}
|
||||
|
||||
private void Validate(string searchText)
|
||||
@ -242,6 +244,22 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
Find();
|
||||
buttonFind.Focus();
|
||||
SetRegEx();
|
||||
}
|
||||
|
||||
private void SetRegEx()
|
||||
{
|
||||
if (radioButtonRegEx.Checked)
|
||||
{
|
||||
try
|
||||
{
|
||||
_regEx = new Regex(RegexUtils.FixNewLine(FindText), RegexOptions.Compiled, TimeSpan.FromSeconds(5));
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(exception.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Find()
|
||||
|
@ -11,11 +11,12 @@ namespace Nikse.SubtitleEdit.Forms.VTT
|
||||
private readonly List<WebVttStyle> _styles;
|
||||
public List<WebVttStyle> ImportExportStyles { get; set; }
|
||||
|
||||
public WebVttStylePicker(List<WebVttStyle> styles)
|
||||
public WebVttStylePicker(List<WebVttStyle> styles, Paragraph getParagraphOrDefault)
|
||||
{
|
||||
InitializeComponent();
|
||||
UiUtil.FixFonts(this);
|
||||
|
||||
ImportExportStyles = new List<WebVttStyle>();
|
||||
_styles = styles;
|
||||
listViewExportStyles.Columns[0].Width = listViewExportStyles.Width - 20;
|
||||
foreach (var style in _styles)
|
||||
@ -33,7 +34,13 @@ namespace Nikse.SubtitleEdit.Forms.VTT
|
||||
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
foreach (ListViewItem item in listViewExportStyles.Items)
|
||||
{
|
||||
if (item.Checked)
|
||||
{
|
||||
ImportExportStyles.Add((WebVttStyle)item.Tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WebVttImportExport_KeyDown(object sender, KeyEventArgs e)
|
||||
|
@ -95,7 +95,14 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
Match match;
|
||||
try
|
||||
{
|
||||
_regEx = new Regex(FindText, RegexOptions.None, TimeSpan.FromSeconds(5));
|
||||
if (_regEx == null)
|
||||
{
|
||||
_regEx = new Regex(FindText, RegexOptions.None, TimeSpan.FromSeconds(5));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
match = _regEx.Match(text, startIndex);
|
||||
}
|
||||
catch (RegexMatchTimeoutException exception)
|
||||
|
Loading…
Reference in New Issue
Block a user