Fix bug in converting position tags - thx Mike :)

Added 'save as...' in "dvd sub rip - choose language" window (for quick save to sub/idx)


git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1627 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2013-02-13 19:04:47 +00:00
parent b5bf292d4a
commit 61d8df3a40
8 changed files with 176 additions and 24 deletions

View File

@ -35,6 +35,7 @@
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button();
this.groupBoxImage = new System.Windows.Forms.GroupBox();
this.buttonSaveAs = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImage)).BeginInit();
this.groupBoxImage.SuspendLayout();
this.SuspendLayout();
@ -119,11 +120,24 @@
this.groupBoxImage.TabStop = false;
this.groupBoxImage.Text = "Subtitle image";
//
// buttonSaveAs
//
this.buttonSaveAs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonSaveAs.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonSaveAs.Location = new System.Drawing.Point(487, 281);
this.buttonSaveAs.Name = "buttonSaveAs";
this.buttonSaveAs.Size = new System.Drawing.Size(118, 21);
this.buttonSaveAs.TabIndex = 15;
this.buttonSaveAs.Text = "Save as...";
this.buttonSaveAs.UseVisualStyleBackColor = true;
this.buttonSaveAs.Click += new System.EventHandler(this.buttonSaveAs_Click);
//
// DvdSubRipChooseLanguage
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(779, 314);
this.Controls.Add(this.buttonSaveAs);
this.Controls.Add(this.groupBoxImage);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
@ -157,5 +171,6 @@
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.GroupBox groupBoxImage;
private System.Windows.Forms.Button buttonSaveAs;
}
}

View File

@ -39,6 +39,7 @@ namespace Nikse.SubtitleEdit.Forms
labelChooseLanguage.Text = Configuration.Settings.Language.DvdSubRipChooseLanguage.ChooseLanguageStreamId;
buttonOK.Text = Configuration.Settings.Language.General.OK;
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
buttonSaveAs.Text = Configuration.Settings.Language.Main.Menu.File.SaveAs;
FixLargeFonts();
groupBoxImage.Text = Configuration.Settings.Language.DvdSubRipChooseLanguage.SubtitleImage;
}
@ -175,5 +176,30 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private void buttonSaveAs_Click(object sender, EventArgs e)
{
if (listBox1.Items.Count > -1)
{
if (_languages != null && comboBoxLanguages.SelectedIndex >= 0 && comboBoxLanguages.SelectedIndex < _languages.Count)
SelectedLanguageString = _languages[comboBoxLanguages.SelectedIndex];
else
SelectedLanguageString = null;
var subs = new List<VobSubMergedPack>();
foreach (var x in listBox1.Items)
{
subs.Add((x as SubListBoxItem).SubPack);
}
var formSubOcr = new VobSubOcr();
formSubOcr.InitializeQuick(subs, _palette, Configuration.Settings.VobSubOcr, SelectedLanguageString);
var subtitle = formSubOcr.ReadyVobSubRip();
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.InitializeFromVobSubOcr(subtitle, new Nikse.SubtitleEdit.Logic.SubtitleFormats.SubRip(), "VOBSUB", "DVD", formSubOcr);
exportBdnXmlPng.ShowDialog(this);
}
}
}
}

View File

