Try to keep styles from ttml draft to ASS - thx Bill :)

Also, added UI setting to take ASS/SSA style from source in "Batch convert"
This commit is contained in:
Nikolaj Olsson 2017-07-27 13:31:54 +02:00
parent 375b414daa
commit 915d254342
10 changed files with 249 additions and 51 deletions

View File

@ -166,6 +166,7 @@ Note: Do check free disk space.</WaveFileMalformed>
<ChooseOutputFolder>Choose output folder</ChooseOutputFolder>
<OverwriteExistingFiles>Overwrite existing files</OverwriteExistingFiles>
<Style>Style...</Style>
<UseStyleFromSource>Use style from source</UseStyleFromSource>
<ConvertOptions>Convert options</ConvertOptions>
<RemoveFormatting>Remove formatting tags</RemoveFormatting>
<RemoveTextForHI>Remove text for HI</RemoveTextForHI>

View File

@ -304,6 +304,7 @@ namespace Nikse.SubtitleEdit.Core
RemoveFormatting = "Remove formatting tags",
Status = "Status",
Style = "Style...",
UseStyleFromSource = "Use style from source",
NothingToConvert = "Nothing to convert!",
PleaseChooseOutputFolder = "Please choose output folder",
NotConverted = "Failed",

View File

@ -439,6 +439,9 @@ namespace Nikse.SubtitleEdit.Core
case "BatchConvert/Style":
language.BatchConvert.Style = reader.Value;
break;
case "BatchConvert/UseStyleFromSource":
language.BatchConvert.UseStyleFromSource = reader.Value;
break;
case "BatchConvert/ConvertOptions":
language.BatchConvert.ConvertOptions = reader.Value;
break;

View File

@ -174,6 +174,7 @@
public string ChooseOutputFolder { get; set; }
public string OverwriteExistingFiles { get; set; }
public string Style { get; set; }
public string UseStyleFromSource { get; set; }
public string ConvertOptions { get; set; }
public string RemoveFormatting { get; set; }
public string RemoveTextForHI { get; set; }

View File

