mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-26 05:02:36 +01:00
Testing waveform move perf
This commit is contained in:
parent
4110ebd2e8
commit
ff629f512e
@ -94,16 +94,27 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
private bool _saveColumnWidthChanges;
|
||||
private Timer _setLastColumnWidthTimer;
|
||||
|
||||
public class SyntaxColorLineParamter
|
||||
public class SyntaxColorLineParameter
|
||||
{
|
||||
public List<Paragraph> Paragraphs { get; set; }
|
||||
public int Index { get; set; }
|
||||
public Paragraph Paragraph { get; set; }
|
||||
}
|
||||
|
||||
private readonly List<SyntaxColorLineParamter> _syntaxColorList = new List<SyntaxColorLineParamter>();
|
||||
public class SetStartAndDurationParameter
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public Paragraph Paragraph { get; set; }
|
||||
public Paragraph Next { get; set; }
|
||||
public Paragraph Prev { get; set; }
|
||||
}
|
||||
|
||||
private readonly List<SyntaxColorLineParameter> _syntaxColorList = new List<SyntaxColorLineParameter>();
|
||||
private readonly List<SetStartAndDurationParameter> _setStartAndDurationList = new List<SetStartAndDurationParameter>();
|
||||
private static readonly object SyntaxColorListLock = new object();
|
||||
private static readonly object SetStartTimeAndDurationLock = new object();
|
||||
private readonly Timer _syntaxColorLineTimer;
|
||||
private readonly Timer _setStartAndDurationTimer;
|
||||
|
||||
public int FirstVisibleIndex { get; set; } = -1;
|
||||
|
||||
@ -386,9 +397,12 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
ShowGapColumn(LanguageSettings.Current.General.Gap);
|
||||
}
|
||||
|
||||
_syntaxColorLineTimer = new Timer { Interval = 50 };
|
||||
_syntaxColorLineTimer = new Timer { Interval = 43 };
|
||||
_syntaxColorLineTimer.Tick += SyntaxColorLineTimerTick;
|
||||
|
||||
_setStartAndDurationTimer = new Timer { Interval = 49 };
|
||||
_setStartAndDurationTimer.Tick += SetStartAndDurationTimerTick;
|
||||
|
||||
SubtitleListViewLastColumnFill(this, null);
|
||||
|
||||
FullRowSelect = true;
|
||||
@ -1351,6 +1365,28 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void SetStartAndDurationTimerTick(object sender, EventArgs e)
|
||||
{
|
||||
var hashSet = new HashSet<int>();
|
||||
lock (SetStartTimeAndDurationLock)
|
||||
{
|
||||
_setStartAndDurationTimer.Stop();
|
||||
for (int i = _setStartAndDurationList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var item = _setStartAndDurationList[i];
|
||||
if (!hashSet.Contains(item.Index))
|
||||
{
|
||||
if (IsValidIndex(item.Index))
|
||||
{
|
||||
SetStartTimeAndDuration(item.Index, item.Paragraph, item.Next, item.Prev);
|
||||
}
|
||||
hashSet.Add(item.Index);
|
||||
}
|
||||
}
|
||||
_setStartAndDurationList.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Can handle multiple events to same line - but not line adding/splitting.
|
||||
/// </summary>
|
||||
@ -1364,11 +1400,29 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
lock (SyntaxColorListLock)
|
||||
{
|
||||
_syntaxColorLineTimer.Stop();
|
||||
_syntaxColorList.Add(new SyntaxColorLineParamter { Index = i, Paragraphs = paragraphs, Paragraph = paragraph });
|
||||
_syntaxColorList.Add(new SyntaxColorLineParameter { Index = i, Paragraphs = paragraphs, Paragraph = paragraph });
|
||||
_syntaxColorLineTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Can handle multiple events to same line - but not line adding/splitting.
|
||||
/// </summary>
|
||||
public void SetStartTimeAndDurationBackground(int index, Paragraph paragraph, Paragraph next, Paragraph prev)
|
||||
{
|
||||
if (_settings == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (SetStartTimeAndDurationLock)
|
||||
{
|
||||
_setStartAndDurationTimer.Stop();
|
||||
_setStartAndDurationList.Add(new SetStartAndDurationParameter { Index = index, Paragraph = paragraph, Next = next, Prev = prev });
|
||||
_setStartAndDurationTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public void SyntaxColorLine(List<Paragraph> paragraphs, int i, Paragraph paragraph)
|
||||
{
|
||||
if (UseSyntaxColoring && _settings != null && IsValidIndex(i))
|
||||
|
@ -1163,7 +1163,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
InitializeListViewEditBoxTimeOnly(p);
|
||||
SubtitleListview1.SetStartTimeAndDuration(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
SubtitleListview1.SetStartTimeAndDurationBackground(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
UpdateSourceView();
|
||||
}
|
||||
|
||||
@ -1238,7 +1238,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged;
|
||||
timeUpDownStartTime.TimeCode = paragraph.StartTime;
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged;
|
||||
SubtitleListview1.SetStartTimeAndDuration(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
SubtitleListview1.SetStartTimeAndDurationBackground(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
|
||||
var durationInSeconds = (decimal)paragraph.Duration.TotalSeconds;
|
||||
if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum)
|
||||
@ -1277,7 +1277,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
index = _subtitle.GetIndex(current);
|
||||
|
||||
SubtitleListview1.SetStartTimeAndDuration(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
SubtitleListview1.SetStartTimeAndDurationBackground(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
|
||||
if (index == selectedIndex)
|
||||
{
|
||||
@ -1313,7 +1313,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
original.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds;
|
||||
}
|
||||
|
||||
SubtitleListview1.SetStartTimeAndDuration(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
SubtitleListview1.SetStartTimeAndDurationBackground(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1357,7 +1357,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
SubtitleListview1.SetStartTimeAndDuration(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
SubtitleListview1.SetStartTimeAndDurationBackground(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1));
|
||||
}
|
||||
|
||||
beforeParagraph.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds;
|
||||
|
Loading…
Reference in New Issue
Block a user