Minor fixes + started on Transcript importer

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@374 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-03-26 19:56:18 +00:00
parent 6794c60843
commit 506dd10c62
19 changed files with 712 additions and 134 deletions

View File

@ -49,7 +49,7 @@ namespace Nikse.SubtitleEdit.Forms
private void buttonDonate_Click(object sender, EventArgs e)
{
Process.Start("http://www.nikse.dk/Donate.aspx");
Process.Start("http://www.nikse.dk/Donate");
}
}

View File

@ -72,8 +72,8 @@
//
// groupBoxImportText
//
this.groupBoxImportText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxImportText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxImportText.Controls.Add(this.textBoxText);
this.groupBoxImportText.Controls.Add(this.buttonOpenText);
this.groupBoxImportText.Location = new System.Drawing.Point(12, 12);
@ -86,8 +86,8 @@
// textBoxText
//
this.textBoxText.AllowDrop = true;
this.textBoxText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBoxText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBoxText.Location = new System.Drawing.Point(6, 48);
this.textBoxText.MaxLength = 232767;
this.textBoxText.Multiline = true;
@ -124,7 +124,7 @@
this.checkBoxMergeShortLines.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxMergeShortLines.Location = new System.Drawing.Point(6, 98);
this.checkBoxMergeShortLines.Name = "checkBoxMergeShortLines";
this.checkBoxMergeShortLines.Size = new System.Drawing.Size(189, 17);
this.checkBoxMergeShortLines.Size = new System.Drawing.Size(193, 17);
this.checkBoxMergeShortLines.TabIndex = 40;
this.checkBoxMergeShortLines.Text = "Merge short lines with continuation";
this.checkBoxMergeShortLines.UseVisualStyleBackColor = true;
@ -169,7 +169,7 @@
this.radioButtonDurationFixed.AutoSize = true;
this.radioButtonDurationFixed.Location = new System.Drawing.Point(19, 42);
this.radioButtonDurationFixed.Name = "radioButtonDurationFixed";
this.radioButtonDurationFixed.Size = new System.Drawing.Size(50, 17);
this.radioButtonDurationFixed.Size = new System.Drawing.Size(51, 17);
this.radioButtonDurationFixed.TabIndex = 3;
this.radioButtonDurationFixed.Text = "Fixed";
this.radioButtonDurationFixed.UseVisualStyleBackColor = true;
@ -181,7 +181,7 @@
this.radioButtonDurationAuto.Checked = true;
this.radioButtonDurationAuto.Location = new System.Drawing.Point(19, 19);
this.radioButtonDurationAuto.Name = "radioButtonDurationAuto";
this.radioButtonDurationAuto.Size = new System.Drawing.Size(47, 17);
this.radioButtonDurationAuto.Size = new System.Drawing.Size(48, 17);
this.radioButtonDurationAuto.TabIndex = 2;
this.radioButtonDurationAuto.TabStop = true;
this.radioButtonDurationAuto.Text = "Auto";
@ -236,7 +236,7 @@
this.checkBoxRemoveLinesWithoutLetters.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxRemoveLinesWithoutLetters.Location = new System.Drawing.Point(6, 144);
this.checkBoxRemoveLinesWithoutLetters.Name = "checkBoxRemoveLinesWithoutLetters";
this.checkBoxRemoveLinesWithoutLetters.Size = new System.Drawing.Size(158, 17);
this.checkBoxRemoveLinesWithoutLetters.Size = new System.Drawing.Size(162, 17);
this.checkBoxRemoveLinesWithoutLetters.TabIndex = 5;
this.checkBoxRemoveLinesWithoutLetters.Text = "Remove lines without letters";
this.checkBoxRemoveLinesWithoutLetters.UseVisualStyleBackColor = true;
@ -259,7 +259,7 @@
this.radioButtonAutoSplit.Checked = true;
this.radioButtonAutoSplit.Location = new System.Drawing.Point(6, 19);
this.radioButtonAutoSplit.Name = "radioButtonAutoSplit";
this.radioButtonAutoSplit.Size = new System.Drawing.Size(88, 17);
this.radioButtonAutoSplit.Size = new System.Drawing.Size(93, 17);
this.radioButtonAutoSplit.TabIndex = 2;
this.radioButtonAutoSplit.TabStop = true;
this.radioButtonAutoSplit.Text = "Auto split text";
@ -271,7 +271,7 @@
this.radioButtonLineMode.AutoSize = true;
this.radioButtonLineMode.Location = new System.Drawing.Point(6, 42);
this.radioButtonLineMode.Name = "radioButtonLineMode";
this.radioButtonLineMode.Size = new System.Drawing.Size(131, 17);
this.radioButtonLineMode.Size = new System.Drawing.Size(133, 17);
this.radioButtonLineMode.TabIndex = 0;
this.radioButtonLineMode.Text = "One line is one subtitle";
this.radioButtonLineMode.UseVisualStyleBackColor = true;
@ -284,7 +284,7 @@
this.checkBoxRemoveEmptyLines.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxRemoveEmptyLines.Location = new System.Drawing.Point(6, 121);
this.checkBoxRemoveEmptyLines.Name = "checkBoxRemoveEmptyLines";
this.checkBoxRemoveEmptyLines.Size = new System.Drawing.Size(121, 17);
this.checkBoxRemoveEmptyLines.Size = new System.Drawing.Size(122, 17);
this.checkBoxRemoveEmptyLines.TabIndex = 3;
this.checkBoxRemoveEmptyLines.Text = "Remove empty lines";
this.checkBoxRemoveEmptyLines.UseVisualStyleBackColor = true;
@ -292,9 +292,9 @@
//
// groupBoxImportResult
//
this.groupBoxImportResult.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.groupBoxImportResult.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.groupBoxImportResult.Controls.Add(this.SubtitleListview1);
this.groupBoxImportResult.Location = new System.Drawing.Point(12, 344);
this.groupBoxImportResult.Name = "groupBoxImportResult";
@ -306,9 +306,9 @@
// 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.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.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;

View File