@ -129,6 +129,7 @@ namespace Nikse.SubtitleEdit.Core
public string BatchConvertFormat { get; set; }
public string BatchConvertAssStyles { get; set; }
public string BatchConvertSsaStyles { get; set; }
public bool BatchConvertUseStyleFromSource { get; set; }
public string BatchConvertExportCustomTextTemplate { get; set; }
public string ModifySelectionText { get; set; }
public string ModifySelectionRule { get; set; }
@ -1901,6 +1902,9 @@ namespace Nikse.SubtitleEdit.Core
subNode = node.SelectSingleNode("BatchConvertSsaStyles");
if (subNode != null)
settings.Tools.BatchConvertSsaStyles = subNode.InnerText;
subNode = node.SelectSingleNode("BatchConvertUseStyleFromSource");
if (subNode != null)
settings.Tools.BatchConvertUseStyleFromSource = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("BatchConvertExportCustomTextTemplate");
if (subNode != null)
settings.Tools.BatchConvertExportCustomTextTemplate = subNode.InnerText;
@ -3351,6 +3355,7 @@ namespace Nikse.SubtitleEdit.Core
textWriter.WriteElementString("BatchConvertFormat", settings.Tools.BatchConvertFormat);
textWriter.WriteElementString("BatchConvertAssStyles", settings.Tools.BatchConvertAssStyles);
textWriter.WriteElementString("BatchConvertSsaStyles", settings.Tools.BatchConvertSsaStyles);
textWriter.WriteElementString("BatchConvertUseStyleFromSource", settings.Tools.BatchConvertUseStyleFromSource.ToString());
textWriter.WriteElementString("BatchConvertExportCustomTextTemplate", settings.Tools.BatchConvertExportCustomTextTemplate);
textWriter.WriteElementString("ModifySelectionRule", settings.Tools.ModifySelectionRule);
textWriter.WriteElementString("ModifySelectionText", settings.Tools.ModifySelectionText);

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Xml;
@ -48,22 +49,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
public override string Extension
{
get { return ".ass"; }
}
public override string Extension => ".ass";
public const string NameOfFormat = "Advanced Sub Station Alpha";
public override string Name
{
get { return NameOfFormat; }
}
public override string Name => NameOfFormat;
public override bool IsTimeBased
{
get { return true; }
}
public override bool IsTimeBased => true;
public override bool IsMine(List<string> lines, string fileName)
{
@ -153,6 +145,16 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
styles = GetStylesFromHeader(subtitle.Header);
}
}
else if (subtitle.Header != null && subtitle.Header.Contains("http://www.w3.org/2006/10/ttaf1"))
{
LoadStylesFromTimedTextTimedDraft2006Oct(subtitle, title, header, HeaderNoStyles, sb);
fromTtml = true;
isValidAssHeader = !string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.Contains("[V4+ Styles]");
if (isValidAssHeader)
{
styles = GetStylesFromHeader(subtitle.Header);
}
}
else
{
sb.AppendLine(string.Format(header, title));
@ -261,6 +263,7 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
}
catch
{
// ignored
}
}
@ -301,8 +304,9 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml");
XmlNode head = xml.DocumentElement.SelectSingleNode("ttml:head", nsmgr);
int stylexmlCount = 0;
int styleCount = 0;
var ttStyles = new StringBuilder();
var styleNames = new List<string>();
foreach (XmlNode node in head.SelectNodes("//ttml:style", nsmgr))
{
string name = null;
@ -312,7 +316,7 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
name = node.Attributes["id"].Value;
if (name != null)
{
stylexmlCount++;
styleCount++;
string fontFamily = "Arial";
if (node.Attributes["tts:fontFamily"] != null)
@ -344,6 +348,7 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
}
catch
{
// ignored
}
string fontSize = "20";
@ -363,11 +368,142 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
const string styleFormat = "Style: {0},{1},{2},{3},&H0300FFFF,&H00000000,&H02000000,{4},{5},0,0,100,100,0,0,1,2,2,2,10,10,10,1";
ttStyles.AppendLine(string.Format(styleFormat, name, fontFamily, fSize, GetSsaColorString(c), bold, italic));
styleNames.Add(name);
}
}
if (stylexmlCount > 0)
if (styleCount > 0)
{
if (!styleNames.Contains("Default") && !styleNames.Contains("default") && subtitle.Paragraphs.Any(pa => string.IsNullOrEmpty(pa.Extra)))
{
ttStyles = new StringBuilder(DefaultStyle + Environment.NewLine + ttStyles);
foreach (var paragraph in subtitle.Paragraphs)
{
if (string.IsNullOrEmpty(paragraph.Extra))
paragraph.Extra = "Default";
}
}
sb.AppendLine(string.Format(headerNoStyles, title, ttStyles));
subtitle.Header = sb.ToString();
}
else
{
sb.AppendLine(string.Format(header, title));
}
// Set correct style on paragraphs
foreach (Paragraph p in subtitle.Paragraphs)
{
if (p.Extra != null && p.Extra.Contains('/'))
{
p.Extra = p.Extra.Split('/')[0].Trim();
}
}
}
catch
{
sb.AppendLine(string.Format(header, title));
}
}
public static void LoadStylesFromTimedTextTimedDraft2006Oct(Subtitle subtitle, string title, string header, string headerNoStyles, StringBuilder sb)
{
foreach (Paragraph p in subtitle.Paragraphs)
{
p.Effect = null;
}
try
{
var lines = new List<string>();
foreach (string s in subtitle.Header.SplitToLines())
lines.Add(s);
var sb2 = new StringBuilder();
lines.ForEach(line => sb2.AppendLine(line));
var xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(sb2.ToString().Replace(" & ", " &amp; ").Replace("Q&A", "Q&amp;A").RemoveControlCharactersButWhiteSpace().Trim());
subtitle.Header = xml.OuterXml;
var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("ttaf1", xml.DocumentElement.NamespaceURI);
int styleCount = 0;
var ttStyles = new StringBuilder();
var styleNames = new List<string>();
foreach (XmlNode node in xml.DocumentElement.SelectNodes("//ttaf1:style", nsmgr))
{
string name = null;
if (node.Attributes["xml:id"] != null)
name = node.Attributes["xml:id"].Value;
else if (node.Attributes["id"] != null)
name = node.Attributes["id"].Value;
if (name != null)
{
styleCount++;
string fontFamily = "Arial";
if (node.Attributes["tts:fontFamily"] != null)
fontFamily = node.Attributes["tts:fontFamily"].Value;
string fontWeight = "normal";
if (node.Attributes["tts:fontWeight"] != null)
fontWeight = node.Attributes["tts:fontWeight"].Value;
string fontStyle = "normal";
if (node.Attributes["tts:fontStyle"] != null)
fontStyle = node.Attributes["tts:fontStyle"].Value;
string color = "#ffffff";
if (node.Attributes["tts:color"] != null)
color = node.Attributes["tts:color"].Value.Trim();
Color c = Color.White;
try
{
if (color.StartsWith("rgb(", StringComparison.Ordinal))
{
string[] arr = color.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]));
}
else
{
c = ColorTranslator.FromHtml(color);
}
}
catch
{
// ignored
}
string fontSize = "20";
if (node.Attributes["tts:fontSize"] != null)
fontSize = node.Attributes["tts:fontSize"].Value.Replace("px", string.Empty).Replace("em", string.Empty);
int fSize;
if (!int.TryParse(fontSize, out fSize))
fSize = 20;
string italic = "0";
if (fontStyle == "italic")
italic = "-1";
string bold = "0";
if (fontWeight == "bold")
bold = "-1";
const string styleFormat = "Style: {0},{1},{2},{3},&H0300FFFF,&H00000000,&H02000000,{4},{5},0,0,100,100,0,0,1,2,2,2,10,10,10,1";
ttStyles.AppendLine(string.Format(styleFormat, name, fontFamily, fSize, GetSsaColorString(c), bold, italic));
styleNames.Add(name);
}
}
if (styleCount > 0)
{
if (!styleNames.Contains("Default") && !styleNames.Contains("default") && subtitle.Paragraphs.Any(pa => string.IsNullOrEmpty(pa.Extra)))
{
ttStyles = new StringBuilder(DefaultStyle + Environment.NewLine + ttStyles);
foreach (var paragraph in subtitle.Paragraphs)
{
if (string.IsNullOrEmpty(paragraph.Extra))
paragraph.Extra = "Default";
}
}
sb.AppendLine(string.Format(headerNoStyles, title, ttStyles));
subtitle.Header = sb.ToString();
}
@ -1175,7 +1311,7 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
public static string GetSsaColorString(Color c)
{
return string.Format("&H{0:X2}{1:X2}{2:X2}{3:X2}", 255 - c.A, c.B, c.G, c.R); // ASS stores alpha in reverse (0=full itentity and 255=fully transparent)
return $"&H{255 - c.A:X2}{c.B:X2}{c.G:X2}{c.R:X2}"; // ASS stores alpha in reverse (0=full itentity and 255=fully transparent)
}
public static string CheckForErrors(string header)
@ -1634,13 +1770,6 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
return new SsaStyle { Name = styleName };
}
public override bool HasStyleSupport
{
get
{
return true;
}
}
public override bool HasStyleSupport => true;
}
}

