Now remembers original subtitle

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@254 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-01-15 20:32:19 +00:00
parent 984182b876
commit 5ed3b8d284
3 changed files with 165 additions and 131 deletions

View File

@ -215,7 +215,6 @@
this.toolStripButtonWaveFormPause = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonWaveFormPlay = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonLockCenter = new System.Windows.Forms.ToolStripButton();
this.AudioWaveForm = new Nikse.SubtitleEdit.Controls.WaveForm();
this.tabControlButtons = new System.Windows.Forms.TabControl();
this.tabPageTranslate = new System.Windows.Forms.TabPage();
this.labelTranslateTip = new System.Windows.Forms.Label();
@ -237,7 +236,6 @@
this.buttonPlayCurrent = new System.Windows.Forms.Button();
this.buttonPlayNext = new System.Windows.Forms.Button();
this.tabPageCreate = new System.Windows.Forms.TabPage();
this.timeUpDownVideoPosition = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.buttonGotoSub = new System.Windows.Forms.Button();
this.buttonBeforeText = new System.Windows.Forms.Button();
this.buttonSetEnd = new System.Windows.Forms.Button();
@ -256,7 +254,6 @@
this.labelVideoPosition = new System.Windows.Forms.Label();
this.buttonSecBack1 = new System.Windows.Forms.Button();
this.tabPageAdjust = new System.Windows.Forms.TabPage();
this.timeUpDownVideoPositionAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.buttonAdjustSetEndTime = new System.Windows.Forms.Button();
this.buttonSetEndAndGoToNext = new System.Windows.Forms.Button();
this.buttonSetStartAndOffsetRest = new System.Windows.Forms.Button();
@ -297,7 +294,6 @@
this.panelSingleLine = new System.Windows.Forms.Panel();
this.labelTextLineTotal = new System.Windows.Forms.Label();
this.buttonUnBreak = new System.Windows.Forms.Button();
this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.buttonUndoListViewChanges = new System.Windows.Forms.Button();
this.labelStartTimeWarning = new System.Windows.Forms.Label();
this.labelDurationWarning = new System.Windows.Forms.Label();
@ -311,13 +307,17 @@
this.textBoxListViewText = new System.Windows.Forms.TextBox();
this.labelDuration = new System.Windows.Forms.Label();
this.labelAutoDuration = new System.Windows.Forms.Label();
this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.textBoxSource = new System.Windows.Forms.TextBox();
this.panelVideoPlayer = new System.Windows.Forms.Panel();
this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer();
this.contextMenuStripEmpty = new System.Windows.Forms.ContextMenuStrip(this.components);
this.insertLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer();
this.AudioWaveForm = new Nikse.SubtitleEdit.Controls.WaveForm();
this.timeUpDownVideoPosition = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.timeUpDownVideoPositionAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.statusStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
@ -1916,34 +1916,6 @@
this.toolStripButtonLockCenter.Text = "Center";
this.toolStripButtonLockCenter.Click += new System.EventHandler(this.toolStripButtonLockCenter_Click);
//
// AudioWaveForm
//
this.AudioWaveForm.AllowDrop = true;
this.AudioWaveForm.AllowNewSelection = true;
this.AudioWaveForm.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.AudioWaveForm.BackColor = System.Drawing.Color.Black;
this.AudioWaveForm.BackgroundColor = System.Drawing.Color.Black;
this.AudioWaveForm.Color = System.Drawing.Color.GreenYellow;
this.AudioWaveForm.DrawGridLines = true;
this.AudioWaveForm.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(18)))));
this.AudioWaveForm.Location = new System.Drawing.Point(475, 35);
this.AudioWaveForm.Margin = new System.Windows.Forms.Padding(0);
this.AudioWaveForm.Name = "AudioWaveForm";
this.AudioWaveForm.NewSelectionParagraph = null;
this.AudioWaveForm.SelectedColor = System.Drawing.Color.Red;
this.AudioWaveForm.Size = new System.Drawing.Size(762, 223);
this.AudioWaveForm.StartPositionSeconds = 0D;
this.AudioWaveForm.TabIndex = 6;
this.AudioWaveForm.TextColor = System.Drawing.Color.Gray;
this.AudioWaveForm.WaveFormNotLoadedText = "Click to add wave form";
this.AudioWaveForm.WavePeaks = null;
this.AudioWaveForm.ZoomFactor = 1D;
this.AudioWaveForm.Click += new System.EventHandler(this.AudioWaveForm_Click);
this.AudioWaveForm.DragDrop += new System.Windows.Forms.DragEventHandler(this.AudioWaveForm_DragDrop);
this.AudioWaveForm.DragEnter += new System.Windows.Forms.DragEventHandler(this.AudioWaveForm_DragEnter);
//
// tabControlButtons
//
this.tabControlButtons.Controls.Add(this.tabPageTranslate);
@ -2219,16 +2191,6 @@
this.tabPageCreate.Text = "Create";
this.tabPageCreate.UseVisualStyleBackColor = true;
//
// timeUpDownVideoPosition
//
this.timeUpDownVideoPosition.AutoSize = true;
this.timeUpDownVideoPosition.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownVideoPosition.Location = new System.Drawing.Point(86, 192);
this.timeUpDownVideoPosition.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownVideoPosition.Name = "timeUpDownVideoPosition";
this.timeUpDownVideoPosition.Size = new System.Drawing.Size(92, 25);
this.timeUpDownVideoPosition.TabIndex = 12;
//
// buttonGotoSub
//
this.buttonGotoSub.Location = new System.Drawing.Point(6, 58);
@ -2452,16 +2414,6 @@
this.tabPageAdjust.Text = "Adjust";
this.tabPageAdjust.UseVisualStyleBackColor = true;
//
// timeUpDownVideoPositionAdjust
//
this.timeUpDownVideoPositionAdjust.AutoSize = true;
this.timeUpDownVideoPositionAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownVideoPositionAdjust.Location = new System.Drawing.Point(87, 214);
this.timeUpDownVideoPositionAdjust.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownVideoPositionAdjust.Name = "timeUpDownVideoPositionAdjust";
this.timeUpDownVideoPositionAdjust.Size = new System.Drawing.Size(92, 25);
this.timeUpDownVideoPositionAdjust.TabIndex = 13;
//
// buttonAdjustSetEndTime
//
this.buttonAdjustSetEndTime.Location = new System.Drawing.Point(6, 84);
@ -2818,17 +2770,17 @@
//
this.groupBoxEdit.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxEdit.Controls.Add(this.labelCharactersPerSecond);
this.groupBoxEdit.Controls.Add(this.buttonAutoBreak);
this.groupBoxEdit.Controls.Add(this.panelSingleLine);
this.groupBoxEdit.Controls.Add(this.labelTextLineLengths);
this.groupBoxEdit.Controls.Add(this.labelTextLineTotal);
this.groupBoxEdit.Controls.Add(this.labelCharactersPerSecond);
this.groupBoxEdit.Controls.Add(this.buttonUnBreak);
this.groupBoxEdit.Controls.Add(this.timeUpDownStartTime);
this.groupBoxEdit.Controls.Add(this.buttonUndoListViewChanges);
this.groupBoxEdit.Controls.Add(this.labelStartTimeWarning);
this.groupBoxEdit.Controls.Add(this.labelDurationWarning);
this.groupBoxEdit.Controls.Add(this.numericUpDownDuration);
this.groupBoxEdit.Controls.Add(this.labelTextLineLengths);
this.groupBoxEdit.Controls.Add(this.buttonAutoBreak);
this.groupBoxEdit.Controls.Add(this.buttonPrevious);
this.groupBoxEdit.Controls.Add(this.buttonNext);
this.groupBoxEdit.Controls.Add(this.labelText);
@ -2882,16 +2834,6 @@
this.buttonUnBreak.UseVisualStyleBackColor = true;
this.buttonUnBreak.Click += new System.EventHandler(this.ButtonUnBreakClick);
//
// timeUpDownStartTime
//
this.timeUpDownStartTime.AutoSize = true;
this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownStartTime.Location = new System.Drawing.Point(9, 27);
this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownStartTime.Name = "timeUpDownStartTime";
this.timeUpDownStartTime.Size = new System.Drawing.Size(92, 25);
this.timeUpDownStartTime.TabIndex = 0;
//
// buttonUndoListViewChanges
//
this.buttonUndoListViewChanges.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@ -3040,31 +2982,6 @@
this.labelAutoDuration.TabIndex = 30;
this.labelAutoDuration.Text = "Auto";
//
// SubtitleListview1
//
this.SubtitleListview1.AllowDrop = true;
this.SubtitleListview1.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.SubtitleListview1.ContextMenuStrip = this.contextMenuStripListview;
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;
this.SubtitleListview1.Location = new System.Drawing.Point(1, 3);
this.SubtitleListview1.Name = "SubtitleListview1";
this.SubtitleListview1.Size = new System.Drawing.Size(932, 148);
this.SubtitleListview1.SmallImageList = this.imageList1;
this.SubtitleListview1.TabIndex = 0;
this.SubtitleListview1.UseCompatibleStateImageBehavior = false;
this.SubtitleListview1.View = System.Windows.Forms.View.Details;
this.SubtitleListview1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListview1_SelectedIndexChanged);
this.SubtitleListview1.DragDrop += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragDrop);
this.SubtitleListview1.DragEnter += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragEnter);
this.SubtitleListview1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SubtitleListview1_KeyDown);
this.SubtitleListview1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListview1_MouseDoubleClick);
//
// tabPage2
//
this.tabPage2.Controls.Add(this.textBoxSource);
@ -3109,6 +3026,55 @@
this.panelVideoPlayer.Size = new System.Drawing.Size(282, 278);
this.panelVideoPlayer.TabIndex = 5;
//
// contextMenuStripEmpty
//
this.contextMenuStripEmpty.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.insertLineToolStripMenuItem});
this.contextMenuStripEmpty.Name = "contextMenuStripEmpty";
this.contextMenuStripEmpty.Size = new System.Drawing.Size(126, 26);
//
// insertLineToolStripMenuItem
//
this.insertLineToolStripMenuItem.Name = "insertLineToolStripMenuItem";
this.insertLineToolStripMenuItem.Size = new System.Drawing.Size(125, 22);
this.insertLineToolStripMenuItem.Text = "Insert line";
this.insertLineToolStripMenuItem.Click += new System.EventHandler(this.insertLineToolStripMenuItem_Click);
//
// timeUpDownStartTime
//
this.timeUpDownStartTime.AutoSize = true;
this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownStartTime.Location = new System.Drawing.Point(9, 27);
this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownStartTime.Name = "timeUpDownStartTime";
this.timeUpDownStartTime.Size = new System.Drawing.Size(92, 25);
this.timeUpDownStartTime.TabIndex = 0;
//
// SubtitleListview1
//
this.SubtitleListview1.AllowDrop = true;
this.SubtitleListview1.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.SubtitleListview1.ContextMenuStrip = this.contextMenuStripListview;
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;
this.SubtitleListview1.Location = new System.Drawing.Point(1, 3);
this.SubtitleListview1.Name = "SubtitleListview1";
this.SubtitleListview1.Size = new System.Drawing.Size(932, 148);
this.SubtitleListview1.SmallImageList = this.imageList1;
this.SubtitleListview1.TabIndex = 0;
this.SubtitleListview1.UseCompatibleStateImageBehavior = false;
this.SubtitleListview1.View = System.Windows.Forms.View.Details;
this.SubtitleListview1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListview1_SelectedIndexChanged);
this.SubtitleListview1.DragDrop += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragDrop);
this.SubtitleListview1.DragEnter += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragEnter);
this.SubtitleListview1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SubtitleListview1_KeyDown);
this.SubtitleListview1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListview1_MouseDoubleClick);
//
// mediaPlayer
//
this.mediaPlayer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -3128,19 +3094,53 @@
this.mediaPlayer.DragDrop += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragDrop);
this.mediaPlayer.DragEnter += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragEnter);
//
// contextMenuStripEmpty
// AudioWaveForm
//
this.contextMenuStripEmpty.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.insertLineToolStripMenuItem});
this.contextMenuStripEmpty.Name = "contextMenuStripEmpty";
this.contextMenuStripEmpty.Size = new System.Drawing.Size(126, 26);
this.AudioWaveForm.AllowDrop = true;
this.AudioWaveForm.AllowNewSelection = true;
this.AudioWaveForm.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.AudioWaveForm.BackColor = System.Drawing.Color.Black;
this.AudioWaveForm.BackgroundColor = System.Drawing.Color.Black;
this.AudioWaveForm.Color = System.Drawing.Color.GreenYellow;
this.AudioWaveForm.DrawGridLines = true;
this.AudioWaveForm.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(18)))));
this.AudioWaveForm.Location = new System.Drawing.Point(475, 35);
this.AudioWaveForm.Margin = new System.Windows.Forms.Padding(0);
this.AudioWaveForm.Name = "AudioWaveForm";
this.AudioWaveForm.NewSelectionParagraph = null;
this.AudioWaveForm.SelectedColor = System.Drawing.Color.Red;
this.AudioWaveForm.Size = new System.Drawing.Size(762, 223);
this.AudioWaveForm.StartPositionSeconds = 0D;
this.AudioWaveForm.TabIndex = 6;
this.AudioWaveForm.TextColor = System.Drawing.Color.Gray;
this.AudioWaveForm.WaveFormNotLoadedText = "Click to add wave form";
this.AudioWaveForm.WavePeaks = null;
this.AudioWaveForm.ZoomFactor = 1D;
this.AudioWaveForm.Click += new System.EventHandler(this.AudioWaveForm_Click);
this.AudioWaveForm.DragDrop += new System.Windows.Forms.DragEventHandler(this.AudioWaveForm_DragDrop);
this.AudioWaveForm.DragEnter += new System.Windows.Forms.DragEventHandler(this.AudioWaveForm_DragEnter);
//
// insertLineToolStripMenuItem
// timeUpDownVideoPosition
//
this.insertLineToolStripMenuItem.Name = "insertLineToolStripMenuItem";
this.insertLineToolStripMenuItem.Size = new System.Drawing.Size(125, 22);
this.insertLineToolStripMenuItem.Text = "Insert line";
this.insertLineToolStripMenuItem.Click += new System.EventHandler(this.insertLineToolStripMenuItem_Click);
this.timeUpDownVideoPosition.AutoSize = true;
this.timeUpDownVideoPosition.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownVideoPosition.Location = new System.Drawing.Point(86, 192);
this.timeUpDownVideoPosition.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownVideoPosition.Name = "timeUpDownVideoPosition";
this.timeUpDownVideoPosition.Size = new System.Drawing.Size(92, 25);
this.timeUpDownVideoPosition.TabIndex = 12;
//
// timeUpDownVideoPositionAdjust
//
this.timeUpDownVideoPositionAdjust.AutoSize = true;
this.timeUpDownVideoPositionAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownVideoPositionAdjust.Location = new System.Drawing.Point(87, 214);
this.timeUpDownVideoPositionAdjust.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownVideoPositionAdjust.Name = "timeUpDownVideoPositionAdjust";
this.timeUpDownVideoPositionAdjust.Size = new System.Drawing.Size(92, 25);
this.timeUpDownVideoPositionAdjust.TabIndex = 13;
//
// Main
//