@ -7,6 +7,7 @@ using System.Text;
using System.Windows.Forms;
using System.IO;
using Nikse.SubtitleEdit.Logic;
using System.Xml;
namespace Nikse.SubtitleEdit.Forms
{
@ -62,10 +63,16 @@ namespace Nikse.SubtitleEdit.Forms
private void buttonOpenText_Click(object sender, EventArgs e)
{
openFileDialog1.Title = buttonOpenText.Text;
openFileDialog1.Filter = Configuration.Settings.Language.ImportText.TextFiles + "|*.txt|" + Configuration.Settings.Language.General.AllFiles + "|*.*";
openFileDialog1.Filter = Configuration.Settings.Language.ImportText.TextFiles + "|*.txt|Adobe Story|*.astx|" + Configuration.Settings.Language.General.AllFiles + "|*.*";
openFileDialog1.FileName = string.Empty;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
LoadTextFile(openFileDialog1.FileName);
{
string ext = Path.GetExtension(openFileDialog1.FileName).ToLower();
if (ext == ".astx")
LoadAdobeStory(openFileDialog1.FileName);
else
LoadTextFile(openFileDialog1.FileName);
}
}
private void GeneratePreview()
@ -313,28 +320,7 @@ namespace Nikse.SubtitleEdit.Forms
{
Encoding encoding = Utilities.GetEncodingFromFile(fileName);
textBoxText.Text = File.ReadAllText(fileName, encoding);
_videoFileName = fileName.Substring(0, fileName.Length - Path.GetExtension(fileName).Length);
if (_videoFileName.EndsWith(".en"))
_videoFileName = _videoFileName.Remove(_videoFileName.Length - 3);
if (File.Exists(_videoFileName + ".avi"))
{
_videoFileName += ".avi";
}
else if (File.Exists(_videoFileName + ".mkv"))
{
_videoFileName += ".mkv";
}
else
{
string[] files = Directory.GetFiles(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(_videoFileName) + "*.avi");
if (files.Length == 0)
files = Directory.GetFiles(Path.GetDirectoryName(fileName), "*.avi");
if (files.Length == 0)
files = Directory.GetFiles(Path.GetDirectoryName(fileName), "*.mkv");
if (files.Length > 0)
_videoFileName = files[0];
}
SetVideoFileName(fileName);
}
catch (Exception ex)
{
@ -343,6 +329,56 @@ namespace Nikse.SubtitleEdit.Forms
GeneratePreview();
}
private void LoadAdobeStory(string fileName)
{
try
{
StringBuilder sb = new StringBuilder();
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
foreach (XmlNode node in doc.DocumentElement.SelectNodes("//paragraph[@element='Dialog']")) // <paragraph objID="1:28" element="Dialog">
{
XmlNode textRun = node.SelectSingleNode("textRun"); // <textRun objID="1:259">Yeah...I suppose</textRun>
if (textRun != null)
sb.AppendLine(textRun.InnerText);
}
textBoxText.Text = sb.ToString();
SetVideoFileName(fileName);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
radioButtonLineMode.Checked = true;
checkBoxMergeShortLines.Checked = false;
GeneratePreview();
}
private void SetVideoFileName(string fileName)
{
_videoFileName = fileName.Substring(0, fileName.Length - Path.GetExtension(fileName).Length);
if (_videoFileName.EndsWith(".en"))
_videoFileName = _videoFileName.Remove(_videoFileName.Length - 3);
if (File.Exists(_videoFileName + ".avi"))
{
_videoFileName += ".avi";
}
else if (File.Exists(_videoFileName + ".mkv"))
{
_videoFileName += ".mkv";
}
else
{
string[] files = Directory.GetFiles(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(_videoFileName) + "*.avi");
if (files.Length == 0)
files = Directory.GetFiles(Path.GetDirectoryName(fileName), "*.avi");
if (files.Length == 0)
files = Directory.GetFiles(Path.GetDirectoryName(fileName), "*.mkv");
if (files.Length > 0)
_videoFileName = files[0];
}
}
private void buttonRefresh_Click(object sender, EventArgs e)
{
GeneratePreview();

View File

@ -177,6 +177,7 @@
this.toolStripMenuItemInsertBefore = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemInsertAfter = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemInsertSubtitle = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemCopySourceText = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.splitLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemMergeLines = new System.Windows.Forms.ToolStripMenuItem();
@ -1604,6 +1605,7 @@
this.toolStripMenuItemInsertBefore,
this.toolStripMenuItemInsertAfter,
this.toolStripMenuItemInsertSubtitle,
this.toolStripMenuItemCopySourceText,
this.toolStripSeparator7,
this.splitLineToolStripMenuItem,
this.toolStripMenuItemMergeLines,
@ -1630,7 +1632,7 @@
this.fixCommonErrorsInSelectedLinesToolStripMenuItem,
this.changeCasingForSelectedLinesToolStripMenuItem});
this.contextMenuStripListview.Name = "contextMenuStripListview";
this.contextMenuStripListview.Size = new System.Drawing.Size(276, 562);
this.contextMenuStripListview.Size = new System.Drawing.Size(276, 584);
this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening);
//
// toolStripMenuItemDelete
@ -1661,6 +1663,13 @@
this.toolStripMenuItemInsertSubtitle.Text = "Insert subtitle file after this line...";
this.toolStripMenuItemInsertSubtitle.Click += new System.EventHandler(this.toolStripMenuItemInsertSubtitle_Click);
//
// toolStripMenuItemCopySourceText
//
this.toolStripMenuItemCopySourceText.Name = "toolStripMenuItemCopySourceText";
this.toolStripMenuItemCopySourceText.Size = new System.Drawing.Size(275, 22);
this.toolStripMenuItemCopySourceText.Text = "Copy as text to clipboard";
this.toolStripMenuItemCopySourceText.Click += new System.EventHandler(this.toolStripMenuItemCopySourceText_Click);
//
// toolStripSeparator7
//
this.toolStripSeparator7.Name = "toolStripSeparator7";
@ -2819,7 +2828,7 @@
this.toolStripSeparator11,
this.toolStripMenuItemWaveFormPlaySelection});
this.contextMenuStripWaveForm.Name = "contextMenuStripWaveForm";
this.contextMenuStripWaveForm.Size = new System.Drawing.Size(183, 164);
this.contextMenuStripWaveForm.Size = new System.Drawing.Size(183, 142);
//
// addParagraphHereToolStripMenuItem
//
@ -3735,6 +3744,7 @@
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSetAudioTrack;
private System.Windows.Forms.Button buttonSplitLine;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemChangeFrameRate2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemCopySourceText;
}
}

