Make ttml 1.0 ext custimizable - thx Tony :)

This commit is contained in:
Nikolaj Olsson 2020-05-24 08:25:41 +02:00
parent 0a0301165f
commit 3d7f8b616e
4 changed files with 58 additions and 8 deletions

View File

@ -519,6 +519,7 @@ namespace Nikse.SubtitleEdit.Core
public string TimedText10TimeCodeFormat { get; set; }
public string TimedText10TimeCodeFormatSource { get; set; }
public bool TimedText10ShowStyleAndLanguage { get; set; }
public string TimedText10FileExtension { get; set; }
public int FcpFontSize { get; set; }
public string FcpFontName { get; set; }
@ -585,6 +586,7 @@ $HorzAlign = Center
TimedText10TimeCodeFormat = "Source";
TimedText10ShowStyleAndLanguage = true;
TimedText10FileExtension = ".xml";
FcpFontSize = 18;
FcpFontName = "Lucida Grande";
@ -4402,6 +4404,12 @@ $HorzAlign = Center
settings.SubtitleSettings.TimedText10ShowStyleAndLanguage = Convert.ToBoolean(subNode.InnerText);
}
subNode = node.SelectSingleNode("TimedText10FileExtension");
if (subNode != null)
{
settings.SubtitleSettings.TimedText10FileExtension = subNode.InnerText;
}
subNode = node.SelectSingleNode("FcpFontSize");
if (subNode != null)
{
@ -7297,6 +7305,7 @@ $HorzAlign = Center
textWriter.WriteElementString("SamiHtmlEncodeMode", settings.SubtitleSettings.SamiHtmlEncodeMode.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("TimedText10TimeCodeFormat", settings.SubtitleSettings.TimedText10TimeCodeFormat);
textWriter.WriteElementString("TimedText10ShowStyleAndLanguage", settings.SubtitleSettings.TimedText10ShowStyleAndLanguage.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("TimedText10FileExtension", settings.SubtitleSettings.TimedText10FileExtension);
textWriter.WriteElementString("FcpFontSize", settings.SubtitleSettings.FcpFontSize.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("FcpFontName", settings.SubtitleSettings.FcpFontName);
textWriter.WriteElementString("Cavena890StartOfMessage", settings.SubtitleSettings.Cavena890StartOfMessage);

View File

@ -13,7 +13,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
public class TimedText10 : SubtitleFormat
{
public override string Extension => ".xml";
public override string Extension => Configuration.Settings.SubtitleSettings.TimedText10FileExtension;
public const string NameOfFormat = "Timed Text 1.0";

View File

@ -51,13 +51,15 @@
this.labelCollision = new System.Windows.Forms.Label();
this.comboBoxDefaultStyle = new System.Windows.Forms.ComboBox();
this.labelWrapStyle = new System.Windows.Forms.Label();
this.comboBoxFileExtensions = new System.Windows.Forms.ComboBox();
this.labelFileExtension = new System.Windows.Forms.Label();
this.groupBoxOptions.SuspendLayout();
this.SuspendLayout();
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.Location = new System.Drawing.Point(335, 364);
this.buttonOK.Location = new System.Drawing.Point(335, 401);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 1;
@ -69,7 +71,7 @@
//
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.Location = new System.Drawing.Point(416, 364);
this.buttonCancel.Location = new System.Drawing.Point(416, 401);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 2;
@ -82,6 +84,8 @@
this.groupBoxOptions.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.groupBoxOptions.Controls.Add(this.comboBoxFileExtensions);
this.groupBoxOptions.Controls.Add(this.labelFileExtension);
this.groupBoxOptions.Controls.Add(this.comboBoxTimeCodeFormat);
this.groupBoxOptions.Controls.Add(this.labelTimeCode);
this.groupBoxOptions.Controls.Add(this.comboBoxFrameRateMultiplier);
@ -104,7 +108,7 @@
this.groupBoxOptions.Controls.Add(this.labelWrapStyle);
this.groupBoxOptions.Location = new System.Drawing.Point(12, 12);
this.groupBoxOptions.Name = "groupBoxOptions";
this.groupBoxOptions.Size = new System.Drawing.Size(479, 346);
this.groupBoxOptions.Size = new System.Drawing.Size(479, 383);
this.groupBoxOptions.TabIndex = 0;
this.groupBoxOptions.TabStop = false;
//
@ -304,11 +308,33 @@
this.labelWrapStyle.TabIndex = 1;
this.labelWrapStyle.Text = "Default style";
//
// comboBoxFileExtensions
//
this.comboBoxFileExtensions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFileExtensions.FormattingEnabled = true;
this.comboBoxFileExtensions.Items.AddRange(new object[] {
".xml",
".ttml",
".dfxp"});
this.comboBoxFileExtensions.Location = new System.Drawing.Point(191, 346);
this.comboBoxFileExtensions.Name = "comboBoxFileExtensions";
this.comboBoxFileExtensions.Size = new System.Drawing.Size(263, 21);
this.comboBoxFileExtensions.TabIndex = 21;
//
// labelFileExtension
//
this.labelFileExtension.AutoSize = true;
this.labelFileExtension.Location = new System.Drawing.Point(6, 349);
this.labelFileExtension.Name = "labelFileExtension";
this.labelFileExtension.Size = new System.Drawing.Size(71, 13);
this.labelFileExtension.TabIndex = 22;
this.labelFileExtension.Text = "File extension";
//
// TimedTextProperties
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(503, 397);
this.ClientSize = new System.Drawing.Size(503, 434);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.groupBoxOptions);
@ -352,5 +378,7 @@
private System.Windows.Forms.ComboBox comboBoxFrameRateMultiplier;
private System.Windows.Forms.ComboBox comboBoxTimeCodeFormat;
private System.Windows.Forms.Label labelTimeCode;
private System.Windows.Forms.ComboBox comboBoxFileExtensions;
private System.Windows.Forms.Label labelFileExtension;
}
}

View File

@ -97,7 +97,7 @@ namespace Nikse.SubtitleEdit.Forms
{
comboBoxDefaultStyle.Items.Add(style);
node = _xml.DocumentElement.SelectSingleNode("ttml:body", _nsmgr);
if (node != null && node.Attributes["style"] != null && style == node.Attributes["style"].Value)
if (node?.Attributes?["style"] != null && style == node.Attributes["style"].Value)
{
comboBoxDefaultStyle.SelectedIndex = comboBoxDefaultStyle.Items.Count - 1;
}
@ -106,7 +106,7 @@ namespace Nikse.SubtitleEdit.Forms
{
comboBoxDefaultRegion.Items.Add(region);
node = _xml.DocumentElement.SelectSingleNode("ttml:body", _nsmgr);
if (node != null && node.Attributes["region"] != null && region == node.Attributes["region"].Value)
if (node?.Attributes?["region"] != null && region == node.Attributes["region"].Value)
{
comboBoxDefaultRegion.SelectedIndex = comboBoxDefaultRegion.Items.Count - 1;
}
@ -120,7 +120,19 @@ namespace Nikse.SubtitleEdit.Forms
if (item.ToString().ToLowerInvariant() == timeCodeFormat)
{
comboBoxTimeCodeFormat.SelectedIndex = index;
return;
break;
}
}
var ext = Configuration.Settings.SubtitleSettings.TimedText10FileExtension;
comboBoxFileExtensions.SelectedIndex = 0;
for (var index = 0; index < comboBoxFileExtensions.Items.Count; index++)
{
var item = comboBoxFileExtensions.Items[index];
if (item.ToString() == ext)
{
comboBoxFileExtensions.SelectedIndex = index;
break;
}
}
}
@ -298,6 +310,7 @@ namespace Nikse.SubtitleEdit.Forms
_subtitle.Header = _xml.OuterXml;
Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormat = comboBoxTimeCodeFormat.SelectedItem.ToString();
Configuration.Settings.SubtitleSettings.TimedText10FileExtension= comboBoxFileExtensions.SelectedItem.ToString();
DialogResult = DialogResult.OK;
}