View File

@ -8,20 +8,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
public class TimedText : SubtitleFormat
{
public override string Extension
{
get { return ".xml"; }
}
public override string Extension => ".xml";
public override string Name
{
get { return "Timed Text draft 2006-10"; }
}
public override string Name => "Timed Text draft 2006-10";
public override bool IsTimeBased
{
get { return true; }
}
public override bool IsTimeBased => true;
public override bool IsMine(List<string> lines, string fileName)
{
@ -60,8 +51,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
private static string ConvertToTimeString(TimeCode time)
{
if (Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormatSource == "hh:mm:ss.ms-two-digits")
return string.Format("{0:00}:{1:00}:{2:00}.{3:0}", time.Hours, time.Minutes, time.Seconds, (int)(Math.Round(time.Milliseconds / 10.0)));
return string.Format("{0:00}:{1:00}:{2:00}.{3:000}", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}.{(int)Math.Round(time.Milliseconds / 10.0):0}";
return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}.{time.Milliseconds:000}";
}
public override string ToText(Subtitle subtitle, string title)
@ -136,6 +127,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(sb.ToString().Replace(" & ", " &amp; ").Replace("Q&A", "Q&amp;A").RemoveControlCharactersButWhiteSpace().Trim());
subtitle.Header = xml.OuterXml;
var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("ttaf1", xml.DocumentElement.NamespaceURI);
@ -159,6 +151,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
try
{
var pText = new StringBuilder();
var styleName = string.Empty;
if (node.Attributes["style"] != null)
{
styleName = node.Attributes["style"].Value;
}
foreach (XmlNode innerNode in node.ChildNodes)
{
switch (innerNode.Name.Replace("tt:", string.Empty))
@ -168,12 +165,22 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
break;
case "span":
bool italic = false;
bool font = false;
if (innerNode.Attributes["style"] != null && styleDic.ContainsKey(innerNode.Attributes["style"].Value))
{
if (styleDic[innerNode.Attributes["style"].Value].Contains("italic"))
{
italic = true;
pText.Append("<i>");
}
}
if (innerNode.Attributes["tts:color"] != null)
{
var colorAsString = innerNode.Attributes["tts:color"].Value;
if (colorAsString != "white")
{
pText.Append("<font color=\"" + colorAsString + "\">");
font = true;
}
}
if (!italic && innerNode.Attributes != null)
@ -205,6 +212,19 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
if (italic)
pText.Append("</i>");
if (font)
{
if (pText.EndsWith(' '))
{
pText = new StringBuilder(pText.ToString().TrimEnd());
pText.Append("</font> ");
}
else
{
pText.Append("</font>");
}
}
break;
case "i":
pText.Append("<i>" + innerNode.InnerText + "</i>");
@ -251,6 +271,10 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
double.TryParse(start, NumberStyles.Float, CultureInfo.InvariantCulture, out dBegin) && double.TryParse(end, NumberStyles.Float, CultureInfo.InvariantCulture, out dEnd))
{
subtitle.Paragraphs.Add(new Paragraph(text, dBegin * TimeCode.BaseUnit, dEnd * TimeCode.BaseUnit));
if (!string.IsNullOrEmpty(styleName))
{
subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].Extra = styleName;
}
}
else
{
@ -263,10 +287,18 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
p.EndTime = new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), 0);
p.Text = text;
subtitle.Paragraphs.Add(p);
if (!string.IsNullOrEmpty(styleName))
{
p.Extra = styleName;
}
}
else
{
subtitle.Paragraphs.Add(new Paragraph(TimedText10.GetTimeCode(start, false), TimedText10.GetTimeCode(end, false), text));
if (!string.IsNullOrEmpty(styleName))
{
subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].Extra = styleName;
}
}
}
}
@ -286,6 +318,10 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
TimeCode startTime = TimedText10.GetTimeCode(start, false);
var endTime = new TimeCode(startTime.TotalMilliseconds + duration.TotalMilliseconds);
subtitle.Paragraphs.Add(new Paragraph(startTime, endTime, text));
if (!string.IsNullOrEmpty(styleName))
{
subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].Extra = styleName;
}
}
}
catch (Exception ex)
@ -328,13 +364,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
subtitle.Renumber();
}
public override List<string> AlternateExtensions
{
get
{
return new List<string> { ".tt" };
}
}
public override List<string> AlternateExtensions => new List<string> { ".tt" };
}
}