View File

@ -641,6 +641,10 @@ namespace Nikse.SubtitleEdit.Forms
toolStripMenuItemInsertBefore.Text = _language.Menu.ContextMenu.InsertBefore;
toolStripMenuItemInsertAfter.Text = _language.Menu.ContextMenu.InsertAfter;
toolStripMenuItemInsertSubtitle.Text = _language.Menu.ContextMenu.InsertSubtitleAfter;
toolStripMenuItemCopySourceText.Visible = !string.IsNullOrEmpty(_language.Menu.ContextMenu.CopyToClipboard); //TODO: remove in 3.2
toolStripMenuItemCopySourceText.Text = _language.Menu.ContextMenu.CopyToClipboard;
splitLineToolStripMenuItem.Text = _language.Menu.ContextMenu.Split;
toolStripMenuItemMergeLines.Text = _language.Menu.ContextMenu.MergeSelectedLines;
mergeBeforeToolStripMenuItem.Text = _language.Menu.ContextMenu.MergeWithLineBefore;
@ -1474,9 +1478,10 @@ namespace Nikse.SubtitleEdit.Forms
_change = false;
return DialogResult.OK;
}
catch
catch (Exception exception)
{
MessageBox.Show(string.Format(_language.UnableToSaveSubtitleX, _fileName));
System.Diagnostics.Debug.Write(exception.Message);
return DialogResult.Cancel;
}
}
@ -2853,16 +2858,30 @@ namespace Nikse.SubtitleEdit.Forms
{
MessageBox.Show(_language.NoSubtitleLoaded, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
private static string GetTranslateStringFromNikseDk(string input)
{
// string url = String.Format("http://localhost:2782/mt/Translate.aspx?text={0}&langpair={1}", HttpUtility.UrlEncode(input), "svda");
// string url = String.Format("http://www.nikse.dk/mt/Translate.aspx?text={0}&langpair={1}", HttpUtility.UrlEncode(input), "svda");
string url = String.Format("http://www.nikse.dk/mt/Translate.aspx?text={0}&langpair={1}", Utilities.UrlEncode(input), "svda");
var webClient = new WebClient { Proxy = Utilities.GetProxy(), Encoding = System.Text.Encoding.UTF8 };
return webClient.DownloadString(url);
WebRequest.DefaultWebProxy = Utilities.GetProxy();
// WebRequest request = WebRequest.Create("http://localhost:54942/MultiTranslator/TranslateForSubtitleEdit");
WebRequest request = WebRequest.Create("http://www.nikse.dk/MultiTranslator/TranslateForSubtitleEdit");
request.Method = "POST";
string postData = String.Format("languagePair={1}&text={0}", Utilities.UrlEncode(input), "svda");
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
string result = responseFromServer;
reader.Close();
dataStream.Close();
response.Close();
return result;
}
private void TranslateFromSwedishToDanishToolStripMenuItemClick(object sender, EventArgs e)
@ -2906,25 +2925,15 @@ namespace Nikse.SubtitleEdit.Forms
output.Append(GetTranslateStringFromNikseDk(sb.ToString()));
MakeHistoryForUndo(_language.BeforeSwedishToDanishTranslation);
string result = output.ToString();
const string key = "<div id=\"translatedText\">";
int startIndex = result.IndexOf(key);
if (startIndex > 0)
string result = output.ToString();
if (result.Length > 0)
{
int index = 0;
while (startIndex > 0)
foreach (string s in result.Split(new string[] { "<p>", "</p>" }, StringSplitOptions.RemoveEmptyEntries))
{
startIndex += key.Length;
int endIndex = result.IndexOf("</div>", startIndex);
string translatedText = result.Substring(startIndex, endIndex - startIndex);
foreach (string s in translatedText.Split(new string[] { "<p>", "</p>" }, StringSplitOptions.RemoveEmptyEntries))
{
if (index < _subtitle.Paragraphs.Count)
_subtitle.Paragraphs[index].Text = s;
index++;
}
startIndex = result.IndexOf(key, startIndex + key.Length);
if (index < _subtitle.Paragraphs.Count)
_subtitle.Paragraphs[index].Text = s;
index++;
}
ShowSource();
SubtitleListview1.ShowAlternateTextColumn(Configuration.Settings.Language.General.OriginalText);
@ -5323,8 +5332,16 @@ namespace Nikse.SubtitleEdit.Forms
videoTimer.Stop();
timer1.Stop();
//if (SubtitleListview1.SelectedIndices.Count > 1)
// SubtitleListview1.EnsureVisible(SubtitleListview1.SelectedIndices[0]);
_showEarlierOrLater = new ShowEarlierLater();
_showEarlierOrLater.Initialize(ShowEarlierOrLater, true);
if (!_formPositionsAndSizes.SetPositionAndSize(_showEarlierOrLater))
{
_showEarlierOrLater.Top = this.Top + 100;
_showEarlierOrLater.Left = this.Left + (this.Width / 2) - (_showEarlierOrLater.Width / 3);
}
_showEarlierOrLater.Initialize(ShowEarlierOrLater, _formPositionsAndSizes, true);
MakeHistoryForUndo(_language.BeforeShowSelectedLinesEarlierLater);
_showEarlierOrLater.Show(this);
@ -5587,7 +5604,7 @@ namespace Nikse.SubtitleEdit.Forms
{
if (mediaPlayer.VideoPlayer != null)
{
GoBackSeconds(3, mediaPlayer);
GoBackSeconds(3);
}
}
else if (e.Modifiers == Keys.None && e.KeyCode == Keys.F8)
@ -6262,26 +6279,38 @@ namespace Nikse.SubtitleEdit.Forms
private void toolStripMenuItemImportText_Click(object sender, EventArgs e)
{
if (ContinueNewOrExit())
{
{
ImportText importText = new ImportText();
if (importText.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
SyncPointsSync syncPointSync = new SyncPointsSync();
syncPointSync.Initialize(importText.FixedSubtitle, _fileName, importText.VideoFileName, _videoAudioTrackNumber);
if (syncPointSync.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
ResetSubtitle();
FileNew();
_subtitleListViewIndex = -1;
MakeHistoryForUndo(_language.BeforeImportText);
_subtitle = importText.FixedSubtitle;
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
ShowStatus(_language.TextImported);
ShowSource();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
_change = true;
}
_videoFileName = syncPointSync.VideoFileName;
if (!string.IsNullOrEmpty(importText.VideoFileName))
OpenVideo(importText.VideoFileName);
var ti = new TranscriptImporter();
ti.Initialize(importText.FixedSubtitle, this);
ti.Top = this.Top + 100;
ti.Left = this.Left + (this.Width / 2) - (ti.Width / 3);
ti.Show(this);
//SyncPointsSync syncPointSync = new SyncPointsSync();
//syncPointSync.Initialize(importText.FixedSubtitle, _fileName, importText.VideoFileName, _videoAudioTrackNumber);
//if (syncPointSync.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
//{
// ResetSubtitle();
// _subtitleListViewIndex = -1;
// MakeHistoryForUndo(_language.BeforeImportText);
// _subtitle = importText.FixedSubtitle;
// _subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
// ShowStatus(_language.TextImported);
// ShowSource();
// SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
// _change = true;
//}
//_videoFileName = syncPointSync.VideoFileName;
}
}
}
@ -6583,7 +6612,7 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private void GoBackSeconds(double seconds, VideoPlayerContainer videoPlayerContainer)
internal void GoBackSeconds(double seconds)
{
if (mediaPlayer != null)
{
@ -6591,38 +6620,38 @@ namespace Nikse.SubtitleEdit.Forms
mediaPlayer.CurrentPosition -= seconds;
else
mediaPlayer.CurrentPosition = 0;
Utilities.ShowSubtitle(_subtitle.Paragraphs, videoPlayerContainer);
Utilities.ShowSubtitle(_subtitle.Paragraphs, mediaPlayer);
}
}
private void ButtonStartHalfASecondBackClick(object sender, EventArgs e)
{
GoBackSeconds(0.5, mediaPlayer);
GoBackSeconds(0.5);
}
private void ButtonStartThreeSecondsBackClick(object sender, EventArgs e)
{
GoBackSeconds(3.0, mediaPlayer);
GoBackSeconds(3.0);
}
private void ButtonStartOneMinuteBackClick(object sender, EventArgs e)
{
GoBackSeconds(60, mediaPlayer);
GoBackSeconds(60);
}
private void ButtonStartHalfASecondAheadClick(object sender, EventArgs e)
{
GoBackSeconds(-0.5, mediaPlayer);
GoBackSeconds(-0.5);
}
private void ButtonStartThreeSecondsAheadClick(object sender, EventArgs e)
{
GoBackSeconds(-3, mediaPlayer);
GoBackSeconds(-3);
}
private void ButtonStartOneMinuteAheadClick(object sender, EventArgs e)
{
GoBackSeconds(-60, mediaPlayer);
GoBackSeconds(-60);
}
private void videoTimer_Tick(object sender, EventArgs e)
@ -7216,8 +7245,13 @@ namespace Nikse.SubtitleEdit.Forms
}
_showEarlierOrLater = new ShowEarlierLater();
if (!_formPositionsAndSizes.SetPositionAndSize(_showEarlierOrLater))
{
_showEarlierOrLater.Top = this.Top + 100;
_showEarlierOrLater.Left = this.Left + (this.Width /2) - (_showEarlierOrLater.Width / 3);
}
SaveSubtitleListviewIndexes();
_showEarlierOrLater.Initialize(ShowEarlierOrLater, false);
_showEarlierOrLater.Initialize(ShowEarlierOrLater, _formPositionsAndSizes, false);
_showEarlierOrLater.Show(this);
}
else
@ -7491,12 +7525,12 @@ namespace Nikse.SubtitleEdit.Forms
private void buttonSecBack1_Click(object sender, EventArgs e)
{
GoBackSeconds((double)numericUpDownSec1.Value , mediaPlayer);
GoBackSeconds((double)numericUpDownSec1.Value);
}
private void buttonForward1_Click(object sender, EventArgs e)
{
GoBackSeconds(-(double)numericUpDownSec1.Value, mediaPlayer);
GoBackSeconds(-(double)numericUpDownSec1.Value);
}
private void ButtonSetStartAndOffsetRestClick(object sender, EventArgs e)
@ -7566,12 +7600,12 @@ namespace Nikse.SubtitleEdit.Forms
private void buttonAdjustSecBack_Click(object sender, EventArgs e)
{
GoBackSeconds((double)numericUpDownSecAdjust1.Value, mediaPlayer);
GoBackSeconds((double)numericUpDownSecAdjust1.Value);
}
private void buttonAdjustSecForward_Click(object sender, EventArgs e)
{
GoBackSeconds(-(double)numericUpDownSecAdjust1.Value, mediaPlayer);
GoBackSeconds(-(double)numericUpDownSecAdjust1.Value);
}
private void Main_Shown(object sender, EventArgs e)
@ -7816,22 +7850,22 @@ namespace Nikse.SubtitleEdit.Forms
private void buttonSecBack2_Click(object sender, EventArgs e)
{
GoBackSeconds((double)numericUpDownSec2.Value , mediaPlayer);
GoBackSeconds((double)numericUpDownSec2.Value);
}
private void buttonForward2_Click(object sender, EventArgs e)
{
GoBackSeconds(-(double)numericUpDownSec2.Value, mediaPlayer);
GoBackSeconds(-(double)numericUpDownSec2.Value);
}
private void buttonAdjustSecBack2_Click(object sender, EventArgs e)
{
GoBackSeconds((double)numericUpDownSecAdjust2.Value, mediaPlayer);
GoBackSeconds((double)numericUpDownSecAdjust2.Value);
}
private void buttonAdjustSecForward2_Click(object sender, EventArgs e)
{
GoBackSeconds(-(double)numericUpDownSecAdjust2.Value, mediaPlayer);
GoBackSeconds(-(double)numericUpDownSecAdjust2.Value);
}
private void translatepoweredByMicrosoftToolStripMenuItem_Click(object sender, EventArgs e)
@ -9417,5 +9451,82 @@ namespace Nikse.SubtitleEdit.Forms
SplitSelectedParagraph(null);
}
///////////// 3.2 /////////////
private void toolStripMenuItemCopySourceText_Click(object sender, EventArgs e)
{
Subtitle selectedLines = new Subtitle(_subtitle);
selectedLines.Paragraphs.Clear();
foreach (int index in SubtitleListview1.SelectedIndices)
selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]);
Clipboard.SetText(selectedLines.ToText(GetCurrentSubtitleFormat()));
}
public void PlayPause()
{
mediaPlayer.TogglePlayPause();
}
public void InsertViaEndPosition(string text, double durationMilliseconds, bool autoDuration)
{
if (mediaPlayer.VideoPlayer == null || string.IsNullOrEmpty(_videoFileName))
{
MessageBox.Show(Configuration.Settings.Language.General.NoVideoLoaded);
return;
}
if (autoDuration)
{
//TODO: auto duration
}
// current movie pos
double totalMilliseconds = (mediaPlayer.CurrentPosition * 1000.0) - durationMilliseconds;
//TODO: search for start via wave file (must only be minor adjustment)
int startNumber = 1;
if (_subtitle.Paragraphs.Count > 0)
startNumber = _subtitle.Paragraphs[0].Number;
TimeCode tc = new TimeCode(TimeSpan.FromMilliseconds(totalMilliseconds));
MakeHistoryForUndo(_language.BeforeInsertSubtitleAtVideoPosition + " " + tc.ToString());
// find index where to insert
int index = 0;
foreach (Paragraph p in _subtitle.Paragraphs)
{
if (p.StartTime.TotalMilliseconds > totalMilliseconds)
break;
index++;
}
// create and insert
if (_subtitle.Paragraphs.Count > 0 && index > 0 && totalMilliseconds < _subtitle.Paragraphs[index - 1].EndTime.TotalMilliseconds)
{
double diff = _subtitle.Paragraphs[index - 1].EndTime.TotalMilliseconds - totalMilliseconds;
totalMilliseconds += diff + 250;
durationMilliseconds -= diff + 250;
}
var newParagraph = new Paragraph(text, totalMilliseconds, totalMilliseconds + durationMilliseconds);
if (GetCurrentSubtitleFormat().IsFrameBased)
{
newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
}
_subtitle.Paragraphs.Insert(index, newParagraph);
_subtitleListViewIndex = -1;
_subtitle.Renumber(startNumber);
SubtitleListview1.Fill(_subtitle.Paragraphs);
SubtitleListview1.SelectIndexAndEnsureVisible(index);
ShowStatus(string.Format(_language.VideoControls.NewTextInsertAtX, newParagraph.StartTime.ToShortString()));
}
}
}

