This commit is contained in:
niksedk 2022-05-28 13:28:55 +02:00
parent 338d4f028d
commit d19291587e
11 changed files with 437 additions and 72 deletions

View File

@ -1899,6 +1899,10 @@ $HorzAlign = Center
public bool WaveformSetVideoPositionOnMoveStartEnd { get; set; }
public bool WaveformSingleClickSelect { get; set; }
public bool WaveformSnapToSceneChanges { get; set; }
public int WaveformShotChangeStartTimeBeforeMs { get; set; }
public int WaveformShotChangeStartTimeAfterMs { get; set; }
public int WaveformShotChangeEndTimeBeforeMs { get; set; }
public int WaveformShotChangeEndTimeAfterMs { get; set; }
public int WaveformBorderHitMs { get; set; }
public Color WaveformGridColor { get; set; }
public Color WaveformColor { get; set; }
@ -2391,6 +2395,7 @@ $HorzAlign = Center
public string Waveform100MsRight { get; set; }
public string Waveform1000MsLeft { get; set; }
public string Waveform1000MsRight { get; set; }
public string MainCheckFixTimingViaShotChanges { get; set; }
public string MainTranslateGoogleIt { get; set; }
public string MainTranslateGoogleTranslateIt { get; set; }
public string MainTranslateAuto { get; set; }
@ -2478,6 +2483,7 @@ $HorzAlign = Center
Waveform100MsRight = "Shift+Right";
Waveform1000MsLeft = "Left";
Waveform1000MsRight = "Right";
MainCheckFixTimingViaShotChanges = "Control+Shift+0";
PluginShortcuts = new List<PluginShortcut>();
}
@ -6784,6 +6790,30 @@ $HorzAlign = Center
settings.VideoControls.WaveformSnapToSceneChanges = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("WaveformShotChangeStartTimeBeforeMs");
if (subNode != null)
{
settings.VideoControls.WaveformShotChangeStartTimeBeforeMs = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("WaveformShotChangeStartTimeAfterMs");
if (subNode != null)
{
settings.VideoControls.WaveformShotChangeStartTimeAfterMs = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("WaveformShotChangeEndTimeBeforeMs");
if (subNode != null)
{
settings.VideoControls.WaveformShotChangeEndTimeBeforeMs = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("WaveformShotChangeEndTimeAfterMs");
if (subNode != null)
{
settings.VideoControls.WaveformShotChangeEndTimeAfterMs = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("WaveformSetVideoPositionOnMoveStartEnd");
if (subNode != null)
{
@ -9278,6 +9308,12 @@ $HorzAlign = Center
shortcuts.Waveform1000MsRight = subNode.InnerText;
}
subNode = node.SelectSingleNode("MainCheckFixTimingViaShotChanges");
if (subNode != null)
{
shortcuts.MainCheckFixTimingViaShotChanges = subNode.InnerText;
}
subNode = node.SelectSingleNode("MainTranslateGoogleIt");
if (subNode != null)
{
@ -10099,6 +10135,10 @@ $HorzAlign = Center
textWriter.WriteElementString("WaveformSetVideoPositionOnMoveStartEnd", settings.VideoControls.WaveformSetVideoPositionOnMoveStartEnd.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WaveformSingleClickSelect", settings.VideoControls.WaveformSingleClickSelect.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WaveformSnapToSceneChanges", settings.VideoControls.WaveformSnapToSceneChanges.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WaveformShotChangeStartTimeBeforeMs", settings.VideoControls.WaveformShotChangeStartTimeBeforeMs.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WaveformShotChangeStartTimeAfterMs", settings.VideoControls.WaveformShotChangeStartTimeAfterMs.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WaveformShotChangeEndTimeBeforeMs", settings.VideoControls.WaveformShotChangeEndTimeBeforeMs.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WaveformShotChangeEndTimeAfterMs", settings.VideoControls.WaveformShotChangeEndTimeAfterMs.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WaveformBorderHitMs", settings.VideoControls.WaveformBorderHitMs.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WaveformGridColor", settings.VideoControls.WaveformGridColor.ToArgb().ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WaveformColor", settings.VideoControls.WaveformColor.ToArgb().ToString(CultureInfo.InvariantCulture));
@ -10624,6 +10664,7 @@ $HorzAlign = Center
textWriter.WriteElementString("Waveform100MsRight", shortcuts.Waveform100MsRight);
textWriter.WriteElementString("Waveform1000MsLeft", shortcuts.Waveform1000MsLeft);
textWriter.WriteElementString("Waveform1000MsRight", shortcuts.Waveform1000MsRight);
textWriter.WriteElementString("MainCheckFixTimingViaShotChanges", shortcuts.MainCheckFixTimingViaShotChanges);
textWriter.WriteElementString("MainTranslateGoogleIt", shortcuts.MainTranslateGoogleIt);
textWriter.WriteElementString("MainTranslateGoogleTranslateIt", shortcuts.MainTranslateGoogleTranslateIt);
textWriter.WriteElementString("MainTranslateAuto", shortcuts.MainTranslateAuto);

View File

@ -547,7 +547,7 @@ namespace Nikse.SubtitleEdit.Controls
//private readonly List<long> _ticks = new List<long>();
internal void WaveformPaint(object sender, PaintEventArgs e)
{
// _sw = Stopwatch.StartNew();
// _sw = Stopwatch.StartNew();
var graphics = e.Graphics;
if (_wavePeaks != null)
{
@ -723,13 +723,13 @@ namespace Nikse.SubtitleEdit.Controls
{
try
{
int index = 0;
var index = 0;
while (index < _chapters.Count)
{
int pos;
try
{
double time = _chapters[index].StartTime;
var time = _chapters[index].StartTime;
pos = SecondsToXPosition(time - _startPositionSeconds);
}
catch
@ -897,13 +897,13 @@ namespace Nikse.SubtitleEdit.Controls
}
else
{
double seconds = Math.Ceiling(_startPositionSeconds) - _startPositionSeconds - 1;
int xPosition = SecondsToXPosition(seconds);
int yPosition = 0;
double yCounter = 0;
double interval = _zoomFactor >= 0.4 ?
0.1 : // a pixel is 0.1 second
1.0; // a pixel is 1.0 second
var seconds = Math.Ceiling(_startPositionSeconds) - _startPositionSeconds - 1;
var xPosition = SecondsToXPosition(seconds);
var yPosition = 0;
var yCounter = 0d;
var interval = _zoomFactor >= 0.4d ?
0.1d : // a pixel is 0.1 second
1.0d; // a pixel is 1.0 second
using (var pen = new Pen(GridColor))
{
while (xPosition < Width)
@ -927,8 +927,8 @@ namespace Nikse.SubtitleEdit.Controls
private void DrawTimeLine(Graphics graphics, int imageHeight)
{
double seconds = Math.Ceiling(_startPositionSeconds) - _startPositionSeconds;
int position = SecondsToXPosition(seconds);
var seconds = Math.Ceiling(_startPositionSeconds) - _startPositionSeconds;
var position = SecondsToXPosition(seconds);
using (var pen = new Pen(TextColor))
using (var textBrush = new SolidBrush(TextColor))
using (var textFont = new Font(Font.FontFamily, 7))
@ -974,9 +974,9 @@ namespace Nikse.SubtitleEdit.Controls
private void DrawParagraph(Paragraph paragraph, Graphics graphics)
{
int currentRegionLeft = SecondsToXPosition(paragraph.StartTime.TotalSeconds - _startPositionSeconds);
int currentRegionRight = SecondsToXPosition(paragraph.EndTime.TotalSeconds - _startPositionSeconds);
int currentRegionWidth = currentRegionRight - currentRegionLeft;
var currentRegionLeft = SecondsToXPosition(paragraph.StartTime.TotalSeconds - _startPositionSeconds);
var currentRegionRight = SecondsToXPosition(paragraph.EndTime.TotalSeconds - _startPositionSeconds);
var currentRegionWidth = currentRegionRight - currentRegionLeft;
// background
using (var brush = new SolidBrush(Color.FromArgb(42, 255, 255, 255)))
@ -1011,7 +1011,7 @@ namespace Nikse.SubtitleEdit.Controls
};
const int padding = 3;
double n = _zoomFactor * _wavePeaks.SampleRate;
var n = _zoomFactor * _wavePeaks.SampleRate;
// bookmark text
if (paragraph.Bookmark != null)
@ -1108,12 +1108,12 @@ namespace Nikse.SubtitleEdit.Controls
text = text.Substring(0, 500); // don't now allow very long texts as they can make SE unresponsive - see https://github.com/SubtitleEdit/subtitleedit/issues/2536
}
int y = padding;
var y = padding;
var max = currentRegionWidth - padding - 1;
foreach (var line in text.SplitToLines())
{
text = line;
int removeLength = 1;
var removeLength = 1;
var measureResult = graphics.MeasureString(text, font);
while (text.Length > removeLength && graphics.MeasureString(text, font).Width > max)
{
@ -1136,7 +1136,6 @@ namespace Nikse.SubtitleEdit.Controls
drawStringOutlined(text, currentRegionLeft + padding, y);
y += (int)Math.Round(measureResult.Height, MidpointRounding.AwayFromZero);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -1221,7 +1220,7 @@ namespace Nikse.SubtitleEdit.Controls
if (_mouseDownParagraph != null)
{
oldMouseDownParagraph = new Paragraph(_mouseDownParagraph);
int curIdx = _subtitle.Paragraphs.IndexOf(_mouseDownParagraph);
var curIdx = _subtitle.Paragraphs.IndexOf(_mouseDownParagraph);
if (_mouseDownParagraphType == MouseDownParagraphType.Start && ModifierKeys != Keys.Alt)
{
if (curIdx > 0)
@ -1272,7 +1271,7 @@ namespace Nikse.SubtitleEdit.Controls
{
if (_subtitle != null && _mouseDownParagraph != null)
{
int curIdx = _subtitle.Paragraphs.IndexOf(_mouseDownParagraph);
var curIdx = _subtitle.Paragraphs.IndexOf(_mouseDownParagraph);
if (curIdx > 0 && oldMouseDownParagraph != null)
{
_gapAtStart = oldMouseDownParagraph.StartTime.TotalMilliseconds - _subtitle.Paragraphs[curIdx - 1].EndTime.TotalMilliseconds;
@ -1283,7 +1282,7 @@ namespace Nikse.SubtitleEdit.Controls
{
if (_subtitle != null && _mouseDownParagraph != null)
{
int curIdx = _subtitle.Paragraphs.IndexOf(_mouseDownParagraph);
var curIdx = _subtitle.Paragraphs.IndexOf(_mouseDownParagraph);
if (curIdx >= 0 && curIdx < _subtitle.Paragraphs.Count - 1 && oldMouseDownParagraph != null)
{
_gapAtStart = _subtitle.Paragraphs[curIdx + 1].StartTime.TotalMilliseconds - oldMouseDownParagraph.EndTime.TotalMilliseconds;
@ -1296,7 +1295,7 @@ namespace Nikse.SubtitleEdit.Controls
{
if (e.Button == MouseButtons.Right)
{
double seconds = RelativeXPositionToSeconds(e.X);
var seconds = RelativeXPositionToSeconds(e.X);
var milliseconds = (int)(seconds * TimeCode.BaseUnit);
if (OnNewSelectionRightClicked != null && NewSelectionParagraph != null)
@ -1324,6 +1323,7 @@ namespace Nikse.SubtitleEdit.Controls
}
}
}
Cursor = Cursors.Default;
}
}
@ -1337,7 +1337,7 @@ namespace Nikse.SubtitleEdit.Controls
Paragraph prev = null;
Paragraph next = null;
var paragraphs = _subtitle.Paragraphs.OrderBy(p => p.StartTime.TotalMilliseconds).ToList();
for (int i = 0; i < paragraphs.Count; i++)
for (var i = 0; i < paragraphs.Count; i++)
{
var p2 = paragraphs[i];
if (p2.StartTime.TotalSeconds < seconds)
@ -1350,6 +1350,7 @@ namespace Nikse.SubtitleEdit.Controls
break;
}
}
if (prev != null)
{
_wholeParagraphMinMilliseconds = prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines;
@ -1369,13 +1370,14 @@ namespace Nikse.SubtitleEdit.Controls
if (_subtitle != null && _mouseDownParagraph != null)
{
var paragraphs = _subtitle.Paragraphs.OrderBy(p => p.StartTime.TotalMilliseconds).ToList();
int curIdx = paragraphs.IndexOf(_mouseDownParagraph);
var curIdx = paragraphs.IndexOf(_mouseDownParagraph);
if (curIdx >= 0)
{
if (curIdx > 0)
{
_wholeParagraphMinMilliseconds = paragraphs[curIdx - 1].EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines;
}
if (curIdx < _subtitle.Paragraphs.Count - 1)
{
_wholeParagraphMaxMilliseconds = paragraphs[curIdx + 1].StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
@ -1400,7 +1402,7 @@ namespace Nikse.SubtitleEdit.Controls
if (_subtitle != null && _mouseDownParagraph != null)
{
var paragraphs = _subtitle.Paragraphs.OrderBy(p => p.StartTime.TotalMilliseconds).ToList();
int curIdx = paragraphs.IndexOf(_mouseDownParagraph);
var curIdx = paragraphs.IndexOf(_mouseDownParagraph);
if (curIdx >= 0)
{
var gap = Math.Abs(paragraphs[curIdx - 1].EndTime.TotalMilliseconds - paragraphs[curIdx].StartTime.TotalMilliseconds);
@ -1416,7 +1418,7 @@ namespace Nikse.SubtitleEdit.Controls
if (_subtitle != null && _mouseDownParagraph != null)
{
var paragraphs = _subtitle.Paragraphs.OrderBy(p => p.StartTime.TotalMilliseconds).ToList();
int curIdx = paragraphs.IndexOf(_mouseDownParagraph);
var curIdx = paragraphs.IndexOf(_mouseDownParagraph);
if (curIdx >= 0)
{
if (curIdx < _subtitle.Paragraphs.Count - 1)
@ -1492,6 +1494,7 @@ namespace Nikse.SubtitleEdit.Controls
_mouseDownParagraphType = MouseDownParagraphType.Start;
return true;
}
if (IsParagraphBorderEndHit(milliseconds, paragraph.EndTime.TotalMilliseconds))
{
var idx = _displayableParagraphs.IndexOf(paragraph);
@ -1513,6 +1516,7 @@ namespace Nikse.SubtitleEdit.Controls
_mouseDownParagraphType = MouseDownParagraphType.End;
return true;
}
return false;
}
@ -1671,7 +1675,7 @@ namespace Nikse.SubtitleEdit.Controls
}
}
if (_firstMove && ModifierKeys != Keys.Alt && ModifierKeys != Keys.Shift &&
if (_firstMove && ModifierKeys != Keys.Alt && ModifierKeys != Keys.Shift &&
!Configuration.Settings.VideoControls.WaveformAllowOverlap)
{
// decide which paragraph to move
@ -2286,7 +2290,7 @@ namespace Nikse.SubtitleEdit.Controls
return;
}
int delta = e.Delta;
var delta = e.Delta;
if (!MouseWheelScrollUpIsForward)
{
delta *= -1;
@ -2354,22 +2358,23 @@ namespace Nikse.SubtitleEdit.Controls
private void DrawSpectrogram(Graphics graphics)
{
int width = (int)Math.Round((EndPositionSeconds - _startPositionSeconds) / _spectrogram.SampleDuration);
var width = (int)Math.Round((EndPositionSeconds - _startPositionSeconds) / _spectrogram.SampleDuration);
using (var bmpCombined = new Bitmap(width, _spectrogram.FftSize / 2))
using (var gfxCombined = Graphics.FromImage(bmpCombined))
{
int left = (int)Math.Round(_startPositionSeconds / _spectrogram.SampleDuration);
int offset = 0;
int imageIndex = left / _spectrogram.ImageWidth;
var left = (int)Math.Round(_startPositionSeconds / _spectrogram.SampleDuration);
var offset = 0;
var imageIndex = left / _spectrogram.ImageWidth;
while (offset < width && imageIndex < _spectrogram.Images.Count)
{
int x = (left + offset) % _spectrogram.ImageWidth;
int w = Math.Min(_spectrogram.ImageWidth - x, width - offset);
var x = (left + offset) % _spectrogram.ImageWidth;
var w = Math.Min(_spectrogram.ImageWidth - x, width - offset);
gfxCombined.DrawImage(_spectrogram.Images[imageIndex], offset, 0, new Rectangle(x, 0, w, bmpCombined.Height), GraphicsUnit.Pixel);
offset += w;
imageIndex++;
}
int displayHeight = _showWaveform ? SpectrogramDisplayHeight : Height;
var displayHeight = _showWaveform ? SpectrogramDisplayHeight : Height;
graphics.DrawImage(bmpCombined, new Rectangle(0, Height - displayHeight, Width, displayHeight));
}
}
@ -2377,9 +2382,9 @@ namespace Nikse.SubtitleEdit.Controls
private double GetAverageVolumeForNextMilliseconds(int sampleIndex, int milliseconds)
{
// length cannot be less than 9
int length = Math.Max(SecondsToSampleIndex(milliseconds / TimeCode.BaseUnit), 9);
int max = Math.Min(sampleIndex + length, _wavePeaks.Peaks.Count);
int from = Math.Max(sampleIndex, 1);
var length = Math.Max(SecondsToSampleIndex(milliseconds / TimeCode.BaseUnit), 9);
var max = Math.Min(sampleIndex + length, _wavePeaks.Peaks.Count);
var from = Math.Max(sampleIndex, 1);
if (from >= max)
{
@ -2387,7 +2392,7 @@ namespace Nikse.SubtitleEdit.Controls
}
double v = 0;
for (int i = from; i < max; i++)
for (var i = from; i < max; i++)
{
v += _wavePeaks.Peaks[i].Abs;
}
@ -2397,7 +2402,7 @@ namespace Nikse.SubtitleEdit.Controls
internal void GenerateTimeCodes(Subtitle subtitle, double startFromSeconds, int blockSizeMilliseconds, int minimumVolumePercent, int maximumVolumePercent, int defaultMilliseconds)
{
int begin = SecondsToSampleIndex(startFromSeconds);
var begin = SecondsToSampleIndex(startFromSeconds);
double average = 0;
for (int k = begin; k < _wavePeaks.Peaks.Count; k++)
@ -2469,22 +2474,23 @@ namespace Nikse.SubtitleEdit.Controls
private bool EndParagraphDueToLowVolume(Subtitle subtitle, int blockSizeMilliseconds, double silenceThreshold, int begin, bool subtitleOn, int i)
{
double avgVol = GetAverageVolumeForNextMilliseconds(i, blockSizeMilliseconds);
var avgVol = GetAverageVolumeForNextMilliseconds(i, blockSizeMilliseconds);
if (avgVol < silenceThreshold)
{
var p = new Paragraph(string.Empty, SampleIndexToSeconds(begin) * TimeCode.BaseUnit, SampleIndexToSeconds(i) * TimeCode.BaseUnit);
subtitle.Paragraphs.Add(p);
subtitleOn = false;
}
return subtitleOn;
}
private MinMax GetMinAndMax(int startIndex, int endIndex)
{
int minPeak = int.MaxValue;
int maxPeak = int.MinValue;
var minPeak = int.MaxValue;
var maxPeak = int.MinValue;
double total = 0;
for (int i = startIndex; i < endIndex; i++)
for (var i = startIndex; i < endIndex; i++)
{
var v = _wavePeaks.Peaks[i].Abs;
total += v;
@ -2503,12 +2509,11 @@ namespace Nikse.SubtitleEdit.Controls
public double FindDataBelowThreshold(double thresholdPercent, double durationInSeconds)
{
int begin = SecondsToSampleIndex(_currentVideoPositionSeconds + 1);
int length = SecondsToSampleIndex(durationInSeconds);
var begin = SecondsToSampleIndex(_currentVideoPositionSeconds + 1);
var length = SecondsToSampleIndex(durationInSeconds);
var threshold = thresholdPercent / 100.0 * _wavePeaks.HighestPeak;
int hitCount = 0;
for (int i = Math.Max(0, begin); i < _wavePeaks.Peaks.Count; i++)
var hitCount = 0;
for (var i = Math.Max(0, begin); i < _wavePeaks.Peaks.Count; i++)
{
if (_wavePeaks.Peaks[i].Abs <= threshold)
{
@ -2521,7 +2526,7 @@ namespace Nikse.SubtitleEdit.Controls
if (hitCount > length)
{
double seconds = SampleIndexToSeconds(i - (length / 2));
var seconds = SampleIndexToSeconds(i - (length / 2));
if (seconds >= 0)
{
StartPositionSeconds = seconds;
@ -2533,27 +2538,29 @@ namespace Nikse.SubtitleEdit.Controls
OnSingleClick?.Invoke(this, new ParagraphEventArgs(seconds, null));
Invalidate();
}
return seconds;
}
}
return -1;
}
/// <returns>video position in seconds, -1 if not found</returns>
public double FindDataBelowThresholdBack(double thresholdPercent, double durationInSeconds)
{
int begin = SecondsToSampleIndex(_currentVideoPositionSeconds - 1);
int length = SecondsToSampleIndex(durationInSeconds);
var begin = SecondsToSampleIndex(_currentVideoPositionSeconds - 1);
var length = SecondsToSampleIndex(durationInSeconds);
var threshold = thresholdPercent / 100.0 * _wavePeaks.HighestPeak;
int hitCount = 0;
for (int i = begin; i > 0; i--)
var hitCount = 0;
for (var i = begin; i > 0; i--)
{
if (i > 0 && i < _wavePeaks.Peaks.Count && _wavePeaks.Peaks[i].Abs <= threshold)
if (i < _wavePeaks.Peaks.Count && _wavePeaks.Peaks[i].Abs <= threshold)
{
hitCount++;
if (hitCount > length)
{
double seconds = SampleIndexToSeconds(i + length / 2);
var seconds = SampleIndexToSeconds(i + length / 2);
if (seconds >= 0)
{
StartPositionSeconds = seconds;
@ -2569,6 +2576,7 @@ namespace Nikse.SubtitleEdit.Controls
OnSingleClick?.Invoke(this, new ParagraphEventArgs(seconds, null));
Invalidate();
}
return seconds;
}
}
@ -2577,6 +2585,7 @@ namespace Nikse.SubtitleEdit.Controls
hitCount = 0;
}
}
return -1;
}
@ -2589,7 +2598,7 @@ namespace Nikse.SubtitleEdit.Controls
var min = Math.Max(0, SecondsToSampleIndex(startSeconds - 1));
var maxShort = Math.Min(_wavePeaks.Peaks.Count, SecondsToSampleIndex(startSeconds + durationInSeconds + 0.01));
var max = Math.Min(_wavePeaks.Peaks.Count, SecondsToSampleIndex(startSeconds + durationInSeconds + 0.8));
int length = SecondsToSampleIndex(durationInSeconds);
var length = SecondsToSampleIndex(durationInSeconds);
var threshold = thresholdPercent / 100.0 * _wavePeaks.HighestPeak;
var minMax = GetMinAndMax(min, max);
@ -2620,6 +2629,7 @@ namespace Nikse.SubtitleEdit.Controls
hitCount = length / 2;
}
}
if (hitCount > length)
{
minMax = GetMinAndMax(min, index);
@ -2648,6 +2658,7 @@ namespace Nikse.SubtitleEdit.Controls
hitCount = 0;
}
}
return -1;
}
@ -2675,9 +2686,10 @@ namespace Nikse.SubtitleEdit.Controls
{
return -1;
}
try
{
for (int index = 0; index < SceneChanges.Count; index++)
for (var index = 0; index < SceneChanges.Count; index++)
{
var sceneChange = SceneChanges[index];
if (Math.Abs(sceneChange - seconds) < 0.04)
@ -2693,6 +2705,5 @@ namespace Nikse.SubtitleEdit.Controls
return -1;
}
}
}

View File

@ -41,6 +41,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Forms.SceneChanges;
namespace Nikse.SubtitleEdit.Forms
{
@ -16898,7 +16899,7 @@ namespace Nikse.SubtitleEdit.Forms
e.SuppressKeyPress = true;
}
else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.MainVideoFoucsSetVideoPosition)
else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.MainVideoFocusSetVideoPosition)
{
if (tabControlModes.SelectedTab == tabPageAdjust)
{

View File

@ -0,0 +1,138 @@
namespace Nikse.SubtitleEdit.Forms.SceneChanges
{
partial class AdjustTimingViaShotChanges
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AdjustTimingViaShotChanges));
this.audioVisualizer = new Nikse.SubtitleEdit.Controls.AudioVisualizer();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button();
this.listView1 = new System.Windows.Forms.ListView();
this.SuspendLayout();
//
// audioVisualizer
//
this.audioVisualizer.AllowNewSelection = true;
this.audioVisualizer.AllowOverlap = false;
this.audioVisualizer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.audioVisualizer.BackColor = System.Drawing.Color.Black;
this.audioVisualizer.BackgroundColor = System.Drawing.Color.Black;
this.audioVisualizer.Chapters = ((System.Collections.Generic.List<Nikse.SubtitleEdit.Core.ContainerFormats.Matroska.MatroskaChapter>)(resources.GetObject("audioVisualizer.Chapters")));
this.audioVisualizer.ChaptersColor = System.Drawing.Color.Empty;
this.audioVisualizer.ClosenessForBorderSelection = 15;
this.audioVisualizer.Color = System.Drawing.Color.GreenYellow;
this.audioVisualizer.CursorColor = System.Drawing.Color.Empty;
this.audioVisualizer.Font = new System.Drawing.Font("Segoe UI", 9F);
this.audioVisualizer.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(18)))));
this.audioVisualizer.InsertAtVideoPositionShortcut = System.Windows.Forms.Keys.Insert;
this.audioVisualizer.Location = new System.Drawing.Point(12, 215);
this.audioVisualizer.MouseWheelScrollUpIsForward = true;
this.audioVisualizer.Move100MsLeft = System.Windows.Forms.Keys.None;
this.audioVisualizer.Move100MsRight = System.Windows.Forms.Keys.None;
this.audioVisualizer.MoveOneSecondLeft = System.Windows.Forms.Keys.None;
this.audioVisualizer.MoveOneSecondRight = System.Windows.Forms.Keys.None;
this.audioVisualizer.Name = "audioVisualizer";
this.audioVisualizer.NewSelectionParagraph = null;
this.audioVisualizer.ParagraphColor = System.Drawing.Color.LimeGreen;
this.audioVisualizer.SceneChanges = ((System.Collections.Generic.List<double>)(resources.GetObject("audioVisualizer.SceneChanges")));
this.audioVisualizer.SelectedColor = System.Drawing.Color.Red;
this.audioVisualizer.ShowGridLines = true;
this.audioVisualizer.ShowSpectrogram = true;
this.audioVisualizer.ShowWaveform = true;
this.audioVisualizer.Size = new System.Drawing.Size(862, 151);
this.audioVisualizer.StartPositionSeconds = 0D;
this.audioVisualizer.TabIndex = 0;
this.audioVisualizer.TextBold = true;
this.audioVisualizer.TextColor = System.Drawing.Color.Gray;
this.audioVisualizer.TextSize = 9F;
this.audioVisualizer.VerticalZoomFactor = 1D;
this.audioVisualizer.WaveformNotLoadedText = "Click to add waveform/spectrogram";
this.audioVisualizer.WavePeaks = null;
this.audioVisualizer.ZoomFactor = 1D;
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(787, 372);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(87, 23);
this.buttonCancel.TabIndex = 6;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(694, 372);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(87, 23);
this.buttonOK.TabIndex = 5;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
//
// listView1
//
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(13, 13);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(861, 159);
this.listView1.TabIndex = 7;
this.listView1.UseCompatibleStateImageBehavior = false;
//
// AdjustTimingViaShotChanges
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(886, 407);
this.Controls.Add(this.listView1);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.audioVisualizer);
this.Name = "AdjustTimingViaShotChanges";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Adjust timing via shot changes";
this.ResumeLayout(false);
}
#endregion
private Controls.AudioVisualizer audioVisualizer;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.ListView listView1;
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Nikse.SubtitleEdit.Forms.SceneChanges
{
public partial class AdjustTimingViaShotChanges : Form
{
public AdjustTimingViaShotChanges()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="audioVisualizer.Chapters" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAIwBbGlic2UsIFZlcnNpb249My42LjYuMTIsIEN1bHR1cmU9bmV1
dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0
dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkMAwAAAD1saWJzZSwgVmVy
c2lvbj0zLjYuNi4xMiwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBQEAAABkU3lz
dGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tOaWtzZS5TdWJ0aXRsZUVkaXQuQ29yZS5Db250
YWluZXJGb3JtYXRzLk1hdHJvc2thLk1hdHJvc2thQ2hhcHRlcgMAAAAGX2l0ZW1zBV9zaXplCF92ZXJz
aW9uBAAAQ05pa3NlLlN1YnRpdGxlRWRpdC5Db3JlLkNvbnRhaW5lckZvcm1hdHMuTWF0cm9za2EuTWF0
cm9za2FDaGFwdGVyW10DAAAACAgCAAAACQQAAAAAAAAAAAAAAAcEAAAAAAEAAAAAAAAABEFOaWtzZS5T
dWJ0aXRsZUVkaXQuQ29yZS5Db250YWluZXJGb3JtYXRzLk1hdHJvc2thLk1hdHJvc2thQ2hhcHRlcgMA
AAAL
</value>
</data>
<data name="audioVisualizer.SceneChanges" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u
ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u
PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB
AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLkRvdWJsZQMAAAAGX2l0
ZW1zBV9zaXplCF92ZXJzaW9uBwAABggIAgAAAAkDAAAAAAAAAAAAAAAPAwAAAAAAAAAGCw==
</value>
</data>
</root>

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.SceneChanges
{
partial class ImportSceneChanges
{

View File

@ -1,7 +1,4 @@
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Logic;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@ -9,8 +6,11 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.SceneChanges
{
public partial class ImportSceneChanges : PositionAndSizeForm
{

View File

@ -34,7 +34,7 @@ namespace Nikse.SubtitleEdit.Logic
public Keys MainGeneralSetAssaResolution { get; set; }
public Keys MainGeneralTakeAutoBackupNow { get; set; }
public Keys MainToolsAutoDuration { get; set; }
public Keys MainVideoFoucsSetVideoPosition { get; set; }
public Keys MainVideoFocusSetVideoPosition { get; set; }
public Keys ToggleVideoDockUndock { get; set; }
public Keys VideoPause { get; set; }
public Keys VideoStop { get; set; }
@ -222,6 +222,7 @@ namespace Nikse.SubtitleEdit.Logic
public Keys WaveformListSceneChanges { get; set; }
public Keys WaveformGuessStart { get; set; }
public Keys MainTranslateGoogleIt { get; set; }
public Keys MainCheckFixTimingViaShotChanges { get; set; }
public Keys MainTranslateGoogleTranslateIt { get; set; }
public Keys MainTranslateCustomSearch1 { get; set; }
public Keys MainTranslateCustomSearch2 { get; set; }
@ -263,7 +264,7 @@ namespace Nikse.SubtitleEdit.Logic
MainVideoPlayFromBeginning = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoPlayFromBeginning);
VideoPause = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoPause);
VideoStop = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoStop);
MainVideoFoucsSetVideoPosition = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoFoucsSetVideoPosition);
MainVideoFocusSetVideoPosition = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoFoucsSetVideoPosition);
ToggleVideoDockUndock = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls);
VideoPlayPauseToggle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoPlayPauseToggle);
Video1FrameLeft = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideo1FrameLeft);
@ -447,6 +448,7 @@ namespace Nikse.SubtitleEdit.Logic
WaveformListSceneChanges = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformListSceneChanges);
WaveformGuessStart = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformGuessStart);
MainTranslateGoogleIt = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTranslateGoogleIt);
MainCheckFixTimingViaShotChanges = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainCheckFixTimingViaShotChanges);
MainTranslateGoogleTranslateIt = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTranslateGoogleTranslateIt);
MainTranslateCustomSearch1 = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTranslateCustomSearch1);
MainTranslateCustomSearch2 = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTranslateCustomSearch2);

View File

@ -420,6 +420,12 @@
<Compile Include="Forms\Assa\SubStationAlphaStylesCategoriesManager.Designer.cs">
<DependentUpon>SubStationAlphaStylesCategoriesManager.cs</DependentUpon>
</Compile>
<Compile Include="Forms\SceneChanges\AdjustTimingViaShotChanges.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\SceneChanges\AdjustTimingViaShotChanges.Designer.cs">
<DependentUpon>AdjustTimingViaShotChanges.cs</DependentUpon>
</Compile>
<Compile Include="Forms\SeJobs\SeJobExport.cs">
<SubType>Form</SubType>
</Compile>
@ -636,10 +642,10 @@
<Compile Include="Forms\ImportImages.Designer.cs">
<DependentUpon>ImportImages.cs</DependentUpon>
</Compile>
<Compile Include="Forms\ImportSceneChanges.cs">
<Compile Include="Forms\SceneChanges\ImportSceneChanges.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\ImportSceneChanges.Designer.cs">
<Compile Include="Forms\SceneChanges\ImportSceneChanges.Designer.cs">
<DependentUpon>ImportSceneChanges.cs</DependentUpon>
</Compile>
<Compile Include="Forms\ImportUnknownFormat.cs">
@ -1527,6 +1533,9 @@
<EmbeddedResource Include="Forms\Assa\SubStationAlphaStylesCategoriesManager.resx">
<DependentUpon>SubStationAlphaStylesCategoriesManager.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SceneChanges\AdjustTimingViaShotChanges.resx">
<DependentUpon>AdjustTimingViaShotChanges.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SeJobs\SeJobExport.resx">
<DependentUpon>SeJobExport.cs</DependentUpon>
</EmbeddedResource>
@ -1628,7 +1637,7 @@
<EmbeddedResource Include="Forms\ImportImages.resx">
<DependentUpon>ImportImages.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ImportSceneChanges.resx">
<EmbeddedResource Include="Forms\SceneChanges\ImportSceneChanges.resx">
<DependentUpon>ImportSceneChanges.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ImportUnknownFormat.resx">