View File

@ -999,7 +999,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
fontFamily = styleNode.Attributes["tts:fontFamily"].Value;
}
if (styleNode.Attributes["tts:color"] != null && styleNode.Attributes["tts:color"].Value != "white")
if (styleNode.Attributes["tts:color"] != null)
{
color = styleNode.Attributes["tts:color"].Value;
}

View File

@ -29,6 +29,7 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
Nikse.SubtitleEdit.Core.TimeCode timeCode1 = new Nikse.SubtitleEdit.Core.TimeCode();
this.buttonConvert = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxConvertOptions = new System.Windows.Forms.GroupBox();
@ -91,6 +92,7 @@
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.labelStatus = new System.Windows.Forms.Label();
this.checkBoxUseStyleFromSource = new System.Windows.Forms.CheckBox();
this.groupBoxConvertOptions.SuspendLayout();
this.groupBoxSpeed.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).BeginInit();
@ -406,6 +408,14 @@
this.timeUpDownAdjust.Name = "timeUpDownAdjust";
this.timeUpDownAdjust.Size = new System.Drawing.Size(96, 24);
this.timeUpDownAdjust.TabIndex = 1;
timeCode1.Hours = 99;
timeCode1.Milliseconds = 999;
timeCode1.Minutes = 59;
timeCode1.Seconds = 59;
timeCode1.TimeSpan = System.TimeSpan.Parse("4.03:59:59.9990000");
timeCode1.TotalMilliseconds = 359999999D;
timeCode1.TotalSeconds = 359999.999D;
this.timeUpDownAdjust.TimeCode = timeCode1;
this.timeUpDownAdjust.UseVideoOffset = false;
//
// labelHourMinSecMilliSecond
@ -451,6 +461,7 @@
//
this.groupBoxOutput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxOutput.Controls.Add(this.checkBoxUseStyleFromSource);
this.groupBoxOutput.Controls.Add(this.checkBoxOverwriteOriginalFiles);
this.groupBoxOutput.Controls.Add(this.linkLabelOpenOutputFolder);
this.groupBoxOutput.Controls.Add(this.buttonStyles);
@ -526,7 +537,7 @@
// labelEncoding
//
this.labelEncoding.AutoSize = true;
this.labelEncoding.Location = new System.Drawing.Point(10, 178);
this.labelEncoding.Location = new System.Drawing.Point(10, 201);
this.labelEncoding.Name = "labelEncoding";
this.labelEncoding.Size = new System.Drawing.Size(52, 13);
this.labelEncoding.TabIndex = 9;
@ -536,7 +547,7 @@
//
this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxEncoding.FormattingEnabled = true;
this.comboBoxEncoding.Location = new System.Drawing.Point(80, 175);
this.comboBoxEncoding.Location = new System.Drawing.Point(80, 198);
this.comboBoxEncoding.Name = "comboBoxEncoding";
this.comboBoxEncoding.Size = new System.Drawing.Size(225, 21);
this.comboBoxEncoding.TabIndex = 10;
@ -764,6 +775,17 @@
this.labelStatus.TabIndex = 9;
this.labelStatus.Text = "labelStatus";
//
// checkBoxUseStyleFromSource
//
this.checkBoxUseStyleFromSource.AutoSize = true;
this.checkBoxUseStyleFromSource.Location = new System.Drawing.Point(80, 170);
this.checkBoxUseStyleFromSource.Name = "checkBoxUseStyleFromSource";
this.checkBoxUseStyleFromSource.Size = new System.Drawing.Size(127, 17);
this.checkBoxUseStyleFromSource.TabIndex = 9;
this.checkBoxUseStyleFromSource.Text = "Use style from source";
this.checkBoxUseStyleFromSource.UseVisualStyleBackColor = true;
this.checkBoxUseStyleFromSource.Visible = false;
//
// BatchConvert
//
this.AllowDrop = true;
@ -866,5 +888,6 @@
private System.Windows.Forms.RadioButton radioButtonToDropFrame;
private System.Windows.Forms.RadioButton radioButtonSpeedFromDropFrame;
private System.Windows.Forms.RadioButton radioButtonSpeedCustom;
private System.Windows.Forms.CheckBox checkBoxUseStyleFromSource;
}
}