View File

@ -684,7 +684,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
CAAAAk1TRnQBSQFMAgEBAgEAAagBAwGoAQMBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CAAAAk1TRnQBSQFMAgEBAgEAAQgBBAEIAQQBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@ -41,6 +41,7 @@ namespace Nikse.SubtitleEdit.Forms
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.checkBoxOnlyContinuationLines = new System.Windows.Forms.CheckBox();
this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).BeginInit();
@ -51,7 +52,7 @@ namespace Nikse.SubtitleEdit.Forms
//
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(608, 552);
this.buttonOK.Location = new System.Drawing.Point(608, 562);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 21);
this.buttonOK.TabIndex = 6;
@ -64,7 +65,7 @@ namespace Nikse.SubtitleEdit.Forms
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(689, 552);
this.buttonCancel.Location = new System.Drawing.Point(689, 562);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 8;
@ -86,7 +87,7 @@ namespace Nikse.SubtitleEdit.Forms
0,
0});
this.numericUpDownMaxCharacters.Name = "numericUpDownMaxCharacters";
this.numericUpDownMaxCharacters.Size = new System.Drawing.Size(64, 27);
this.numericUpDownMaxCharacters.Size = new System.Drawing.Size(64, 21);
this.numericUpDownMaxCharacters.TabIndex = 0;
this.numericUpDownMaxCharacters.Value = new decimal(new int[] {
65,
@ -100,7 +101,7 @@ namespace Nikse.SubtitleEdit.Forms
this.labelMaxCharacters.AutoSize = true;
this.labelMaxCharacters.Location = new System.Drawing.Point(187, 9);
this.labelMaxCharacters.Name = "labelMaxCharacters";
this.labelMaxCharacters.Size = new System.Drawing.Size(294, 21);
this.labelMaxCharacters.Size = new System.Drawing.Size(190, 13);
this.labelMaxCharacters.TabIndex = 32;
this.labelMaxCharacters.Text = "Maximum characters in one paragraph";
//
@ -109,7 +110,7 @@ namespace Nikse.SubtitleEdit.Forms
this.labelMaxMillisecondsBetweenLines.AutoSize = true;
this.labelMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(483, 9);
this.labelMaxMillisecondsBetweenLines.Name = "labelMaxMillisecondsBetweenLines";
this.labelMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(284, 21);
this.labelMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(178, 13);
this.labelMaxMillisecondsBetweenLines.TabIndex = 33;
this.labelMaxMillisecondsBetweenLines.Text = "Maximum milliseconds between lines";
//
@ -127,7 +128,7 @@ namespace Nikse.SubtitleEdit.Forms
0,
0});
this.numericUpDownMaxMillisecondsBetweenLines.Name = "numericUpDownMaxMillisecondsBetweenLines";
this.numericUpDownMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(64, 27);
this.numericUpDownMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(64, 21);
this.numericUpDownMaxMillisecondsBetweenLines.TabIndex = 2;
this.numericUpDownMaxMillisecondsBetweenLines.Value = new decimal(new int[] {
250,
@ -138,10 +139,10 @@ namespace Nikse.SubtitleEdit.Forms
//
// groupBoxLinesFound
//
this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxLinesFound.Controls.Add(this.listViewFixes);
this.groupBoxLinesFound.Location = new System.Drawing.Point(12, 51);
this.groupBoxLinesFound.Location = new System.Drawing.Point(13, 68);
this.groupBoxLinesFound.Name = "groupBoxLinesFound";
this.groupBoxLinesFound.Size = new System.Drawing.Size(752, 200);
this.groupBoxLinesFound.TabIndex = 36;
@ -150,8 +151,8 @@ namespace Nikse.SubtitleEdit.Forms
//
// listViewFixes
//
this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listViewFixes.CheckBoxes = true;
this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader4,
@ -181,29 +182,43 @@ namespace Nikse.SubtitleEdit.Forms
this.columnHeader7.Text = "New text";
this.columnHeader7.Width = 500;
//
// checkBoxOnlyContinuationLines
//
this.checkBoxOnlyContinuationLines.AutoSize = true;
this.checkBoxOnlyContinuationLines.Checked = true;
this.checkBoxOnlyContinuationLines.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxOnlyContinuationLines.Location = new System.Drawing.Point(190, 54);
this.checkBoxOnlyContinuationLines.Name = "checkBoxOnlyContinuationLines";
this.checkBoxOnlyContinuationLines.Size = new System.Drawing.Size(167, 17);
this.checkBoxOnlyContinuationLines.TabIndex = 37;
this.checkBoxOnlyContinuationLines.Text = "Only merge continuation lines";
this.checkBoxOnlyContinuationLines.UseVisualStyleBackColor = true;
this.checkBoxOnlyContinuationLines.CheckedChanged += new System.EventHandler(this.checkBoxOnlyContinuationLines_CheckedChanged);
//
// 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.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.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(10, 257);
this.SubtitleListview1.Location = new System.Drawing.Point(10, 274);
this.SubtitleListview1.Name = "SubtitleListview1";
this.SubtitleListview1.Size = new System.Drawing.Size(757, 289);
this.SubtitleListview1.Size = new System.Drawing.Size(757, 282);
this.SubtitleListview1.TabIndex = 4;
this.SubtitleListview1.UseCompatibleStateImageBehavior = false;
this.SubtitleListview1.View = System.Windows.Forms.View.Details;
//
// MergeShortLines
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(776, 585);
this.ClientSize = new System.Drawing.Size(776, 595);
this.Controls.Add(this.checkBoxOnlyContinuationLines);
this.Controls.Add(this.numericUpDownMaxCharacters);
this.Controls.Add(this.groupBoxLinesFound);
this.Controls.Add(this.numericUpDownMaxMillisecondsBetweenLines);
@ -242,5 +257,6 @@ namespace Nikse.SubtitleEdit.Forms
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.ColumnHeader columnHeader7;
private System.Windows.Forms.CheckBox checkBoxOnlyContinuationLines;
}
}

