mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 10:42:35 +01:00
Minor performance optimization
This commit is contained in:
parent
c1754a0343
commit
800f01cc65
@ -11,6 +11,7 @@ using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Nikse.SubtitleEdit.Core.Forms;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Controls
|
||||
{
|
||||
@ -486,7 +487,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
|
||||
public void SetPosition(double startPositionSeconds, Subtitle subtitle, double currentVideoPositionSeconds, int subtitleIndex, ListView.SelectedIndexCollection selectedIndexes)
|
||||
{
|
||||
if (TimeSpan.FromTicks(DateTime.UtcNow.Ticks - _lastMouseWheelScroll).TotalSeconds > 0.25)
|
||||
if (TimeSpan.FromTicks(Stopwatch.GetTimestamp() - _lastMouseWheelScroll).TotalSeconds > 0.25)
|
||||
{ // don't set start position when scrolling with mouse wheel as it will make a bad (jumping back) forward scrolling
|
||||
StartPositionSeconds = startPositionSeconds;
|
||||
}
|
||||
@ -1195,7 +1196,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
_firstMove = true;
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
_buttonDownTimeTicks = DateTime.UtcNow.Ticks;
|
||||
_buttonDownTimeTicks = Stopwatch.GetTimestamp();
|
||||
|
||||
Cursor = Cursors.VSplit;
|
||||
double seconds = RelativeXPositionToSeconds(e.X);
|
||||
@ -2086,7 +2087,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
if (e.Button == MouseButtons.Left && OnSingleClick != null)
|
||||
{
|
||||
var diff = Math.Abs(_mouseMoveStartX - e.X);
|
||||
if (_mouseMoveStartX == -1 || _mouseMoveEndX == -1 || diff < 10 && TimeSpan.FromTicks(DateTime.UtcNow.Ticks - _buttonDownTimeTicks).TotalSeconds < 0.25)
|
||||
if (_mouseMoveStartX == -1 || _mouseMoveEndX == -1 || diff < 10 && TimeSpan.FromTicks(Stopwatch.GetTimestamp() - _buttonDownTimeTicks).TotalSeconds < 0.25)
|
||||
{
|
||||
if (ModifierKeys == Keys.Shift && SelectedParagraph != null)
|
||||
{
|
||||
@ -2326,7 +2327,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
else
|
||||
{
|
||||
StartPositionSeconds += delta / 256.0;
|
||||
_lastMouseWheelScroll = DateTime.UtcNow.Ticks;
|
||||
_lastMouseWheelScroll = Stopwatch.GetTimestamp();
|
||||
if (_currentVideoPositionSeconds < _startPositionSeconds || _currentVideoPositionSeconds >= EndPositionSeconds)
|
||||
{
|
||||
OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_startPositionSeconds, null));
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Nikse.SubtitleEdit.Core.Common;
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@ -30,7 +31,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
KeyDown += SETextBox_KeyDown;
|
||||
|
||||
// To fix issue where WM_LBUTTONDOWN got wrong "SelectedText" (only in undocked mode)
|
||||
GotFocus += (sender, args) => { _gotFocusTicks = DateTime.UtcNow.Ticks; };
|
||||
GotFocus += (sender, args) => { _gotFocusTicks = Stopwatch.GetTimestamp(); };
|
||||
}
|
||||
|
||||
private void SetAlignment()
|
||||
@ -208,7 +209,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
if (_dragFromThis)
|
||||
{
|
||||
_dragFromThis = false;
|
||||
var milliseconds = (DateTime.UtcNow.Ticks - _dragStartTicks) / 10000;
|
||||
var milliseconds = (Stopwatch.GetTimestamp() - _dragStartTicks) / 10000;
|
||||
if (milliseconds < 400)
|
||||
{
|
||||
SelectionLength = 0;
|
||||
@ -337,12 +338,12 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
|
||||
if (m.Msg == WM_LBUTTONDOWN)
|
||||
{
|
||||
var milliseconds = (DateTime.UtcNow.Ticks - _gotFocusTicks) / 10000;
|
||||
var milliseconds = (Stopwatch.GetTimestamp() - _gotFocusTicks) / 10000;
|
||||
if (milliseconds > 10)
|
||||
{
|
||||
_dragText = SelectedText;
|
||||
_dragStartFrom = SelectionStart;
|
||||
_dragStartTicks = DateTime.UtcNow.Ticks;
|
||||
_dragStartTicks = Stopwatch.GetTimestamp();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
var buffer = new byte[4096];
|
||||
_bytesWavTotal = new FileInfo(waveFileName).Length;
|
||||
_bytesWavRead = 0;
|
||||
_startTicks = DateTime.UtcNow.Ticks;
|
||||
_startTicks = Stopwatch.GetTimestamp();
|
||||
timer1.Start();
|
||||
using (var source = File.OpenRead(waveFileName))
|
||||
{
|
||||
@ -605,7 +605,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
return;
|
||||
}
|
||||
|
||||
var durationMs = (DateTime.UtcNow.Ticks - _startTicks) / 10_000;
|
||||
var durationMs = (Stopwatch.GetTimestamp() - _startTicks) / 10_000;
|
||||
var msPerFrame = (float)durationMs / _bytesWavRead;
|
||||
var estimatedTotalMs = msPerFrame * _bytesWavTotal;
|
||||
var estimatedLeft = ProgressHelper.ToProgressTime(estimatedTotalMs - durationMs);
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -227,7 +228,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
var buffer = new byte[4096];
|
||||
_bytesWavTotal = new FileInfo(waveFileName).Length;
|
||||
_bytesWavRead = 0;
|
||||
_startTicks = DateTime.UtcNow.Ticks;
|
||||
_startTicks = Stopwatch.GetTimestamp();
|
||||
timer1.Start();
|
||||
using (var source = File.OpenRead(waveFileName))
|
||||
{
|
||||
@ -325,7 +326,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
return;
|
||||
}
|
||||
|
||||
var durationMs = (DateTime.UtcNow.Ticks - _startTicks) / 10_000;
|
||||
var durationMs = (Stopwatch.GetTimestamp() - _startTicks) / 10_000;
|
||||
var msPerFrame = (float)durationMs / _bytesWavRead;
|
||||
var estimatedTotalMs = msPerFrame * _bytesWavTotal;
|
||||
var estimatedLeft = ProgressHelper.ToProgressTime(estimatedTotalMs - durationMs);
|
||||
|
@ -929,7 +929,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
var process = GetWhisperProcess(inputFile, model.Name, _languageCode, checkBoxTranslateToEnglish.Checked, OutputHandler);
|
||||
var sw = Stopwatch.StartNew();
|
||||
_outputText.Add($"Calling whisper ({Configuration.Settings.Tools.WhisperChoice}) with : {process.StartInfo.FileName} {process.StartInfo.Arguments}{Environment.NewLine}");
|
||||
_startTicks = DateTime.UtcNow.Ticks;
|
||||
_startTicks = Stopwatch.GetTimestamp();
|
||||
_videoInfo = UiUtil.GetVideoInfo(waveFileName);
|
||||
timer1.Start();
|
||||
if (!_batchMode)
|
||||
@ -1573,7 +1573,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
return;
|
||||
}
|
||||
|
||||
var durationMs = (DateTime.UtcNow.Ticks - _startTicks) / 10_000;
|
||||
var durationMs = (Stopwatch.GetTimestamp() - _startTicks) / 10_000;
|
||||
|
||||
labelElapsed.Text = new TimeCode(durationMs).ToShortDisplayString();
|
||||
if (_endSeconds <= 0 || _videoInfo == null)
|
||||
|
@ -802,7 +802,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
process.Start();
|
||||
process.BeginOutputReadLine();
|
||||
process.BeginErrorReadLine();
|
||||
_startTicks = DateTime.UtcNow.Ticks;
|
||||
_startTicks = Stopwatch.GetTimestamp();
|
||||
timer1.Start();
|
||||
|
||||
while (!process.HasExited)
|
||||
@ -855,7 +855,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
var durationMs = (DateTime.UtcNow.Ticks - _startTicks) / 10_000;
|
||||
var durationMs = (Stopwatch.GetTimestamp() - _startTicks) / 10_000;
|
||||
var msPerFrame = (float)durationMs / _processedFrames;
|
||||
var estimatedTotalMs = msPerFrame * _totalFrames;
|
||||
var estimatedLeft = ProgressHelper.ToProgressTime(estimatedTotalMs - durationMs);
|
||||
|
@ -199,7 +199,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
process.BeginErrorReadLine();
|
||||
_totalFrames = (long)Math.Round(float.Parse(comboBoxFrameRate.Text, CultureInfo.CurrentCulture) * (float)numericUpDownDurationMinutes.Value * 60.0f);
|
||||
progressBar1.Maximum = (int)_totalFrames;
|
||||
_startTicks = DateTime.UtcNow.Ticks;
|
||||
_startTicks = Stopwatch.GetTimestamp();
|
||||
timer1.Start();
|
||||
while (!process.HasExited)
|
||||
{
|
||||
@ -314,7 +314,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
var durationMs = (DateTime.UtcNow.Ticks - _startTicks) / 10_000;
|
||||
var durationMs = (Stopwatch.GetTimestamp() - _startTicks) / 10_000;
|
||||
var msPerFrame = (float)durationMs / _processedFrames;
|
||||
var estimatedTotalMs = msPerFrame * _totalFrames;
|
||||
var estimatedLeft = ProgressHelper.ToProgressTime(estimatedTotalMs - durationMs);
|
||||
|
@ -935,7 +935,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
process.Start();
|
||||
process.BeginOutputReadLine();
|
||||
process.BeginErrorReadLine();
|
||||
_startTicks = DateTime.UtcNow.Ticks;
|
||||
_startTicks = Stopwatch.GetTimestamp();
|
||||
timer1.Start();
|
||||
|
||||
while (!process.HasExited)
|
||||
@ -965,7 +965,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
process.Start();
|
||||
process.BeginOutputReadLine();
|
||||
process.BeginErrorReadLine();
|
||||
_startTicks = DateTime.UtcNow.Ticks;
|
||||
_startTicks = Stopwatch.GetTimestamp();
|
||||
timer1.Start();
|
||||
|
||||
while (!process.HasExited)
|
||||
@ -1054,7 +1054,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
process.Start();
|
||||
process.BeginOutputReadLine();
|
||||
process.BeginErrorReadLine();
|
||||
_startTicks = DateTime.UtcNow.Ticks;
|
||||
_startTicks = Stopwatch.GetTimestamp();
|
||||
timer1.Start();
|
||||
|
||||
while (!process.HasExited)
|
||||
@ -1185,7 +1185,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
var durationMs = (DateTime.UtcNow.Ticks - _startTicks) / 10_000;
|
||||
var durationMs = (Stopwatch.GetTimestamp() - _startTicks) / 10_000;
|
||||
var msPerFrame = (float)durationMs / _processedFrames;
|
||||
var estimatedTotalMs = msPerFrame * _totalFrames;
|
||||
var estimatedLeft = ProgressHelper.ToProgressTime(estimatedTotalMs - durationMs);
|
||||
|
@ -2456,7 +2456,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private void AutoSave(bool force = false)
|
||||
{
|
||||
if (!Configuration.Settings.General.AutoSave ||
|
||||
DateTime.UtcNow.Ticks - _lastAutoSave < 10000 * 3000 && !force) // only check for auto save evety 3 seconds
|
||||
Stopwatch.GetTimestamp() - _lastAutoSave < 10000 * 3000 && !force) // only check for auto save evety 3 seconds
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -2476,7 +2476,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void DoAutoSave()
|
||||
{
|
||||
_lastAutoSave = DateTime.UtcNow.Ticks + 1009000;
|
||||
_lastAutoSave = Stopwatch.GetTimestamp() + 1009000;
|
||||
var currentSubtitleHash = GetFastSubtitleHash();
|
||||
if (_changeSubtitleHash != currentSubtitleHash && _lastDoNotPrompt != currentSubtitleHash && _subtitle?.Paragraphs.Count > 0)
|
||||
{
|
||||
@ -2493,7 +2493,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SaveOriginalSubtitle(GetCurrentSubtitleFormat(), true);
|
||||
}
|
||||
|
||||
_lastAutoSave = DateTime.UtcNow.Ticks;
|
||||
_lastAutoSave = Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
private bool ContinueNewOrExit()
|
||||
@ -2672,10 +2672,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow.Ticks - _lastHistoryTicks) > 10000 * 500) // only if last change was longer ago than 500 milliseconds
|
||||
if ((Stopwatch.GetTimestamp() - _lastHistoryTicks) > 10000 * 500) // only if last change was longer ago than 500 milliseconds
|
||||
{
|
||||
MakeHistoryForUndo(description);
|
||||
_lastHistoryTicks = DateTime.UtcNow.Ticks;
|
||||
_lastHistoryTicks = Stopwatch.GetTimestamp();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2887,7 +2887,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
_lastAutoSave = DateTime.UtcNow.Ticks;
|
||||
_lastAutoSave = Stopwatch.GetTimestamp();
|
||||
bool videoFileLoaded = false;
|
||||
_formatManuallyChanged = false;
|
||||
var file = new FileInfo(fileName);
|
||||
@ -6499,7 +6499,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ShowSourceLineNumber();
|
||||
_sourceViewChange = true;
|
||||
labelStatus.Text = string.Empty;
|
||||
_sourceTextTicks = DateTime.UtcNow.Ticks;
|
||||
_sourceTextTicks = Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
private bool ShowProfileInStatusBar => Configuration.Settings.General.CurrentProfile != "Default";
|
||||
@ -11513,7 +11513,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void TextBoxListViewTextKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
_listViewTextTicks = DateTime.UtcNow.Ticks;
|
||||
_listViewTextTicks = Stopwatch.GetTimestamp();
|
||||
|
||||
if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.ShiftKey)
|
||||
{
|
||||
@ -11810,7 +11810,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
// last key down in text
|
||||
_lastTextKeyDownTicks = DateTime.UtcNow.Ticks;
|
||||
_lastTextKeyDownTicks = Stopwatch.GetTimestamp();
|
||||
|
||||
UpdatePositionAndTotalLength(labelTextLineTotal, textBoxListViewText);
|
||||
}
|
||||
@ -15205,7 +15205,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ShowStatus(string.Format("{0}, {1:0}%", statusMessage, _lastProgressPercent));
|
||||
statusStrip1.Refresh();
|
||||
TaskbarList.SetProgressValue(Handle, percent, 100);
|
||||
if (DateTime.UtcNow.Ticks % 10 == 0)
|
||||
if (Stopwatch.GetTimestamp() % 10 == 0)
|
||||
{
|
||||
Application.DoEvents();
|
||||
}
|
||||
@ -16952,15 +16952,15 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (e.KeyCode == Keys.LWin)
|
||||
{
|
||||
_winLeftDownTicks = DateTime.UtcNow.Ticks;
|
||||
_winLeftDownTicks = Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
if (e.KeyCode == Keys.RWin)
|
||||
{
|
||||
_winRightDownTicks = DateTime.UtcNow.Ticks;
|
||||
_winRightDownTicks = Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow.Ticks - _winLeftDownTicks) <= 10000 * 999 || (DateTime.UtcNow.Ticks - _winRightDownTicks) <= 10000 * 999) // less than 999 ms
|
||||
if ((Stopwatch.GetTimestamp() - _winLeftDownTicks) <= 10000 * 999 || (Stopwatch.GetTimestamp() - _winRightDownTicks) <= 10000 * 999) // less than 999 ms
|
||||
{
|
||||
// if it's less than one second since Win key was pressed we ignore key (not perfect...)
|
||||
e.SuppressKeyPress = true;
|
||||
@ -18398,7 +18398,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
mediaPlayer.CurrentPosition = startSeconds;
|
||||
UiUtil.ShowSubtitle(_subtitle, mediaPlayer, GetCurrentSubtitleFormat());
|
||||
mediaPlayer.Play();
|
||||
_endSecondsNewPositionTicks = DateTime.UtcNow.Ticks;
|
||||
_endSecondsNewPositionTicks = Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
e.SuppressKeyPress = true;
|
||||
@ -18414,7 +18414,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
mediaPlayer.CurrentPosition = startSeconds;
|
||||
UiUtil.ShowSubtitle(_subtitle, mediaPlayer, GetCurrentSubtitleFormat());
|
||||
mediaPlayer.Play();
|
||||
_endSecondsNewPositionTicks = DateTime.UtcNow.Ticks;
|
||||
_endSecondsNewPositionTicks = Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
e.SuppressKeyPress = true;
|
||||
@ -21033,7 +21033,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
labelNextWord.Text = string.Format(_language.NextX, HtmlUtil.RemoveHtmlTags(next.Text, true).Replace(Environment.NewLine, " "));
|
||||
labelNextWord.Left = audioVisualizer.Width / 2 - labelNextWord.Width / 2 + audioVisualizer.Left;
|
||||
labelNextWord.Visible = true;
|
||||
_labelNextTicks = DateTime.UtcNow.Ticks;
|
||||
_labelNextTicks = Stopwatch.GetTimestamp();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -21231,7 +21231,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
_textHeightResize = splitContainerListViewAndText.Height - splitContainerListViewAndText.SplitterDistance;
|
||||
_textHeightResizeIgnoreUpdate = DateTime.UtcNow.Ticks;
|
||||
_textHeightResizeIgnoreUpdate = Stopwatch.GetTimestamp();
|
||||
mediaPlayer.ShowFullScreenControls();
|
||||
bool setRedockOnFullscreenEnd = false;
|
||||
|
||||
@ -24183,7 +24183,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
int index = ShowSubtitle();
|
||||
if (index != -1 && oldIndex != index && checkBoxSyncListViewWithVideoWhilePlaying.Checked)
|
||||
{
|
||||
if ((DateTime.UtcNow.Ticks - _lastTextKeyDownTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds
|
||||
if ((Stopwatch.GetTimestamp() - _lastTextKeyDownTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds
|
||||
{
|
||||
if (_endSeconds <= 0 || !checkBoxAutoRepeatOn.Checked)
|
||||
{
|
||||
@ -24205,7 +24205,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
mediaPlayer.Pause();
|
||||
if (_playSelectionIndex < 0)
|
||||
{
|
||||
if (_endSecondsNewPosition >= 0 && _endSecondsNewPositionTicks > DateTime.UtcNow.Ticks - (10000 * 900)) // 900 ms
|
||||
if (_endSecondsNewPosition >= 0 && _endSecondsNewPositionTicks > Stopwatch.GetTimestamp() - (10000 * 900)) // 900 ms
|
||||
{
|
||||
mediaPlayer.CurrentPosition = _endSecondsNewPosition;
|
||||
}
|
||||
@ -24329,7 +24329,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
|
||||
if (labelNextWord.Visible && _labelNextTicks + 100000000 < DateTime.UtcNow.Ticks)
|
||||
if (labelNextWord.Visible && _labelNextTicks + 100000000 < Stopwatch.GetTimestamp())
|
||||
{
|
||||
labelNextWord.Visible = false;
|
||||
}
|
||||
@ -24367,7 +24367,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Text = Text.RemoveChar('*').TrimEnd();
|
||||
}
|
||||
|
||||
if (InSourceView && _sourceTextTicks != -1 && (DateTime.UtcNow.Ticks - _sourceTextTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds
|
||||
if (InSourceView && _sourceTextTicks != -1 && (Stopwatch.GetTimestamp() - _sourceTextTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds
|
||||
{
|
||||
ReloadFromSourceInSourceView();
|
||||
_sourceTextTicks = -1;
|
||||
@ -24651,7 +24651,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
_textHeightResizeIgnoreUpdate = DateTime.UtcNow.Ticks;
|
||||
_textHeightResizeIgnoreUpdate = Stopwatch.GetTimestamp();
|
||||
SubtitleListview1.AutoSizeAllColumns(this);
|
||||
|
||||
if (WindowState == FormWindowState.Maximized ||
|
||||
@ -24684,7 +24684,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void Main_ResizeBegin(object sender, EventArgs e)
|
||||
{
|
||||
_textHeightResizeIgnoreUpdate = DateTime.UtcNow.Ticks;
|
||||
_textHeightResizeIgnoreUpdate = Stopwatch.GetTimestamp();
|
||||
if (_loading)
|
||||
{
|
||||
return;
|
||||
@ -25697,7 +25697,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
timerAutoContinue.Stop();
|
||||
|
||||
if ((DateTime.UtcNow.Ticks - _lastTextKeyDownTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds
|
||||
if ((Stopwatch.GetTimestamp() - _lastTextKeyDownTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds
|
||||
{
|
||||
labelStatus.Text = string.Empty;
|
||||
PlayNext();
|
||||
@ -26343,7 +26343,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
try
|
||||
{
|
||||
_textHeightResizeIgnoreUpdate = DateTime.UtcNow.Ticks;
|
||||
_textHeightResizeIgnoreUpdate = Stopwatch.GetTimestamp();
|
||||
_textHeightResize = splitContainerListViewAndText.Height - splitContainerListViewAndText.SplitterDistance;
|
||||
}
|
||||
catch
|
||||
@ -26411,7 +26411,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SubtitleListview1.Focus();
|
||||
}
|
||||
|
||||
_lastTextKeyDownTicks = DateTime.UtcNow.Ticks;
|
||||
_lastTextKeyDownTicks = Stopwatch.GetTimestamp();
|
||||
if (_subtitleOriginal != null && _subtitleOriginal.Paragraphs.Count > 0)
|
||||
{
|
||||
var idx = _subtitleListViewIndex;
|
||||
@ -29732,7 +29732,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
_textHeightResizeIgnoreUpdate = DateTime.UtcNow.Ticks;
|
||||
_textHeightResizeIgnoreUpdate = Stopwatch.GetTimestamp();
|
||||
mediaPlayer.ShowNonFullScreenControls();
|
||||
|
||||
SaveUndockedPositions();
|
||||
@ -30091,7 +30091,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void TextBoxListViewTextOriginalKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
_listViewOriginalTextTicks = DateTime.UtcNow.Ticks;
|
||||
_listViewOriginalTextTicks = Stopwatch.GetTimestamp();
|
||||
if (_subtitleOriginal == null || _subtitleOriginal.Paragraphs.Count < 1)
|
||||
{
|
||||
return;
|
||||
@ -30283,7 +30283,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
// last key down in text
|
||||
_lastTextKeyDownTicks = DateTime.UtcNow.Ticks;
|
||||
_lastTextKeyDownTicks = Stopwatch.GetTimestamp();
|
||||
|
||||
UpdatePositionAndTotalLength(labelTextOriginalLineTotal, textBoxListViewTextOriginal);
|
||||
}
|
||||
@ -31619,7 +31619,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow.Ticks - _listViewTextTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds
|
||||
if ((Stopwatch.GetTimestamp() - _listViewTextTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds
|
||||
{
|
||||
var p = _subtitle.GetParagraphOrDefault(index);
|
||||
if (p == null)
|
||||
@ -31713,7 +31713,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
if ((DateTime.UtcNow.Ticks - _listViewOriginalTextTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds
|
||||
if ((Stopwatch.GetTimestamp() - _listViewOriginalTextTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds
|
||||
{
|
||||
var original = Utilities.GetOriginalParagraph(index, _subtitle.Paragraphs[index], _subtitleOriginal.Paragraphs);
|
||||
if (original != null)
|
||||
@ -34207,7 +34207,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (Configuration.Settings.VideoControls.WaveformFocusOnMouseEnter && audioVisualizer.WavePeaks != null && !audioVisualizer.Focused && audioVisualizer.CanFocus)
|
||||
{
|
||||
if (Math.Abs(_lastWaveformMenuCloseTicks - DateTime.UtcNow.Ticks) > 10000 * 500) // only if last change was longer ago than 500 milliseconds
|
||||
if (Math.Abs(_lastWaveformMenuCloseTicks - Stopwatch.GetTimestamp()) > 10000 * 500) // only if last change was longer ago than 500 milliseconds
|
||||
{
|
||||
audioVisualizer.Focus();
|
||||
}
|
||||
@ -34529,7 +34529,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void ContextMenuStripWaveformClosing(object sender, ToolStripDropDownClosingEventArgs e)
|
||||
{
|
||||
_lastWaveformMenuCloseTicks = DateTime.UtcNow.Ticks;
|
||||
_lastWaveformMenuCloseTicks = Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
private void MenuOpened(object sender, EventArgs e)
|
||||
@ -35603,7 +35603,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
var diff = DateTime.UtcNow.Ticks - _textHeightResizeIgnoreUpdate;
|
||||
var diff = Stopwatch.GetTimestamp() - _textHeightResizeIgnoreUpdate;
|
||||
if (diff > 10_000 * 750 && // 750 ms
|
||||
WindowState == _lastFormWindowState)
|
||||
{
|
||||
@ -35818,7 +35818,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void SplitContainerMainSplitterMoving(object sender, SplitterCancelEventArgs e)
|
||||
{
|
||||
_textHeightResizeIgnoreUpdate = DateTime.UtcNow.Ticks;
|
||||
_textHeightResizeIgnoreUpdate = Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
private void ApplyCustomStylesToolStripMenuItemClick(object sender, EventArgs e)
|
||||
|
@ -32,6 +32,7 @@ using Nikse.SubtitleEdit.Core.Settings;
|
||||
using MessageBox = Nikse.SubtitleEdit.Forms.SeMsgBox.MessageBox;
|
||||
using Timer = System.Windows.Forms.Timer;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
{
|
||||
@ -6645,7 +6646,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
{
|
||||
if (subtitleListView1.SelectedItems.Count > 1)
|
||||
{
|
||||
if (DateTime.UtcNow.Ticks - _slvSelIdxChangedTicks < 100000)
|
||||
if (Stopwatch.GetTimestamp() - _slvSelIdxChangedTicks < 100000)
|
||||
{
|
||||
_slvSelIdx = new KeyValuePair<long, int>(_slvSelIdxChangedTicks, subtitleListView1.SelectedItems[0].Index);
|
||||
if (_changeDelayTimer == null)
|
||||
@ -6659,10 +6660,10 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
_changeDelayTimer.Stop();
|
||||
_changeDelayTimer.Start();
|
||||
}
|
||||
_slvSelIdxChangedTicks = DateTime.UtcNow.Ticks;
|
||||
_slvSelIdxChangedTicks = Stopwatch.GetTimestamp();
|
||||
return;
|
||||
}
|
||||
_slvSelIdxChangedTicks = DateTime.UtcNow.Ticks;
|
||||
_slvSelIdxChangedTicks = Stopwatch.GetTimestamp();
|
||||
}
|
||||
_selectedIndex = subtitleListView1.SelectedItems[0].Index;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using Nikse.SubtitleEdit.Core.Dictionaries;
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@ -694,7 +695,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
|
||||
|
||||
e.SuppressKeyPress = true;
|
||||
if (TimeSpan.FromTicks(_listBoxSearchStringLastUsed.Ticks).TotalMilliseconds + 1800 <
|
||||
TimeSpan.FromTicks(DateTime.UtcNow.Ticks).TotalMilliseconds)
|
||||
TimeSpan.FromTicks(Stopwatch.GetTimestamp()).TotalMilliseconds)
|
||||
{
|
||||
_listBoxSearchString = string.Empty;
|
||||
}
|
||||
@ -866,7 +867,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
|
||||
|
||||
e.SuppressKeyPress = true;
|
||||
if (TimeSpan.FromTicks(_listBoxSearchStringLastUsed.Ticks).TotalMilliseconds + 1800 <
|
||||
TimeSpan.FromTicks(DateTime.UtcNow.Ticks).TotalMilliseconds)
|
||||
TimeSpan.FromTicks(Stopwatch.GetTimestamp()).TotalMilliseconds)
|
||||
{
|
||||
_listBoxSearchString = string.Empty;
|
||||
}
|
||||
@ -902,7 +903,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
|
||||
|
||||
e.SuppressKeyPress = true;
|
||||
if (TimeSpan.FromTicks(_listBoxSearchStringLastUsed.Ticks).TotalMilliseconds + 1800 <
|
||||
TimeSpan.FromTicks(DateTime.UtcNow.Ticks).TotalMilliseconds)
|
||||
TimeSpan.FromTicks(Stopwatch.GetTimestamp()).TotalMilliseconds)
|
||||
{
|
||||
_listBoxSearchString = string.Empty;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
return LibMpvDynamic.GetVideoInfo(fileName);
|
||||
}
|
||||
|
||||
private static long _lastShowSubTicks = DateTime.UtcNow.Ticks;
|
||||
private static long _lastShowSubTicks = Stopwatch.GetTimestamp();
|
||||
private static int _lastShowSubHash;
|
||||
|
||||
public static int ShowSubtitle(Subtitle subtitle, VideoPlayerContainer videoPlayerContainer, SubtitleFormat format)
|
||||
@ -115,7 +115,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
private static void TimeOutRefresh(Subtitle subtitle, VideoPlayerContainer videoPlayerContainer, SubtitleFormat format, Paragraph p = null)
|
||||
{
|
||||
if (DateTime.UtcNow.Ticks - _lastShowSubTicks > 10000 * 1000) // more than 1+ seconds ago
|
||||
if (Stopwatch.GetTimestamp() - _lastShowSubTicks > 10000 * 1000) // more than 1+ seconds ago
|
||||
{
|
||||
var newHash = subtitle.GetFastHashCode(string.Empty);
|
||||
if (newHash != _lastShowSubHash)
|
||||
@ -124,7 +124,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
_lastShowSubHash = newHash;
|
||||
}
|
||||
|
||||
_lastShowSubTicks = DateTime.UtcNow.Ticks;
|
||||
_lastShowSubTicks = Stopwatch.GetTimestamp();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Nikse.SubtitleEdit.Core.Common;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic
|
||||
@ -14,10 +14,10 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
return;
|
||||
}
|
||||
|
||||
if (DateTime.UtcNow.Ticks - _lastCall > 10_000_000 * 60) // one minute
|
||||
if (Stopwatch.GetTimestamp() - _lastCall > 10_000_000 * 60) // one minute
|
||||
{
|
||||
NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED);
|
||||
_lastCall = DateTime.UtcNow.Ticks;
|
||||
_lastCall = Stopwatch.GetTimestamp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user