mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
"Point sync" can now also sync using only one sync point (thx tttoan)
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@292 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
2ac40da6c6
commit
83819775fc
23
src/Forms/SyncPointsSync.Designer.cs
generated
23
src/Forms/SyncPointsSync.Designer.cs
generated
@ -31,7 +31,7 @@
|
||||
this.groupBoxImportResult = new System.Windows.Forms.GroupBox();
|
||||
this.listBoxSyncPoints = new System.Windows.Forms.ListBox();
|
||||
this.labelNoOfSyncPoints = new System.Windows.Forms.Label();
|
||||
this.labelSyncHelp = new System.Windows.Forms.Label();
|
||||
this.labelSyncInfo = new System.Windows.Forms.Label();
|
||||
this.buttonRemoveSyncPoint = new System.Windows.Forms.Button();
|
||||
this.buttonSetSyncPoint = new System.Windows.Forms.Button();
|
||||
this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
|
||||
@ -48,7 +48,7 @@
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBoxImportResult.Controls.Add(this.listBoxSyncPoints);
|
||||
this.groupBoxImportResult.Controls.Add(this.labelNoOfSyncPoints);
|
||||
this.groupBoxImportResult.Controls.Add(this.labelSyncHelp);
|
||||
this.groupBoxImportResult.Controls.Add(this.labelSyncInfo);
|
||||
this.groupBoxImportResult.Controls.Add(this.buttonRemoveSyncPoint);
|
||||
this.groupBoxImportResult.Controls.Add(this.buttonSetSyncPoint);
|
||||
this.groupBoxImportResult.Controls.Add(this.SubtitleListview1);
|
||||
@ -78,15 +78,15 @@
|
||||
this.labelNoOfSyncPoints.TabIndex = 16;
|
||||
this.labelNoOfSyncPoints.Text = "Sync points: 0";
|
||||
//
|
||||
// labelSyncHelp
|
||||
// labelSyncInfo
|
||||
//
|
||||
this.labelSyncHelp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.labelSyncHelp.AutoSize = true;
|
||||
this.labelSyncHelp.Location = new System.Drawing.Point(6, 376);
|
||||
this.labelSyncHelp.Name = "labelSyncHelp";
|
||||
this.labelSyncHelp.Size = new System.Drawing.Size(284, 13);
|
||||
this.labelSyncHelp.TabIndex = 17;
|
||||
this.labelSyncHelp.Text = "Set at least two sync points to make rough syncronization";
|
||||
this.labelSyncInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.labelSyncInfo.AutoSize = true;
|
||||
this.labelSyncInfo.Location = new System.Drawing.Point(6, 376);
|
||||
this.labelSyncInfo.Name = "labelSyncInfo";
|
||||
this.labelSyncInfo.Size = new System.Drawing.Size(284, 13);
|
||||
this.labelSyncInfo.TabIndex = 17;
|
||||
this.labelSyncInfo.Text = "Set at least two sync points to make rough syncronization";
|
||||
//
|
||||
// buttonRemoveSyncPoint
|
||||
//
|
||||
@ -117,6 +117,7 @@
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.SubtitleListview1.FirstVisibleIndex = -1;
|
||||
this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.SubtitleListview1.FullRowSelect = true;
|
||||
this.SubtitleListview1.GridLines = true;
|
||||
this.SubtitleListview1.HideSelection = false;
|
||||
@ -192,7 +193,7 @@
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox groupBoxImportResult;
|
||||
private System.Windows.Forms.Label labelSyncHelp;
|
||||
private System.Windows.Forms.Label labelSyncInfo;
|
||||
private System.Windows.Forms.Label labelNoOfSyncPoints;
|
||||
private System.Windows.Forms.Button buttonSetSyncPoint;
|
||||
private System.Windows.Forms.Button buttonApplySync;
|
||||
|
@ -47,7 +47,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
buttonApplySync.Text = Configuration.Settings.Language.General.Apply;
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
||||
labelNoOfSyncPoints.Text = string.Format(Configuration.Settings.Language.PointSync.SyncPointsX, 0);
|
||||
labelSyncHelp.Text = Configuration.Settings.Language.PointSync.Description;
|
||||
labelSyncInfo.Text = Configuration.Settings.Language.PointSync.Info;
|
||||
SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings);
|
||||
SubtitleListview1.InitializeTimeStampColumWidths(this);
|
||||
Utilities.InitializeSubtitleFont(SubtitleListview1);
|
||||
@ -80,10 +80,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void RefreshSyncronizationPointsUI()
|
||||
{
|
||||
buttonApplySync.Enabled = _syncronizationPoints.Count > 1;
|
||||
buttonApplySync.Enabled = _syncronizationPoints.Count > 0;
|
||||
labelNoOfSyncPoints.Text = string.Format(Configuration.Settings.Language.PointSync.SyncPointsX, _syncronizationPoints.Count);
|
||||
|
||||
|
||||
listBoxSyncPoints.Items.Clear();
|
||||
|
||||
for (int i = 0; i < SubtitleListview1.Items.Count; i++)
|
||||
@ -194,15 +193,23 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void buttonSync_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_syncronizationPoints.Count == 1)
|
||||
{
|
||||
foreach (KeyValuePair<int, TimeSpan> kvp in _syncronizationPoints)
|
||||
AdjustViaShowEarlierLater(kvp.Key, kvp.Value.TotalMilliseconds);
|
||||
_syncronizationPoints = new SortedDictionary<int, TimeSpan>();
|
||||
SubtitleListview1.Fill(_subtitle);
|
||||
RefreshSyncronizationPointsUI();
|
||||
return;
|
||||
}
|
||||
|
||||
int startIndex = -1;
|
||||
int endIndex = -1;
|
||||
int minIndex = 0;
|
||||
int maxIndex;
|
||||
|
||||
List<int> syncIndices = new List<int>();
|
||||
foreach (KeyValuePair<int, TimeSpan> kvp in _syncronizationPoints)
|
||||
syncIndices.Add(kvp.Key);
|
||||
|
||||
for (int i = 0; i < syncIndices.Count; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
@ -229,6 +236,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
RefreshSyncronizationPointsUI();
|
||||
}
|
||||
|
||||
private void AdjustViaShowEarlierLater(int index, double newTotalMilliseconds)
|
||||
{
|
||||
var oldTotalMilliseconds = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds;
|
||||
var diff = newTotalMilliseconds - oldTotalMilliseconds;
|
||||
_subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(diff));
|
||||
}
|
||||
|
||||
private void listBoxSyncPoints_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxSyncPoints.SelectedIndex >= 0)
|
||||
|
@ -1233,7 +1233,7 @@ can edit in same subtitle file (collaboration)",
|
||||
SetSyncPoint = "Set sync point",
|
||||
RemoveSyncPoint = "Remove sync point",
|
||||
SyncPointsX = "Sync points: {0}",
|
||||
Description = "Point synchronization requires at least 2 synchronization points",
|
||||
Info = "One sync point will adjust position, two or more sync points will adjust position and speed",
|
||||
};
|
||||
|
||||
UnknownSubtitle = new LanguageStructure.UnknownSubtitle
|
||||
|
@ -1167,7 +1167,7 @@
|
||||
public string SetSyncPoint { get; set; }
|
||||
public string RemoveSyncPoint { get; set; }
|
||||
public string SyncPointsX { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Info { get; set; }
|
||||
}
|
||||
|
||||
public class UnknownSubtitle
|
||||
|
Loading…
Reference in New Issue
Block a user