View File

@ -51,6 +51,9 @@ namespace Nikse.SubtitleEdit.Forms
labelMaxCharacters.Text = Configuration.Settings.Language.MergedShortLines.MaximumCharacters;
labelMaxMillisecondsBetweenLines.Text = Configuration.Settings.Language.MergedShortLines.MaximumMillisecondsBetween;
checkBoxOnlyContinuationLines.Visible = !string.IsNullOrEmpty(Configuration.Settings.Language.MergedShortLines.OnlyMergeContinuationLines); //TODO: Remove in se 3.2
checkBoxOnlyContinuationLines.Text = Configuration.Settings.Language.MergedShortLines.OnlyMergeContinuationLines;
listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply;
listViewFixes.Columns[1].Text = Configuration.Settings.Language.MergedShortLines.LineNumber;
listViewFixes.Columns[2].Text = Configuration.Settings.Language.MergedShortLines.MergedText;
@ -224,7 +227,7 @@ namespace Nikse.SubtitleEdit.Forms
return startTag;
}
private static bool QualifiesForMerge(Paragraph p, Paragraph next, double maximumMillisecondsBetweenLines, int maximumTotalLength)
private bool QualifiesForMerge(Paragraph p, Paragraph next, double maximumMillisecondsBetweenLines, int maximumTotalLength)
{
if (p != null && p.Text != null && next != null && next.Text != null)
{
@ -236,6 +239,10 @@ namespace Nikse.SubtitleEdit.Forms
if (string.IsNullOrEmpty(s))
return true;
bool isLineContinuation = s.EndsWith(",") || s.EndsWith("-") || s.EndsWith("...") || Utilities.GetLetters(true, true, true).Contains(s.Substring(s.Length - 1));
if (!checkBoxOnlyContinuationLines.Checked)
return true;
if (isLineContinuation)
return true;
}
@ -318,6 +325,13 @@ namespace Nikse.SubtitleEdit.Forms
if (listViewFixes.Items.Count > 0)
listViewFixes.Items[0].Selected = true;
}
private void checkBoxOnlyContinuationLines_CheckedChanged(object sender, EventArgs e)
{
Cursor = Cursors.WaitCursor;
GeneratePreview();
Cursor = Cursors.Default;
}
}