@ -689,7 +689,16 @@ namespace Nikse.SubtitleEdit.Forms
if (toFormat.ToLower() != new AdvancedSubStationAlpha().Name.ToLower().Replace(" ", string.Empty) &&
toFormat.ToLower() != new SubStationAlpha().Name.ToLower().Replace(" ", string.Empty))
{
format.RemoveNativeFormatting(sub);
foreach (SubtitleFormat sf in formats)
{
if (sf.Name.ToLower().Replace(" ", string.Empty) == toFormat.ToLower() || sf.Name.ToLower().Replace(" ", string.Empty) == toFormat.Replace(" ", string.Empty).ToLower())
{
format.RemoveNativeFormatting(sub, sf);
break;
}
}
}
}
@ -3001,7 +3010,7 @@ namespace Nikse.SubtitleEdit.Forms
else
{
_subtitle.MakeHistoryForUndo(string.Format(_language.BeforeConvertingToX, GetCurrentSubtitleFormat().FriendlyName), _oldSubtitleFormat, _fileDateTime, _subtitleAlternate, _subtitleAlternateFileName, _subtitleListViewIndex, textBoxListViewText.SelectionStart, textBoxListViewTextAlternate.SelectionStart);
_oldSubtitleFormat.RemoveNativeFormatting(_subtitle);
_oldSubtitleFormat.RemoveNativeFormatting(_subtitle, GetCurrentSubtitleFormat());
SaveSubtitleListviewIndexes();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
RestoreSubtitleListviewIndexes();

View File

@ -380,6 +380,27 @@ namespace Nikse.SubtitleEdit.Forms
SetTesseractLanguageFromLanguageString(languageString);
}
internal void InitializeQuick(List<VobSubMergedPack> vobSubMergedPackist, List<Color> palette, VobSubOcrSettings vobSubOcrSettings, string languageString)
{
buttonOK.Enabled = false;
buttonCancel.Enabled = false;
buttonStartOcr.Enabled = false;
buttonStop.Enabled = false;
buttonNewCharacterDatabase.Enabled = false;
buttonEditCharacterDatabase.Enabled = false;
labelStatus.Text = string.Empty;
progressBar1.Visible = false;
progressBar1.Maximum = 100;
progressBar1.Value = 0;
numericUpDownPixelsIsSpace.Value = vobSubOcrSettings.XOrMorePixelsMakesSpace;
_vobSubOcrSettings = vobSubOcrSettings;
_vobSubMergedPackist = vobSubMergedPackist;
_palette = palette;
if (_palette == null)
checkBoxCustomFourColors.Checked = true;
}
internal void Initialize(List<Nikse.SubtitleEdit.Logic.BluRaySup.BluRaySupParser.PcsData> subtitles, VobSubOcrSettings vobSubOcrSettings, string fileName)
{
buttonOK.Enabled = false;
@ -1823,27 +1844,40 @@ namespace Nikse.SubtitleEdit.Forms
}
else
{
_vobSubMergedPackistOriginal = new List<VobSubMergedPack>();
bool hasIdxTimeCodes = false;
bool hasForcedSubtitles = false;
foreach (var x in _vobSubMergedPackist)
{
_vobSubMergedPackistOriginal.Add(x);
if (x.IdxLine != null)
hasIdxTimeCodes = true;
if (x.SubPicture.Forced)
hasForcedSubtitles = true;
}
checkBoxUseTimeCodesFromIdx.CheckedChanged -= checkBoxUseTimeCodesFromIdx_CheckedChanged;
checkBoxUseTimeCodesFromIdx.Visible = hasIdxTimeCodes;
checkBoxUseTimeCodesFromIdx.Checked = hasIdxTimeCodes;
checkBoxUseTimeCodesFromIdx.CheckedChanged += checkBoxUseTimeCodesFromIdx_CheckedChanged;
checkBoxShowOnlyForced.Enabled = hasForcedSubtitles;
LoadVobRip();
ReadyVobSubRip();
}
VobSubOcr_Resize(null, null);
}
public void DoHide()
{
base.SetVisibleCore(false);
}
public Subtitle ReadyVobSubRip()
{
_vobSubMergedPackistOriginal = new List<VobSubMergedPack>();
bool hasIdxTimeCodes = false;
bool hasForcedSubtitles = false;
if (_vobSubMergedPackist == null)
return null;
foreach (var x in _vobSubMergedPackist)
{
_vobSubMergedPackistOriginal.Add(x);
if (x.IdxLine != null)
hasIdxTimeCodes = true;
if (x.SubPicture.Forced)
hasForcedSubtitles = true;
}
checkBoxUseTimeCodesFromIdx.CheckedChanged -= checkBoxUseTimeCodesFromIdx_CheckedChanged;
checkBoxUseTimeCodesFromIdx.Visible = hasIdxTimeCodes;
checkBoxUseTimeCodesFromIdx.Checked = hasIdxTimeCodes;
checkBoxUseTimeCodesFromIdx.CheckedChanged += checkBoxUseTimeCodesFromIdx_CheckedChanged;
checkBoxShowOnlyForced.Enabled = hasForcedSubtitles;
LoadVobRip();
return _subtitle;
}
private void ButtonOkClick(object sender, EventArgs e)
{
if (Configuration.Settings.VobSubOcr.XOrMorePixelsMakesSpace != (int)numericUpDownPixelsIsSpace.Value && _bluRaySubtitlesOriginal == null)

View File

@ -754,7 +754,7 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
int.Parse(timeCode[3]) * 10);
}
public override void RemoveNativeFormatting(Subtitle subtitle)
public override void RemoveNativeFormatting(Subtitle subtitle, SubtitleFormat newFormat)
{
foreach (Paragraph p in subtitle.Paragraphs)
{
@ -775,6 +775,18 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
{
pre = s.Substring(0, 6);
}
else if (s.StartsWith("{\\an1\\") ||
s.StartsWith("{\\an2\\") ||
s.StartsWith("{\\an3\\") ||
s.StartsWith("{\\an4\\") ||
s.StartsWith("{\\an5\\") ||
s.StartsWith("{\\an6\\") ||
s.StartsWith("{\\an7\\") ||
s.StartsWith("{\\an8\\") ||
s.StartsWith("{\\an9\\"))
{
pre = s.Substring(0, 5) + "}";
}
int indexOfEnd = p.Text.IndexOf("}");
p.Text = p.Text.Remove(indexOfBegin, (indexOfEnd - indexOfBegin) + 1);

View File

@ -453,18 +453,74 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
int.Parse(timeCode[3]) * 10);
}
public override void RemoveNativeFormatting(Subtitle subtitle)
public override void RemoveNativeFormatting(Subtitle subtitle, SubtitleFormat newFormat)
{
foreach (Paragraph p in subtitle.Paragraphs)
{
int indexOfBegin = p.Text.IndexOf("{");
string pre = string.Empty;
while (indexOfBegin >= 0 && p.Text.IndexOf("}") > indexOfBegin)
{
string s = p.Text.Substring(indexOfBegin);
if (s.StartsWith("{\\an1}") ||
s.StartsWith("{\\an2}") ||
s.StartsWith("{\\an3}") ||
s.StartsWith("{\\an4}") ||
s.StartsWith("{\\an5}") ||
s.StartsWith("{\\an6}") ||
s.StartsWith("{\\an7}") ||
s.StartsWith("{\\an8}") ||
s.StartsWith("{\\an9}"))
{
pre = s.Substring(0, 6);
}
else if (s.StartsWith("{\\an1\\") ||
s.StartsWith("{\\an2\\") ||
s.StartsWith("{\\an3\\") ||
s.StartsWith("{\\an4\\") ||
s.StartsWith("{\\an5\\") ||
s.StartsWith("{\\an6\\") ||
s.StartsWith("{\\an7\\") ||
s.StartsWith("{\\an8\\") ||
s.StartsWith("{\\an9\\"))
{
pre = s.Substring(0, 5) + "}";
}
else if (s.StartsWith("{\\a1}") || s.StartsWith("{\\a1\\") ||
s.StartsWith("{\\a3}") || s.StartsWith("{\\a3\\"))
{
pre = s.Substring(0, 4) + "}";
}
else if (s.StartsWith("{\\a9}") || s.StartsWith("{\\a9\\"))
{
pre = "{\\an4}";
}
else if (s.StartsWith("{\\a10}") || s.StartsWith("{\\a10\\"))
{
pre = "{\\an5}";
}
else if (s.StartsWith("{\\a11}") || s.StartsWith("{\\a11\\"))
{
pre = "{\\an6}";
}
else if (s.StartsWith("{\\a5}") || s.StartsWith("{\\a5\\"))
{
pre = "{\\an7}";
}
else if (s.StartsWith("{\\a6}") || s.StartsWith("{\\a6\\"))
{
pre = "{\\an8}";
}
else if (s.StartsWith("{\\a7}") || s.StartsWith("{\\a7\\"))
{
pre = "{\\an9}";
}
int indexOfEnd = p.Text.IndexOf("}");
p.Text = p.Text.Remove(indexOfBegin, (indexOfEnd - indexOfBegin) +1);
p.Text = p.Text.Remove(indexOfBegin, (indexOfEnd - indexOfBegin) + 1);
indexOfBegin = p.Text.IndexOf("{");
}
p.Text = pre + p.Text;
}
}

View File

@ -209,7 +209,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
get { return Extension == new Idx().Extension; }
}
public virtual void RemoveNativeFormatting(Subtitle subtitle)
public virtual void RemoveNativeFormatting(Subtitle subtitle, SubtitleFormat newFormat)
{
}

View File

@ -109,7 +109,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
subtitle.Renumber(1);
}
public override void RemoveNativeFormatting(Subtitle subtitle)
public override void RemoveNativeFormatting(Subtitle subtitle, SubtitleFormat newFormat)
{
foreach (Paragraph p in subtitle.Paragraphs)
{