View File

@ -88,6 +88,7 @@ namespace Nikse.SubtitleEdit.Forms
labelOutputFormat.Text = Configuration.Settings.Language.Main.Controls.SubtitleFormat;
labelEncoding.Text = Configuration.Settings.Language.Main.Controls.FileEncoding;
buttonStyles.Text = l.Style;
checkBoxUseStyleFromSource.Text = l.UseStyleFromSource;
groupBoxConvertOptions.Text = l.ConvertOptions;
checkBoxRemoveFormatting.Text = l.RemoveFormatting;
checkBoxFixCasing.Text = l.RedoCasing;
@ -205,6 +206,7 @@ namespace Nikse.SubtitleEdit.Forms
_assStyle = Configuration.Settings.Tools.BatchConvertAssStyles;
_ssaStyle = Configuration.Settings.Tools.BatchConvertSsaStyles;
checkBoxUseStyleFromSource.Checked = Configuration.Settings.Tools.BatchConvertUseStyleFromSource;
_customTextTemplate = Configuration.Settings.Tools.BatchConvertExportCustomTextTemplate;
}
@ -911,12 +913,12 @@ namespace Nikse.SubtitleEdit.Forms
}
if (comboBoxSubtitleFormats.Text == AdvancedSubStationAlpha.NameOfFormat && _assStyle != null)
{
if (!string.IsNullOrWhiteSpace(_assStyle))
if (!string.IsNullOrWhiteSpace(_assStyle) && !checkBoxUseStyleFromSource.Checked)
sub.Header = _assStyle;
}
else if (comboBoxSubtitleFormats.Text == SubStationAlpha.NameOfFormat && _ssaStyle != null)
{
if (!string.IsNullOrWhiteSpace(_ssaStyle))
if (!string.IsNullOrWhiteSpace(_ssaStyle) && !checkBoxUseStyleFromSource.Checked)
sub.Header = _ssaStyle;
}
@ -1196,11 +1198,14 @@ namespace Nikse.SubtitleEdit.Forms
private void ComboBoxSubtitleFormatsSelectedIndexChanged(object sender, EventArgs e)
{
checkBoxUseStyleFromSource.Visible = false;
if (comboBoxSubtitleFormats.Text == AdvancedSubStationAlpha.NameOfFormat || comboBoxSubtitleFormats.Text == SubStationAlpha.NameOfFormat)
{
buttonStyles.Text = Configuration.Settings.Language.BatchConvert.Style;
buttonStyles.Visible = true;
comboBoxEncoding.Enabled = true;
checkBoxUseStyleFromSource.Visible = true;
checkBoxUseStyleFromSource.Left = buttonStyles.Left + buttonStyles.Width - checkBoxUseStyleFromSource.Width;
}
else if (comboBoxSubtitleFormats.Text == Ebu.NameOfFormat)
{
@ -1442,6 +1447,7 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.Tools.BatchConvertFormat = comboBoxSubtitleFormats.SelectedItem.ToString();
Configuration.Settings.Tools.BatchConvertAssStyles = _assStyle;
Configuration.Settings.Tools.BatchConvertSsaStyles = _ssaStyle;
Configuration.Settings.Tools.BatchConvertUseStyleFromSource = checkBoxUseStyleFromSource.Checked;
Configuration.Settings.Tools.BatchConvertExportCustomTextTemplate = _customTextTemplate;
}