View File

@ -135,7 +135,9 @@ namespace Nikse.SubtitleEdit.Forms
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ShowEarlierLater";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Show selected lines earlier/later";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ShowEarlierLater_FormClosing);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ShowEarlierLater_KeyDown);
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -11,6 +11,7 @@ namespace Nikse.SubtitleEdit.Forms
TimeSpan _totalAdjustment = TimeSpan.FromMilliseconds(0);
AdjustEventHandler _adjustCallback;
PositionsAndSizes _formPositionsAndSizes;
public ShowEarlierLater()
{
@ -51,8 +52,9 @@ namespace Nikse.SubtitleEdit.Forms
}
}
internal void Initialize(AdjustEventHandler adjustCallback, bool onlySelected)
internal void Initialize(AdjustEventHandler adjustCallback, PositionsAndSizes formPositionsAndSizes, bool onlySelected)
{
_formPositionsAndSizes = formPositionsAndSizes;
if (onlySelected)
radioButtonSelectedLinesOnly.Checked = true;
else
@ -100,5 +102,10 @@ namespace Nikse.SubtitleEdit.Forms
Text = Configuration.Settings.Language.ShowEarlierLater.TitleAll;
}
private void ShowEarlierLater_FormClosing(object sender, FormClosingEventArgs e)
{
_formPositionsAndSizes.SavePositionAndSize(this);
}
}
}

169
src/Forms/TranscriptImporter.Designer.cs generated Normal file
View File