View File

@ -35,6 +35,7 @@ namespace Nikse.SubtitleEdit.Forms
Subtitle _subtitle = new Subtitle();
Subtitle _subtitleAlternate = new Subtitle();
string _subtitleAlternateFileName;
string _fileName;
string _videoFileName;
@ -216,7 +217,7 @@ namespace Nikse.SubtitleEdit.Forms
fileName = Configuration.Settings.RecentFiles.Files[0].FileName;
if (File.Exists(fileName))
{
OpenSubtitle(fileName, null, Configuration.Settings.RecentFiles.Files[0].VideoFileName);
OpenSubtitle(fileName, null, Configuration.Settings.RecentFiles.Files[0].VideoFileName, Configuration.Settings.RecentFiles.Files[0].OriginalFileName);
SetRecentIndecies(fileName);
}
}
@ -784,7 +785,7 @@ namespace Nikse.SubtitleEdit.Forms
_fileName = saveFileDialog1.FileName;
Text = Title + " - " + _fileName;
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName);
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName, _subtitleAlternateFileName);
Configuration.Settings.Save();
if (SaveSubtitle(GetCurrentSubtitleFormat()) == DialogResult.OK)
@ -928,10 +929,10 @@ namespace Nikse.SubtitleEdit.Forms
private void OpenSubtitle(string fileName, Encoding encoding)
{
OpenSubtitle(fileName, encoding, null);
OpenSubtitle(fileName, encoding, null, null);
}
private void OpenSubtitle(string fileName, Encoding encoding, string videoFileName)
private void OpenSubtitle(string fileName, Encoding encoding, string videoFileName, string orginalFileName)
{
if (File.Exists(fileName))
{
@ -939,7 +940,7 @@ namespace Nikse.SubtitleEdit.Forms
// save last first visible index + first selected index from listview
if (!string.IsNullOrEmpty(_fileName))
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName);
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName, orginalFileName);
openFileDialog1.InitialDirectory = Path.GetDirectoryName(fileName);
@ -1002,6 +1003,10 @@ namespace Nikse.SubtitleEdit.Forms
SetCurrentFormat(format);
_subtitleAlternateFileName = null;
if (LoadAlternateSubtitleFile(orginalFileName))
_subtitleAlternateFileName = orginalFileName;
textBoxSource.Text = _subtitle.ToText(format);
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
if (SubtitleListview1.Items.Count > 0)
@ -1018,9 +1023,9 @@ namespace Nikse.SubtitleEdit.Forms
OpenVideo(videoFileName);
}
else if (!string.IsNullOrEmpty(_fileName) && (toolStripButtonToogleVideo.Checked || toolStripButtonToogleWaveForm.Checked))
else if (!string.IsNullOrEmpty(fileName) && (toolStripButtonToogleVideo.Checked || toolStripButtonToogleWaveForm.Checked))
{
TryToFindAndOpenVideoFile(Path.Combine(Path.GetDirectoryName(_fileName), Path.GetFileNameWithoutExtension(_fileName)));
TryToFindAndOpenVideoFile(Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName)));
}
videoFileLoaded = _videoFileName != null;
@ -1031,7 +1036,7 @@ namespace Nikse.SubtitleEdit.Forms
}
else
{
Configuration.Settings.RecentFiles.Add(fileName, _videoFileName);
Configuration.Settings.RecentFiles.Add(fileName, _videoFileName, _subtitleAlternateFileName);
Configuration.Settings.Save();
UpdateRecentFilesUI();
}
@ -1083,7 +1088,7 @@ namespace Nikse.SubtitleEdit.Forms
AudioWaveForm.WavePeaks = null;
AudioWaveForm.Invalidate();
Configuration.Settings.RecentFiles.Add(fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName);
Configuration.Settings.RecentFiles.Add(fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName, _subtitleAlternateFileName);
Configuration.Settings.Save();
UpdateRecentFilesUI();
_fileName = fileName;
@ -1146,7 +1151,17 @@ namespace Nikse.SubtitleEdit.Forms
if (ContinueNewOrExit())
{
RecentFileEntry rfe = null;
foreach (var file in Configuration.Settings.RecentFiles.Files)
{
if (file.FileName == item.Text)
rfe = file;
}
if (rfe == null)
OpenSubtitle(item.Text, null);
else
OpenSubtitle(rfe.FileName, null, rfe.VideoFileName, rfe.OriginalFileName);
SetRecentIndecies(item.Text);
}
}
@ -1241,7 +1256,7 @@ namespace Nikse.SubtitleEdit.Forms
_fileDateTime = File.GetLastWriteTime(_fileName);
Text = Title + " - " + _fileName;
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName);
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName, _subtitleAlternateFileName);
Configuration.Settings.Save();
int index = 0;
@ -1362,6 +1377,7 @@ namespace Nikse.SubtitleEdit.Forms
SetCurrentFormat(new SubRip());
_subtitle = new Subtitle(_subtitle.HistoryItems);
_subtitleAlternate = new Subtitle();
_subtitleAlternateFileName = null;
textBoxSource.Text = string.Empty;
SubtitleListview1.Items.Clear();
_fileName = string.Empty;
@ -2607,6 +2623,7 @@ namespace Nikse.SubtitleEdit.Forms
_subtitleListViewIndex = -1;
_subtitleAlternate = new Subtitle(_subtitle);
_subtitleAlternateFileName = null;
MakeHistoryForUndo(_language.BeforeGoogleTranslation);
if (onlySelectedLines)
@ -2667,7 +2684,7 @@ namespace Nikse.SubtitleEdit.Forms
try
{
_subtitleAlternate = new Subtitle(_subtitle);
_subtitleAlternateFileName = null;
int firstSelectedIndex = 0;
if (SubtitleListview1.SelectedItems.Count > 0)
firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index;
@ -2798,7 +2815,7 @@ namespace Nikse.SubtitleEdit.Forms
int totalLinesChanged = 0;
try
{
wordSpellChecker = new WordSpellChecker();
wordSpellChecker = new WordSpellChecker(this);
wordSpellChecker.NewDocument();
Application.DoEvents();
}
@ -3952,7 +3969,7 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.General.AutoContinueOn = checkBoxAutoContinue.Checked;
Configuration.Settings.General.SyncListViewWithVideoWhilePlaying = checkBoxSyncListViewWithVideoWhilePlaying.Checked;
if (!string.IsNullOrEmpty(_fileName))
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName);
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName, _subtitleAlternateFileName);
Configuration.Settings.Save();
}
@ -5823,6 +5840,7 @@ namespace Nikse.SubtitleEdit.Forms
{
SubtitleListview1.HideAlternateTextColumn();
_subtitleAlternate = new Subtitle();
_subtitleAlternateFileName = null;
}
else
{
@ -5838,12 +5856,19 @@ namespace Nikse.SubtitleEdit.Forms
if (!(openFileDialog1.ShowDialog(this) == DialogResult.OK))
return;
string fileName = openFileDialog1.FileName;
if (!File.Exists(fileName))
if (!LoadAlternateSubtitleFile(openFileDialog1.FileName))
return;
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
}
private bool LoadAlternateSubtitleFile(string fileName)
{
if (!File.Exists(fileName))
return false;
if (Path.GetExtension(fileName).ToLower() == ".sub" && IsVobSubFile(fileName, false))
return;
return false;
var fi = new FileInfo(fileName);
if (fi.Length > 1024 * 1024 * 10) // max 10 mb
@ -5852,26 +5877,28 @@ namespace Nikse.SubtitleEdit.Forms
Environment.NewLine +
_language.ContinueAnyway,
fileName), Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
return;
return false;
}
Encoding encoding;
_subtitleAlternate = new Subtitle();
_subtitleAlternateFileName = fileName;
SubtitleFormat format = _subtitleAlternate.LoadSubtitle(fileName, out encoding, null);
if (format == null)
return;
return false;
if (format.IsFrameBased)
_subtitleAlternate.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
else
_subtitleAlternate.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
SubtitleListview1.ShowAlternateTextColumn(Configuration.Settings.Language.General.OriginalText);
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -14,6 +14,7 @@ namespace Nikse.SubtitleEdit.Logic
public class RecentFileEntry
{
public string FileName { get; set; }
public string OriginalFileName { get; set; }
public string VideoFileName { get; set; }
public int FirstVisibleIndex { get; set; }
public int FirstSelectedIndex { get; set; }
@ -31,35 +32,35 @@ namespace Nikse.SubtitleEdit.Logic
Files = new List<RecentFileEntry>();
}
public void Add(string fileName, int firstVisibleIndex, int firstSelectedIndex, string videoFileName)
public void Add(string fileName, int firstVisibleIndex, int firstSelectedIndex, string videoFileName, string originalFileName)
{
var newList = new List<RecentFileEntry> { new RecentFileEntry() { FileName = fileName, FirstVisibleIndex = firstVisibleIndex, FirstSelectedIndex = firstSelectedIndex, VideoFileName = videoFileName } };
var newList = new List<RecentFileEntry> { new RecentFileEntry() { FileName = fileName, FirstVisibleIndex = firstVisibleIndex, FirstSelectedIndex = firstSelectedIndex, VideoFileName = videoFileName, OriginalFileName = originalFileName } };
int index = 0;
foreach (var oldRecentFile in Files)
{
if (string.Compare(fileName, oldRecentFile.FileName, true) != 0 && index < MaxRecentFiles)
newList.Add(new RecentFileEntry() { FileName = oldRecentFile.FileName, FirstVisibleIndex = oldRecentFile.FirstVisibleIndex, FirstSelectedIndex = oldRecentFile.FirstSelectedIndex, VideoFileName = oldRecentFile.VideoFileName });
newList.Add(new RecentFileEntry() { FileName = oldRecentFile.FileName, FirstVisibleIndex = oldRecentFile.FirstVisibleIndex, FirstSelectedIndex = oldRecentFile.FirstSelectedIndex, VideoFileName = oldRecentFile.VideoFileName, OriginalFileName = oldRecentFile.OriginalFileName });
index++;
}
Files = newList;
}
public void Add(string fileName, string videoFileName)
public void Add(string fileName, string videoFileName, string originalFileName)
{
var newList = new List<RecentFileEntry>();
foreach (var oldRecentFile in Files)
{
if (string.Compare(fileName, oldRecentFile.FileName, true) == 0)
newList.Add(new RecentFileEntry() { FileName = oldRecentFile.FileName, FirstVisibleIndex = oldRecentFile.FirstVisibleIndex, FirstSelectedIndex = oldRecentFile.FirstSelectedIndex, VideoFileName = oldRecentFile.VideoFileName });
newList.Add(new RecentFileEntry() { FileName = oldRecentFile.FileName, FirstVisibleIndex = oldRecentFile.FirstVisibleIndex, FirstSelectedIndex = oldRecentFile.FirstSelectedIndex, VideoFileName = oldRecentFile.VideoFileName, OriginalFileName = oldRecentFile.OriginalFileName });
}
if (newList.Count == 0)
newList.Add(new RecentFileEntry() { FileName = fileName, FirstVisibleIndex = -1, FirstSelectedIndex = -1, VideoFileName = videoFileName });
newList.Add(new RecentFileEntry() { FileName = fileName, FirstVisibleIndex = -1, FirstSelectedIndex = -1, VideoFileName = videoFileName, OriginalFileName = originalFileName });
int index = 0;
foreach (var oldRecentFile in Files)
{
if (string.Compare(fileName, oldRecentFile.FileName, true) != 0 && index < MaxRecentFiles)
newList.Add(new RecentFileEntry() { FileName = oldRecentFile.FileName, FirstVisibleIndex = oldRecentFile.FirstVisibleIndex, FirstSelectedIndex = oldRecentFile.FirstSelectedIndex, VideoFileName = oldRecentFile.VideoFileName });
newList.Add(new RecentFileEntry() { FileName = oldRecentFile.FileName, FirstVisibleIndex = oldRecentFile.FirstVisibleIndex, FirstSelectedIndex = oldRecentFile.FirstSelectedIndex, VideoFileName = oldRecentFile.VideoFileName, OriginalFileName = oldRecentFile.OriginalFileName });
index++;
}
Files = newList;
@ -493,7 +494,11 @@ namespace Nikse.SubtitleEdit.Logic
if (listNode.Attributes["VideoFileName"] != null)
videoFileName = listNode.Attributes["VideoFileName"].Value;
settings.RecentFiles.Files.Add(new RecentFileEntry() { FileName = listNode.InnerText, FirstVisibleIndex = int.Parse(firstVisibleIndex), FirstSelectedIndex = int.Parse(firstSelectedIndex), VideoFileName = videoFileName });
string originalFileName = null;
if (listNode.Attributes["OriginalFileName"] != null)
originalFileName = listNode.Attributes["OriginalFileName"].Value;
settings.RecentFiles.Files.Add(new RecentFileEntry() { FileName = listNode.InnerText, FirstVisibleIndex = int.Parse(firstVisibleIndex), FirstSelectedIndex = int.Parse(firstSelectedIndex), VideoFileName = videoFileName, OriginalFileName = originalFileName });
}
@ -887,6 +892,8 @@ namespace Nikse.SubtitleEdit.Logic
foreach (var item in settings.RecentFiles.Files)
{
textWriter.WriteStartElement("FileName");
if (item.OriginalFileName != null)
textWriter.WriteAttributeString("OriginalFileName", item.OriginalFileName);
if (item.VideoFileName != null)
textWriter.WriteAttributeString("VideoFileName", item.VideoFileName);
textWriter.WriteAttributeString("FirstVisibleIndex", item.FirstVisibleIndex.ToString());