@ -0,0 +1,169 @@
namespace Nikse.SubtitleEdit.Forms
{
partial class TranscriptImporter
{
/// <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()
{
this.textBoxListViewText = new System.Windows.Forms.TextBox();
this.labelText = new System.Windows.Forms.Label();
this.buttonInsert = new System.Windows.Forms.Button();
this.labelTranslateTip = new System.Windows.Forms.Label();
this.buttonStartThreeSecondsBack = new System.Windows.Forms.Button();
this.buttonStartHalfASecondBack = new System.Windows.Forms.Button();
this.buttonPlayPause = new System.Windows.Forms.Button();
this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
this.SuspendLayout();
//
// textBoxListViewText
//
this.textBoxListViewText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.textBoxListViewText.Enabled = false;
this.textBoxListViewText.HideSelection = false;
this.textBoxListViewText.Location = new System.Drawing.Point(12, 294);
this.textBoxListViewText.Multiline = true;
this.textBoxListViewText.Name = "textBoxListViewText";
this.textBoxListViewText.Size = new System.Drawing.Size(373, 56);
this.textBoxListViewText.TabIndex = 7;
//
// labelText
//
this.labelText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelText.AutoSize = true;
this.labelText.Location = new System.Drawing.Point(12, 278);
this.labelText.Name = "labelText";
this.labelText.Size = new System.Drawing.Size(28, 13);
this.labelText.TabIndex = 8;
this.labelText.Text = "Text";
//
// buttonInsert
//
this.buttonInsert.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonInsert.Location = new System.Drawing.Point(257, 362);
this.buttonInsert.Name = "buttonInsert";
this.buttonInsert.Size = new System.Drawing.Size(189, 21);
this.buttonInsert.TabIndex = 9;
this.buttonInsert.Text = "Insert text (end time=video pos)";
this.buttonInsert.UseVisualStyleBackColor = true;
this.buttonInsert.Click += new System.EventHandler(this.buttonInsert_Click);
//
// labelTranslateTip
//
this.labelTranslateTip.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelTranslateTip.AutoSize = true;
this.labelTranslateTip.ForeColor = System.Drawing.Color.Gray;
this.labelTranslateTip.Location = new System.Drawing.Point(452, 370);
this.labelTranslateTip.Name = "labelTranslateTip";
this.labelTranslateTip.Size = new System.Drawing.Size(161, 13);
this.labelTranslateTip.TabIndex = 10;
this.labelTranslateTip.Text = "Tip: Shortcut for insert is [Space]";
//
// buttonStartThreeSecondsBack
//
this.buttonStartThreeSecondsBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonStartThreeSecondsBack.Location = new System.Drawing.Point(15, 362);
this.buttonStartThreeSecondsBack.Name = "buttonStartThreeSecondsBack";
this.buttonStartThreeSecondsBack.Size = new System.Drawing.Size(60, 21);
this.buttonStartThreeSecondsBack.TabIndex = 11;
this.buttonStartThreeSecondsBack.Text = "< 3 secs";
this.buttonStartThreeSecondsBack.UseVisualStyleBackColor = true;
this.buttonStartThreeSecondsBack.Click += new System.EventHandler(this.buttonStartThreeSecondsBack_Click);
//
// buttonStartHalfASecondBack
//
this.buttonStartHalfASecondBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonStartHalfASecondBack.Location = new System.Drawing.Point(81, 362);
this.buttonStartHalfASecondBack.Name = "buttonStartHalfASecondBack";
this.buttonStartHalfASecondBack.Size = new System.Drawing.Size(60, 21);
this.buttonStartHalfASecondBack.TabIndex = 12;
this.buttonStartHalfASecondBack.Text = "< ½ sec";
this.buttonStartHalfASecondBack.UseVisualStyleBackColor = true;
this.buttonStartHalfASecondBack.Click += new System.EventHandler(this.buttonStartHalfASecondBack_Click);
//
// buttonPlayPause
//
this.buttonPlayPause.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonPlayPause.Location = new System.Drawing.Point(147, 362);
this.buttonPlayPause.Name = "buttonPlayPause";
this.buttonPlayPause.Size = new System.Drawing.Size(104, 21);
this.buttonPlayPause.TabIndex = 13;
this.buttonPlayPause.Text = "Play/pause";
this.buttonPlayPause.UseVisualStyleBackColor = true;
this.buttonPlayPause.Click += new System.EventHandler(this.buttonPlayPause_Click);
//
// 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.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(12, 12);
this.SubtitleListview1.Name = "SubtitleListview1";
this.SubtitleListview1.Size = new System.Drawing.Size(637, 258);
this.SubtitleListview1.TabIndex = 6;
this.SubtitleListview1.UseCompatibleStateImageBehavior = false;
this.SubtitleListview1.View = System.Windows.Forms.View.Details;
//
// TranscriptImporter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(661, 392);
this.Controls.Add(this.buttonPlayPause);
this.Controls.Add(this.buttonStartThreeSecondsBack);
this.Controls.Add(this.buttonStartHalfASecondBack);
this.Controls.Add(this.labelTranslateTip);
this.Controls.Add(this.buttonInsert);
this.Controls.Add(this.labelText);
this.Controls.Add(this.textBoxListViewText);
this.Controls.Add(this.SubtitleListview1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.KeyPreview = true;
this.MinimumSize = new System.Drawing.Size(533, 376);
this.Name = "TranscriptImporter";
this.Text = "Transcript importer";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBoxListViewText;
private Controls.SubtitleListView SubtitleListview1;
private System.Windows.Forms.Label labelText;
private System.Windows.Forms.Button buttonInsert;
private System.Windows.Forms.Label labelTranslateTip;
private System.Windows.Forms.Button buttonStartThreeSecondsBack;
private System.Windows.Forms.Button buttonStartHalfASecondBack;
private System.Windows.Forms.Button buttonPlayPause;
}
}

View File

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms
{
public partial class TranscriptImporter : Form
{
Main _main;
Subtitle _subtitle;
public TranscriptImporter()
{
InitializeComponent();
FixLargeFonts();
}
private void FixLargeFonts()
{
Graphics graphics = this.CreateGraphics();
SizeF textSize = graphics.MeasureString("OK", this.Font);
if (textSize.Height > buttonInsert.Height - 4)
{
int newButtonHeight = (int)(textSize.Height + 7 + 0.5);
Utilities.SetButtonHeight(this, newButtonHeight, 1);
}
}
public void Initialize(Subtitle subtitle, Main main)
{
_subtitle = subtitle;
_main = main;
if (subtitle.Paragraphs.Count > 0)
subtitle.Renumber(subtitle.Paragraphs[0].Number);
// Text = Configuration.Settings.Language.SplitLongLines.Title;
//buttonOK.Text = Configuration.Settings.Language.General.OK;
//buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings);
Utilities.InitializeSubtitleFont(SubtitleListview1);
SubtitleListview1.AutoSizeAllColumns(this);
SubtitleListview1.Fill(subtitle);
SubtitleListview1.SelectIndexAndEnsureVisible(0);
}
private void buttonInsert_Click(object sender, EventArgs e)
{
if (SubtitleListview1.SelectedIndices.Count == 1)
{
int index = SubtitleListview1.SelectedIndices[0];
var p = _subtitle.Paragraphs[index];
_main.InsertViaEndPosition(p.Text, p.Duration.TotalMilliseconds, false);
SubtitleListview1.Items[index].Selected = false;
SubtitleListview1.SelectIndexAndEnsureVisible(index + 1);
}
}
private void buttonPlayPause_Click(object sender, EventArgs e)
{
_main.PlayPause();
}
private void buttonStartHalfASecondBack_Click(object sender, EventArgs e)
{
_main.GoBackSeconds(0.5);
}
private void buttonStartThreeSecondsBack_Click(object sender, EventArgs e)
{
_main.GoBackSeconds(3.0);
}
}
}

View File

@ -0,0 +1,120 @@
<?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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -73,12 +73,8 @@ namespace Nikse.SubtitleEdit.Logic
if (Instance._dataDir == null)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + "Subtitle Edit";
bool useApplicationData = BaseDirectory.StartsWith(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), StringComparison.OrdinalIgnoreCase);
if (!useApplicationData)
useApplicationData = !Directory.Exists(BaseDirectory + "Dictionaries") && Directory.Exists(Path.Combine(path, "Directonries"));
if (useApplicationData)
if (BaseDirectory.StartsWith(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), StringComparison.OrdinalIgnoreCase)
&& Directory.Exists(Path.Combine(path, "Dictionaries")))
{
try
{

View File

@ -832,6 +832,7 @@ namespace Nikse.SubtitleEdit.Logic
InsertBefore = "Insert before",
InsertAfter = "Insert after",
InsertSubtitleAfter = "Insert subtitle after this line...",
CopyToClipboard = "Copy as text to clipboard",
Split = "Split",
MergeSelectedLines = "Merge selected lines",
MergeWithLineBefore = "Merge with line before",
@ -938,6 +939,7 @@ namespace Nikse.SubtitleEdit.Logic
NumberOfMergesX = "Number of merges: {0}",
LineNumber = "Line#",
MergedText = "Merged text",
OnlyMergeContinuationLines = "Only merge continuation lines",
};
MultipleReplace = new LanguageStructure.MultipleReplace

View File

@ -752,6 +752,7 @@
public string InsertBefore { get; set; }
public string InsertAfter { get; set; }
public string InsertSubtitleAfter { get; set; }
public string CopyToClipboard { get; set; }
public string Split { get; set; }
public string MergeSelectedLines { get; set; }
public string MergeWithLineBefore { get; set; }
@ -874,6 +875,7 @@
public string NumberOfMergesX { get; set; }
public string LineNumber { get; set; }
public string MergedText { get; set; }
public string OnlyMergeContinuationLines { get; set; }
}
public class MultipleReplace

View File

@ -7,10 +7,10 @@ namespace Nikse.SubtitleEdit.Logic
{
List<PositionAndSize> _positionsAndSizes = new List<PositionAndSize>();
public void SetPositionAndSize(Form form)
public bool SetPositionAndSize(Form form)
{
if (form == null)
return;
return false;
foreach (PositionAndSize ps in _positionsAndSizes)
{
@ -20,9 +20,10 @@ namespace Nikse.SubtitleEdit.Logic
form.Left = ps.Left;
form.Top = ps.Top;
form.Size = ps.Size;
break;
return true;
}
}
return false;
}
public void SavePositionAndSize(Form form)

View File

@ -1035,7 +1035,7 @@ namespace Nikse.SubtitleEdit.Logic
{
string helpFile = Configuration.Settings.Language.General.HelpFile;
if (string.IsNullOrEmpty(helpFile))
helpFile = "http://www.nikse.dk/se/Help.aspx";
helpFile = "http://www.nikse.dk/SubtitleEdit/Help";
System.Diagnostics.Process.Start(helpFile + parameter);
}

View File

@ -369,6 +369,12 @@
<Compile Include="Forms\StartNumberingFrom.Designer.cs">
<DependentUpon>StartNumberingFrom.cs</DependentUpon>
</Compile>
<Compile Include="Forms\TranscriptImporter.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\TranscriptImporter.Designer.cs">
<DependentUpon>TranscriptImporter.cs</DependentUpon>
</Compile>
<Compile Include="Forms\UnknownSubtitle.cs">
<SubType>Form</SubType>
</Compile>
@ -511,6 +517,8 @@
<Compile Include="Logic\StripableText.cs" />
<Compile Include="Logic\SubtitleFormats\AdobeEncore.cs" />
<Compile Include="Logic\SubtitleFormats\AdobeEncoreTabs.cs" />
<Compile Include="Logic\SubtitleFormats\DCSubtitle.cs" />
<Compile Include="Logic\SubtitleFormats\FinalCutProTextXml.cs" />
<Compile Include="Logic\SubtitleFormats\FinalCutProXml.cs" />
<Compile Include="Logic\SubtitleFormats\Pac.cs" />
<Compile Include="Logic\SubtitleFormats\PinnacleImpression.cs" />
@ -526,6 +534,7 @@
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle5.cs" />
<Compile Include="Logic\SubtitleFormats\OpenDvt.cs" />
<Compile Include="Logic\SubtitleFormats\AbcIViewer.cs" />
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle6.cs" />
<Compile Include="Logic\SubtitleFormats\YouTubeSbv.cs" />
<Compile Include="Logic\SubtitleFormats\SubViewer10.cs" />
<Compile Include="Logic\SubtitleFormats\TimedText.cs" />
@ -739,6 +748,9 @@
<DependentUpon>StartNumberingFrom.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\TranscriptImporter.resx">
<DependentUpon>TranscriptImporter.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\UnknownSubtitle.resx">
<DependentUpon>UnknownSubtitle.cs</DependentUpon>
<SubType>Designer</SubType>