Work on TTML imsc 1.1 properties

This commit is contained in:
Nikolaj Olsson 2024-03-15 13:51:17 +01:00
parent 18b0c67ebd
commit b7b23d3d86
9 changed files with 1151 additions and 105 deletions

View File

@ -832,6 +832,8 @@ namespace Nikse.SubtitleEdit.Core.Common
public string TimedTextItunesBottomExtent { get; set; }
public string TimedTextItunesTimeCodeFormat { get; set; }
public string TimedTextItunesStyleAttribute { get; set; }
public string TimedTextImsc11TimeCodeFormat { get; set; }
public int FcpFontSize { get; set; }
public string FcpFontName { get; set; }
@ -918,6 +920,7 @@ $HorzAlign = Center
TimedTextItunesBottomExtent = "100% 15%";
TimedTextItunesTimeCodeFormat = "Frames";
TimedTextItunesStyleAttribute = "tts:fontStyle";
TimedTextImsc11TimeCodeFormat = "hh:mm:ss.ms";
FcpFontSize = 18;
FcpFontName = "Lucida Grande";

View File

@ -1,120 +1,120 @@
using Nikse.SubtitleEdit.Core.Common;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
//using Nikse.SubtitleEdit.Core.Common;
//using System;
//using System.Collections.Generic;
//using System.Text;
//using System.Xml;
namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
public class Smil30 : SubtitleFormat
{
public override string Extension => ".xml";
//namespace Nikse.SubtitleEdit.Core.SubtitleFormats
//{
// public class Smil30 : SubtitleFormat
// {
// public override string Extension => ".xml";
public override string Name => "SMIL 3.0";
// public override string Name => "SMIL 3.0";
private static string ToTimeCode(TimeCode tc)
{
return tc.ToString(false).Replace(',', '.');
}
// private static string ToTimeCode(TimeCode tc)
// {
// return tc.ToString(false).Replace(',', '.');
// }
private static TimeCode DecodeTimeCode(string s)
{
var parts = s.Split(new[] { ';', ':', '.', ',' }, StringSplitOptions.RemoveEmptyEntries);
return DecodeTimeCodeFramesFourParts(parts);
}
// private static TimeCode DecodeTimeCode(string s)
// {
// var parts = s.Split(new[] { ';', ':', '.', ',' }, StringSplitOptions.RemoveEmptyEntries);
// return DecodeTimeCodeFramesFourParts(parts);
// }
public override string ToText(Subtitle subtitle, string title)
{
var xml = new XmlDocument();
xml.LoadXml("<smil xmlns=\"http://www.w3.org/ns/SMIL\" xmlns:epub=\"http://www.idpf.org/2007/ops\" version=\"3.0\"><body></body></smil>");
// public override string ToText(Subtitle subtitle, string title)
// {
// var xml = new XmlDocument();
// xml.LoadXml("<smil xmlns=\"http://www.w3.org/ns/SMIL\" xmlns:epub=\"http://www.idpf.org/2007/ops\" version=\"3.0\"><body></body></smil>");
const string ns = "http://www.w3.org/ns/SMIL";
var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("smil", ns);
nsmgr.AddNamespace("epub", "http://www.idpf.org/2007/ops");
// const string ns = "http://www.w3.org/ns/SMIL";
// var nsmgr = new XmlNamespaceManager(xml.NameTable);
// nsmgr.AddNamespace("smil", ns);
// nsmgr.AddNamespace("epub", "http://www.idpf.org/2007/ops");
XmlNode bodyNode = xml.SelectSingleNode("//smil:body", nsmgr);
var count = 1;
foreach (var p in subtitle.Paragraphs)
{
XmlNode paragraph = xml.CreateElement("par", ns);
XmlNode text = xml.CreateElement("text", ns);
XmlNode audio = xml.CreateElement("audio", ns);
text.InnerText = p.Text;
// XmlNode bodyNode = xml.SelectSingleNode("//smil:body", nsmgr);
// var count = 1;
// foreach (var p in subtitle.Paragraphs)
// {
// XmlNode paragraph = xml.CreateElement("par", ns);
// XmlNode text = xml.CreateElement("text", ns);
// XmlNode audio = xml.CreateElement("audio", ns);
// text.InnerText = p.Text;
XmlAttribute start = xml.CreateAttribute("clipBegin");
start.InnerText = ToTimeCode(p.StartTime);
audio.Attributes.Append(start);
// XmlAttribute start = xml.CreateAttribute("clipBegin");
// start.InnerText = ToTimeCode(p.StartTime);
// audio.Attributes.Append(start);
XmlAttribute end = xml.CreateAttribute("clipEnd");
end.InnerText = ToTimeCode(p.EndTime);
audio.Attributes.Append(end);
// XmlAttribute end = xml.CreateAttribute("clipEnd");
// end.InnerText = ToTimeCode(p.EndTime);
// audio.Attributes.Append(end);
XmlAttribute textSource = xml.CreateAttribute("src");
textSource.InnerText = $"text.xhtml#para{count}";
text.Attributes.Append(textSource);
// XmlAttribute textSource = xml.CreateAttribute("src");
// textSource.InnerText = $"text.xhtml#para{count}";
// text.Attributes.Append(textSource);
XmlAttribute audioSource = xml.CreateAttribute("src");
audioSource.InnerText = "audio.mp3";
audio.Attributes.Append(audioSource);
// XmlAttribute audioSource = xml.CreateAttribute("src");
// audioSource.InnerText = "audio.mp3";
// audio.Attributes.Append(audioSource);
bodyNode.AppendChild(paragraph);
paragraph.AppendChild(text);
paragraph.AppendChild(audio);
// bodyNode.AppendChild(paragraph);
// paragraph.AppendChild(text);
// paragraph.AppendChild(audio);
count++;
}
// count++;
// }
return ToUtf8XmlString(xml);
}
// return ToUtf8XmlString(xml);
// }
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var allText = sb.ToString();
if (!allText.Contains("<smil") || !allText.Contains("</smil>"))
{
return;
}
// public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
// {
// _errorCount = 0;
// var sb = new StringBuilder();
// lines.ForEach(line => sb.AppendLine(line));
// var allText = sb.ToString();
// if (!allText.Contains("<smil") || !allText.Contains("</smil>"))
// {
// return;
// }
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(allText);
}
catch
{
_errorCount = 1;
return;
}
// var xml = new XmlDocument { XmlResolver = null };
// try
// {
// xml.LoadXml(allText);
// }
// catch
// {
// _errorCount = 1;
// return;
// }
const string ns = "http://www.w3.org/ns/SMIL";
var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("smil", ns);
nsmgr.AddNamespace("epub", "http://www.idpf.org/2007/ops");
// const string ns = "http://www.w3.org/ns/SMIL";
// var nsmgr = new XmlNamespaceManager(xml.NameTable);
// nsmgr.AddNamespace("smil", ns);
// nsmgr.AddNamespace("epub", "http://www.idpf.org/2007/ops");
foreach (XmlNode node in xml.DocumentElement.SelectNodes("//smil:par", nsmgr))
{
try
{
var textNode = node.SelectSingleNode("smil:text", nsmgr);
var audioNode = node.SelectSingleNode("smil:audio", nsmgr);
// foreach (XmlNode node in xml.DocumentElement.SelectNodes("//smil:par", nsmgr))
// {
// try
// {
// var textNode = node.SelectSingleNode("smil:text", nsmgr);
// var audioNode = node.SelectSingleNode("smil:audio", nsmgr);
var text = textNode.InnerText;
var start = audioNode.Attributes["clipBegin"].InnerText;
var end = audioNode.Attributes["clipEnd"].InnerText;
subtitle.Paragraphs.Add(new Paragraph(DecodeTimeCode(start), DecodeTimeCode(end), text));
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
_errorCount++;
}
}
// var text = textNode.InnerText;
// var start = audioNode.Attributes["clipBegin"].InnerText;
// var end = audioNode.Attributes["clipEnd"].InnerText;
// subtitle.Paragraphs.Add(new Paragraph(DecodeTimeCode(start), DecodeTimeCode(end), text));
// }
// catch (Exception ex)
// {
// System.Diagnostics.Debug.WriteLine(ex.Message);
// _errorCount++;
// }
// }
subtitle.Renumber();
}
}
}
// subtitle.Renumber();
// }
// }
//}

View File

@ -192,7 +192,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
new ScenaristClosedCaptions(),
new ScenaristClosedCaptionsDropFrame(),
new SmartTitler(),
new Smil30(),
// new Smil30(),
new SmilTimesheetData(),
new SmpteTt2052(),
new SoftNiSub(),

View File

@ -84,15 +84,21 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
private static XmlNode MakeParagraph(XmlDocument xml, Paragraph p)
{
var timeCodeFormat = Configuration.Settings.SubtitleSettings.TimedTextImsc11TimeCodeFormat;
if (string.IsNullOrEmpty(timeCodeFormat))
{
timeCodeFormat = "hh:mm:ss.ms";
}
XmlNode paragraph = xml.CreateElement("p", "http://www.w3.org/ns/ttml");
string text = p.Text.RemoveControlCharactersButWhiteSpace();
var text = p.Text.RemoveControlCharactersButWhiteSpace();
XmlAttribute start = xml.CreateAttribute("begin");
start.InnerText = TimedText10.ConvertToTimeString(p.StartTime);
start.InnerText = TimedText10.ConvertToTimeString(p.StartTime, timeCodeFormat);
paragraph.Attributes.Append(start);
XmlAttribute dur = xml.CreateAttribute("dur");
dur.InnerText = TimedText10.ConvertToTimeString(p.Duration);
dur.InnerText = TimedText10.ConvertToTimeString(p.Duration, timeCodeFormat);
paragraph.Attributes.Append(dur);
XmlAttribute region = xml.CreateAttribute("region");

View File

@ -32435,7 +32435,7 @@ namespace Nikse.SubtitleEdit.Forms
return;
}
if (ft == typeof(TimedText10) || ft == typeof(TimedTextImsc11))
if (ft == typeof(TimedText10))
{
using (var properties = new TimedTextProperties(_subtitle))
{
@ -32445,6 +32445,16 @@ namespace Nikse.SubtitleEdit.Forms
return;
}
if (ft == typeof(TimedTextImsc11))
{
using (var properties = new TimedTextPropertiesIms11(_subtitle))
{
properties.ShowDialog(this);
}
return;
}
if (ft == typeof(ItunesTimedText))
{
using (var properties = new TimedTextPropertiesItunes(_subtitle))

View File

@ -0,0 +1,556 @@
namespace Nikse.SubtitleEdit.Forms
{
partial class TimedTextPropertiesIms11
{
/// <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.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxOptions = new System.Windows.Forms.GroupBox();
this.comboBoxFileExtensions = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.labelFileExtension = new System.Windows.Forms.Label();
this.comboBoxTimeCodeFormat = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.labelTimeCode = new System.Windows.Forms.Label();
this.comboBoxFrameRateMultiplier = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.textBoxDescription = new Nikse.SubtitleEdit.Controls.SETextBox();
this.label7 = new System.Windows.Forms.Label();
this.textBoxTitle = new Nikse.SubtitleEdit.Controls.SETextBox();
this.label6 = new System.Windows.Forms.Label();
this.comboBoxDefaultRegion = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.labelDefaultRegion = new System.Windows.Forms.Label();
this.comboBoxDropMode = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.comboBoxFrameRate = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.label2 = new System.Windows.Forms.Label();
this.comboBoxTimeBase = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.label1 = new System.Windows.Forms.Label();
this.comboBoxLanguage = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.labelCollision = new System.Windows.Forms.Label();
this.comboBoxDefaultStyle = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.labelWrapStyle = 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, 401);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 98;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// buttonCancel
//
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, 401);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 99;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// groupBoxOptions
//
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);
this.groupBoxOptions.Controls.Add(this.textBoxDescription);
this.groupBoxOptions.Controls.Add(this.label7);
this.groupBoxOptions.Controls.Add(this.textBoxTitle);
this.groupBoxOptions.Controls.Add(this.label6);
this.groupBoxOptions.Controls.Add(this.comboBoxDefaultRegion);
this.groupBoxOptions.Controls.Add(this.labelDefaultRegion);
this.groupBoxOptions.Controls.Add(this.comboBoxDropMode);
this.groupBoxOptions.Controls.Add(this.label4);
this.groupBoxOptions.Controls.Add(this.label3);
this.groupBoxOptions.Controls.Add(this.comboBoxFrameRate);
this.groupBoxOptions.Controls.Add(this.label2);
this.groupBoxOptions.Controls.Add(this.comboBoxTimeBase);
this.groupBoxOptions.Controls.Add(this.label1);
this.groupBoxOptions.Controls.Add(this.comboBoxLanguage);
this.groupBoxOptions.Controls.Add(this.labelCollision);
this.groupBoxOptions.Controls.Add(this.comboBoxDefaultStyle);
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, 383);
this.groupBoxOptions.TabIndex = 0;
this.groupBoxOptions.TabStop = false;
//
// comboBoxFileExtensions
//
this.comboBoxFileExtensions.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxFileExtensions.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxFileExtensions.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxFileExtensions.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxFileExtensions.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxFileExtensions.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxFileExtensions.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxFileExtensions.DropDownHeight = 400;
this.comboBoxFileExtensions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFileExtensions.DropDownWidth = 263;
this.comboBoxFileExtensions.FormattingEnabled = true;
this.comboBoxFileExtensions.Items.AddRange(new object[] {
".xml",
".ttml",
".dfxp"});
this.comboBoxFileExtensions.Location = new System.Drawing.Point(191, 346);
this.comboBoxFileExtensions.MaxLength = 32767;
this.comboBoxFileExtensions.Name = "comboBoxFileExtensions";
this.comboBoxFileExtensions.SelectedIndex = -1;
this.comboBoxFileExtensions.SelectedItem = null;
this.comboBoxFileExtensions.SelectedText = "";
this.comboBoxFileExtensions.Size = new System.Drawing.Size(263, 23);
this.comboBoxFileExtensions.TabIndex = 21;
this.comboBoxFileExtensions.UsePopupWindow = false;
//
// 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";
//
// comboBoxTimeCodeFormat
//
this.comboBoxTimeCodeFormat.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxTimeCodeFormat.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxTimeCodeFormat.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxTimeCodeFormat.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxTimeCodeFormat.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxTimeCodeFormat.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxTimeCodeFormat.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxTimeCodeFormat.DropDownHeight = 400;
this.comboBoxTimeCodeFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxTimeCodeFormat.DropDownWidth = 263;
this.comboBoxTimeCodeFormat.FormattingEnabled = true;
this.comboBoxTimeCodeFormat.Items.AddRange(new object[] {
"Source",
"Seconds",
"Milliseconds",
"Ticks",
"hh:mm:ss:ff",
"hh:mm:ss.ms",
"hh:mm:ss.ms-two-digits",
"hh:mm:ss,ms",
"Frames"});
this.comboBoxTimeCodeFormat.Location = new System.Drawing.Point(191, 309);
this.comboBoxTimeCodeFormat.MaxLength = 32767;
this.comboBoxTimeCodeFormat.Name = "comboBoxTimeCodeFormat";
this.comboBoxTimeCodeFormat.SelectedIndex = -1;
this.comboBoxTimeCodeFormat.SelectedItem = null;
this.comboBoxTimeCodeFormat.SelectedText = "";
this.comboBoxTimeCodeFormat.Size = new System.Drawing.Size(263, 23);
this.comboBoxTimeCodeFormat.TabIndex = 9;
this.comboBoxTimeCodeFormat.UsePopupWindow = false;
//
// labelTimeCode
//
this.labelTimeCode.AutoSize = true;
this.labelTimeCode.Location = new System.Drawing.Point(6, 312);
this.labelTimeCode.Name = "labelTimeCode";
this.labelTimeCode.Size = new System.Drawing.Size(89, 13);
this.labelTimeCode.TabIndex = 20;
this.labelTimeCode.Text = "Time code format";
//
// comboBoxFrameRateMultiplier
//
this.comboBoxFrameRateMultiplier.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxFrameRateMultiplier.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxFrameRateMultiplier.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxFrameRateMultiplier.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxFrameRateMultiplier.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxFrameRateMultiplier.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxFrameRateMultiplier.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxFrameRateMultiplier.DropDownHeight = 400;
this.comboBoxFrameRateMultiplier.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;
this.comboBoxFrameRateMultiplier.DropDownWidth = 263;
this.comboBoxFrameRateMultiplier.FormattingEnabled = true;
this.comboBoxFrameRateMultiplier.Items.AddRange(new object[] {
"999 1000",
"1 1",
"1000 1001"});
this.comboBoxFrameRateMultiplier.Location = new System.Drawing.Point(191, 176);
this.comboBoxFrameRateMultiplier.MaxLength = 32767;
this.comboBoxFrameRateMultiplier.Name = "comboBoxFrameRateMultiplier";
this.comboBoxFrameRateMultiplier.SelectedIndex = -1;
this.comboBoxFrameRateMultiplier.SelectedItem = null;
this.comboBoxFrameRateMultiplier.SelectedText = "";
this.comboBoxFrameRateMultiplier.Size = new System.Drawing.Size(263, 23);
this.comboBoxFrameRateMultiplier.TabIndex = 5;
this.comboBoxFrameRateMultiplier.TabStop = false;
this.comboBoxFrameRateMultiplier.UsePopupWindow = false;
//
// textBoxDescription
//
this.textBoxDescription.BackColor = System.Drawing.Color.DarkGray;
this.textBoxDescription.CurrentLanguage = "";
this.textBoxDescription.CurrentLineIndex = 0;
this.textBoxDescription.HideSelection = true;
this.textBoxDescription.IsDictionaryDownloaded = true;
this.textBoxDescription.IsSpellCheckerInitialized = false;
this.textBoxDescription.IsSpellCheckRequested = false;
this.textBoxDescription.IsWrongWord = false;
this.textBoxDescription.LanguageChanged = false;
this.textBoxDescription.Location = new System.Drawing.Point(191, 56);
this.textBoxDescription.MaxLength = 32767;
this.textBoxDescription.Multiline = true;
this.textBoxDescription.Name = "textBoxDescription";
this.textBoxDescription.Padding = new System.Windows.Forms.Padding(1);
this.textBoxDescription.ReadOnly = false;
this.textBoxDescription.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
this.textBoxDescription.SelectedText = "";
this.textBoxDescription.SelectionLength = 0;
this.textBoxDescription.SelectionStart = 0;
this.textBoxDescription.Size = new System.Drawing.Size(263, 20);
this.textBoxDescription.TabIndex = 1;
this.textBoxDescription.TextBoxFont = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBoxDescription.UseSystemPasswordChar = false;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(6, 58);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(60, 13);
this.label7.TabIndex = 17;
this.label7.Text = "Description";
//
// textBoxTitle
//
this.textBoxTitle.BackColor = System.Drawing.Color.DarkGray;
this.textBoxTitle.CurrentLanguage = "";
this.textBoxTitle.CurrentLineIndex = 0;
this.textBoxTitle.HideSelection = true;
this.textBoxTitle.IsDictionaryDownloaded = true;
this.textBoxTitle.IsSpellCheckerInitialized = false;
this.textBoxTitle.IsSpellCheckRequested = false;
this.textBoxTitle.IsWrongWord = false;
this.textBoxTitle.LanguageChanged = false;
this.textBoxTitle.Location = new System.Drawing.Point(191, 30);
this.textBoxTitle.MaxLength = 32767;
this.textBoxTitle.Multiline = true;
this.textBoxTitle.Name = "textBoxTitle";
this.textBoxTitle.Padding = new System.Windows.Forms.Padding(1);
this.textBoxTitle.ReadOnly = false;
this.textBoxTitle.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
this.textBoxTitle.SelectedText = "";
this.textBoxTitle.SelectionLength = 0;
this.textBoxTitle.SelectionStart = 0;
this.textBoxTitle.Size = new System.Drawing.Size(263, 20);
this.textBoxTitle.TabIndex = 0;
this.textBoxTitle.TextBoxFont = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBoxTitle.UseSystemPasswordChar = false;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(6, 32);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(27, 13);
this.label6.TabIndex = 15;
this.label6.Text = "Title";
//
// comboBoxDefaultRegion
//
this.comboBoxDefaultRegion.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxDefaultRegion.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxDefaultRegion.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxDefaultRegion.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxDefaultRegion.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxDefaultRegion.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxDefaultRegion.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxDefaultRegion.DropDownHeight = 400;
this.comboBoxDefaultRegion.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxDefaultRegion.DropDownWidth = 263;
this.comboBoxDefaultRegion.FormattingEnabled = true;
this.comboBoxDefaultRegion.Location = new System.Drawing.Point(191, 270);
this.comboBoxDefaultRegion.MaxLength = 32767;
this.comboBoxDefaultRegion.Name = "comboBoxDefaultRegion";
this.comboBoxDefaultRegion.SelectedIndex = -1;
this.comboBoxDefaultRegion.SelectedItem = null;
this.comboBoxDefaultRegion.SelectedText = "";
this.comboBoxDefaultRegion.Size = new System.Drawing.Size(263, 23);
this.comboBoxDefaultRegion.TabIndex = 8;
this.comboBoxDefaultRegion.UsePopupWindow = false;
//
// labelDefaultRegion
//
this.labelDefaultRegion.AutoSize = true;
this.labelDefaultRegion.Location = new System.Drawing.Point(6, 273);
this.labelDefaultRegion.Name = "labelDefaultRegion";
this.labelDefaultRegion.Size = new System.Drawing.Size(73, 13);
this.labelDefaultRegion.TabIndex = 12;
this.labelDefaultRegion.Text = "Default region";
//
// comboBoxDropMode
//
this.comboBoxDropMode.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxDropMode.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxDropMode.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxDropMode.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxDropMode.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxDropMode.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxDropMode.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxDropMode.DropDownHeight = 400;
this.comboBoxDropMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxDropMode.DropDownWidth = 263;
this.comboBoxDropMode.FormattingEnabled = true;
this.comboBoxDropMode.Items.AddRange(new object[] {
"[N/A]",
"dropNTSC",
"dropPAL",
"nonDrop"});
this.comboBoxDropMode.Location = new System.Drawing.Point(191, 203);
this.comboBoxDropMode.MaxLength = 32767;
this.comboBoxDropMode.Name = "comboBoxDropMode";
this.comboBoxDropMode.SelectedIndex = -1;
this.comboBoxDropMode.SelectedItem = null;
this.comboBoxDropMode.SelectedText = "";
this.comboBoxDropMode.Size = new System.Drawing.Size(263, 23);
this.comboBoxDropMode.TabIndex = 6;
this.comboBoxDropMode.UsePopupWindow = false;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(6, 206);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(59, 13);
this.label4.TabIndex = 10;
this.label4.Text = "Drop mode";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 179);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(100, 13);
this.label3.TabIndex = 8;
this.label3.Text = "Frame rate multiplier";
//
// comboBoxFrameRate
//
this.comboBoxFrameRate.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxFrameRate.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxFrameRate.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxFrameRate.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxFrameRate.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxFrameRate.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxFrameRate.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxFrameRate.DropDownHeight = 400;
this.comboBoxFrameRate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;
this.comboBoxFrameRate.DropDownWidth = 263;
this.comboBoxFrameRate.FormattingEnabled = true;
this.comboBoxFrameRate.Location = new System.Drawing.Point(191, 149);
this.comboBoxFrameRate.MaxLength = 32767;
this.comboBoxFrameRate.Name = "comboBoxFrameRate";
this.comboBoxFrameRate.SelectedIndex = -1;
this.comboBoxFrameRate.SelectedItem = null;
this.comboBoxFrameRate.SelectedText = "";
this.comboBoxFrameRate.Size = new System.Drawing.Size(263, 23);
this.comboBoxFrameRate.TabIndex = 4;
this.comboBoxFrameRate.TabStop = false;
this.comboBoxFrameRate.UsePopupWindow = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 152);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(57, 13);
this.label2.TabIndex = 6;
this.label2.Text = "Frame rate";
//
// comboBoxTimeBase
//
this.comboBoxTimeBase.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxTimeBase.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxTimeBase.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxTimeBase.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxTimeBase.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxTimeBase.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxTimeBase.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxTimeBase.DropDownHeight = 400;
this.comboBoxTimeBase.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxTimeBase.DropDownWidth = 263;
this.comboBoxTimeBase.FormattingEnabled = true;
this.comboBoxTimeBase.Items.AddRange(new object[] {
"[N/A]",
"media",
"smpte",
"clock"});
this.comboBoxTimeBase.Location = new System.Drawing.Point(191, 122);
this.comboBoxTimeBase.MaxLength = 32767;
this.comboBoxTimeBase.Name = "comboBoxTimeBase";
this.comboBoxTimeBase.SelectedIndex = -1;
this.comboBoxTimeBase.SelectedItem = null;
this.comboBoxTimeBase.SelectedText = "";
this.comboBoxTimeBase.Size = new System.Drawing.Size(263, 23);
this.comboBoxTimeBase.TabIndex = 3;
this.comboBoxTimeBase.UsePopupWindow = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 125);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 13);
this.label1.TabIndex = 4;
this.label1.Text = "Time base";
//
// comboBoxLanguage
//
this.comboBoxLanguage.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxLanguage.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxLanguage.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxLanguage.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxLanguage.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxLanguage.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxLanguage.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxLanguage.DropDownHeight = 400;
this.comboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;
this.comboBoxLanguage.DropDownWidth = 263;
this.comboBoxLanguage.FormattingEnabled = true;
this.comboBoxLanguage.Location = new System.Drawing.Point(191, 95);
this.comboBoxLanguage.MaxLength = 32767;
this.comboBoxLanguage.Name = "comboBoxLanguage";
this.comboBoxLanguage.SelectedIndex = -1;
this.comboBoxLanguage.SelectedItem = null;
this.comboBoxLanguage.SelectedText = "";
this.comboBoxLanguage.Size = new System.Drawing.Size(263, 23);
this.comboBoxLanguage.TabIndex = 2;
this.comboBoxLanguage.TabStop = false;
this.comboBoxLanguage.UsePopupWindow = false;
//
// labelCollision
//
this.labelCollision.AutoSize = true;
this.labelCollision.Location = new System.Drawing.Point(6, 98);
this.labelCollision.Name = "labelCollision";
this.labelCollision.Size = new System.Drawing.Size(55, 13);
this.labelCollision.TabIndex = 3;
this.labelCollision.Text = "Language";
//
// comboBoxDefaultStyle
//
this.comboBoxDefaultStyle.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxDefaultStyle.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxDefaultStyle.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxDefaultStyle.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxDefaultStyle.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxDefaultStyle.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxDefaultStyle.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxDefaultStyle.DropDownHeight = 400;
this.comboBoxDefaultStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxDefaultStyle.DropDownWidth = 263;
this.comboBoxDefaultStyle.FormattingEnabled = true;
this.comboBoxDefaultStyle.Location = new System.Drawing.Point(191, 243);
this.comboBoxDefaultStyle.MaxLength = 32767;
this.comboBoxDefaultStyle.Name = "comboBoxDefaultStyle";
this.comboBoxDefaultStyle.SelectedIndex = -1;
this.comboBoxDefaultStyle.SelectedItem = null;
this.comboBoxDefaultStyle.SelectedText = "";
this.comboBoxDefaultStyle.Size = new System.Drawing.Size(263, 23);
this.comboBoxDefaultStyle.TabIndex = 7;
this.comboBoxDefaultStyle.UsePopupWindow = false;
//
// labelWrapStyle
//
this.labelWrapStyle.AutoSize = true;
this.labelWrapStyle.Location = new System.Drawing.Point(6, 246);
this.labelWrapStyle.Name = "labelWrapStyle";
this.labelWrapStyle.Size = new System.Drawing.Size(65, 13);
this.labelWrapStyle.TabIndex = 1;
this.labelWrapStyle.Text = "Default style";
//
// TimedTextProperties
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(503, 434);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.groupBoxOptions);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "TimedTextProperties";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Timed Text properties";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TimedTextProperties_KeyDown);
this.groupBoxOptions.ResumeLayout(false);
this.groupBoxOptions.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.GroupBox groupBoxOptions;
private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxDropMode;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxFrameRate;
private System.Windows.Forms.Label label2;
private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxTimeBase;
private System.Windows.Forms.Label label1;
private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxLanguage;
private System.Windows.Forms.Label labelCollision;
private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxDefaultStyle;
private System.Windows.Forms.Label labelWrapStyle;
private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxDefaultRegion;
private System.Windows.Forms.Label labelDefaultRegion;
private Nikse.SubtitleEdit.Controls.SETextBox textBoxDescription;
private System.Windows.Forms.Label label7;
private Nikse.SubtitleEdit.Controls.SETextBox textBoxTitle;
private System.Windows.Forms.Label label6;
private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxFrameRateMultiplier;
private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxTimeCodeFormat;
private System.Windows.Forms.Label labelTimeCode;
private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxFileExtensions;
private System.Windows.Forms.Label labelFileExtension;
}
}

View File

@ -0,0 +1,342 @@
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Logic;
using System;
using System.Globalization;
using System.Windows.Forms;
using System.Xml;
namespace Nikse.SubtitleEdit.Forms
{
public partial class TimedTextPropertiesIms11 : PositionAndSizeForm
{
private readonly Subtitle _subtitle;
private readonly XmlDocument _xml;
private readonly XmlNamespaceManager _namespaceManager;
public TimedTextPropertiesIms11(Subtitle subtitle)
{
UiUtil.PreInitialize(this);
InitializeComponent();
UiUtil.FixFonts(this);
Application.DoEvents();
_subtitle = subtitle;
var notAvailable = "[" + LanguageSettings.Current.General.NotAvailable + "]";
comboBoxDropMode.Items[0] = notAvailable;
comboBoxTimeBase.Items[0] = notAvailable;
comboBoxDefaultStyle.Items.Add(notAvailable);
comboBoxDefaultRegion.Items.Add(notAvailable);
_xml = new XmlDocument();
try
{
_xml.LoadXml(subtitle.Header);
}
catch
{
subtitle.Header = new TimedText10().ToText(new Subtitle(), "tt");
_xml.LoadXml(subtitle.Header); // load default xml
}
_namespaceManager = new XmlNamespaceManager(_xml.NameTable);
_namespaceManager.AddNamespace("ttml", TimedText10.TtmlNamespace);
_namespaceManager.AddNamespace("ttp", TimedText10.TtmlParameterNamespace);
_namespaceManager.AddNamespace("tts", TimedText10.TtmlStylingNamespace);
_namespaceManager.AddNamespace("ttm", TimedText10.TtmlMetadataNamespace);
XmlNode node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:title", _namespaceManager);
if (node != null)
{
textBoxTitle.Text = node.InnerText;
}
node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:desc", _namespaceManager);
if (node != null)
{
textBoxDescription.Text = node.InnerText;
}
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
comboBoxLanguage.Items.Add(ci.Name);
}
XmlAttribute attr = _xml.DocumentElement.Attributes["xml:lang"];
if (attr != null)
{
comboBoxLanguage.Text = attr.InnerText;
}
attr = _xml.DocumentElement.Attributes["ttp:timeBase"];
if (attr != null)
{
comboBoxTimeBase.Text = attr.InnerText;
}
comboBoxFrameRate.Items.Add("23.976");
comboBoxFrameRate.Items.Add("24.0");
comboBoxFrameRate.Items.Add("25.0");
comboBoxFrameRate.Items.Add("29.97");
comboBoxFrameRate.Items.Add("30.0");
attr = _xml.DocumentElement.Attributes["ttp:frameRate"];
if (attr != null)
{
comboBoxFrameRate.Text = attr.InnerText;
}
attr = _xml.DocumentElement.Attributes["ttp:frameRateMultiplier"];
if (attr != null)
{
comboBoxFrameRateMultiplier.Text = attr.InnerText;
}
attr = _xml.DocumentElement.Attributes["ttp:dropMode"];
if (attr != null)
{
comboBoxDropMode.Text = attr.InnerText;
}
foreach (string style in TimedText10.GetStylesFromHeader(_subtitle.Header))
{
comboBoxDefaultStyle.Items.Add(style);
node = _xml.DocumentElement.SelectSingleNode("ttml:body", _namespaceManager);
if (node?.Attributes?["style"] != null && style == node.Attributes["style"].Value)
{
comboBoxDefaultStyle.SelectedIndex = comboBoxDefaultStyle.Items.Count - 1;
}
}
foreach (string region in TimedText10.GetRegionsFromHeader(_subtitle.Header))
{
comboBoxDefaultRegion.Items.Add(region);
node = _xml.DocumentElement.SelectSingleNode("ttml:body", _namespaceManager);
if (node?.Attributes?["region"] != null && region == node.Attributes["region"].Value)
{
comboBoxDefaultRegion.SelectedIndex = comboBoxDefaultRegion.Items.Count - 1;
}
}
var timeCodeFormat = Configuration.Settings.SubtitleSettings.TimedTextImsc11TimeCodeFormat.Trim().ToLowerInvariant();
comboBoxTimeCodeFormat.SelectedIndex = 0;
for (int index = 0; index < comboBoxTimeCodeFormat.Items.Count; index++)
{
var item = comboBoxTimeCodeFormat.Items[index];
if (item.ToString().ToLowerInvariant() == timeCodeFormat)
{
comboBoxTimeCodeFormat.SelectedIndex = index;
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;
}
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void buttonOK_Click(object sender, EventArgs e)
{
XmlNode node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:title", _namespaceManager);
if (node != null)
{
if (string.IsNullOrWhiteSpace(textBoxTitle.Text) && string.IsNullOrWhiteSpace(textBoxDescription.Text))
{
_xml.DocumentElement.SelectSingleNode("ttml:head", _namespaceManager).RemoveChild(_xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata", _namespaceManager));
}
else
{
node.InnerText = textBoxTitle.Text;
}
}
else if (!string.IsNullOrWhiteSpace(textBoxTitle.Text))
{
var head = _xml.DocumentElement.SelectSingleNode("ttml:head", _namespaceManager);
if (head == null)
{
head = _xml.CreateElement("ttml", "head", _namespaceManager.LookupNamespace("ttml"));
_xml.DocumentElement.PrependChild(head);
}
var metadata = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata", _namespaceManager);
if (metadata == null)
{
metadata = _xml.CreateElement("ttml", "metadata", _namespaceManager.LookupNamespace("ttml"));
head.PrependChild(metadata);
}
var title = _xml.CreateElement("ttml", "title", _namespaceManager.LookupNamespace("ttml"));
metadata.InnerText = textBoxTitle.Text;
metadata.AppendChild(title);
}
node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:desc", _namespaceManager);
if (node != null)
{
node.InnerText = textBoxDescription.Text;
}
else if (!string.IsNullOrWhiteSpace(textBoxDescription.Text))
{
var head = _xml.DocumentElement.SelectSingleNode("ttml:head", _namespaceManager);
if (head == null)
{
head = _xml.CreateElement("ttml", "head", _namespaceManager.LookupNamespace("ttml"));
_xml.DocumentElement.PrependChild(head);
}
var metadata = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata", _namespaceManager);
if (metadata == null)
{
metadata = _xml.CreateElement("ttml", "metadata", _namespaceManager.LookupNamespace("ttml"));
head.PrependChild(metadata);
}
var desc = _xml.CreateElement("ttml", "desc", _namespaceManager.LookupNamespace("ttml"));
desc.InnerText = textBoxDescription.Text;
metadata.AppendChild(desc);
}
XmlAttribute attr = _xml.DocumentElement.Attributes["xml:lang"];
if (attr != null)
{
attr.Value = comboBoxLanguage.Text;
if (attr.Value.Length == 0)
{
_xml.DocumentElement.Attributes.Remove(attr);
}
}
else if (comboBoxLanguage.Text.Length > 0)
{
attr = _xml.CreateAttribute("xml", "lang", _namespaceManager.LookupNamespace("xml"));
attr.Value = comboBoxLanguage.Text;
_xml.DocumentElement.Attributes.Prepend(attr);
}
attr = _xml.DocumentElement.Attributes["ttp:timeBase"];
if (attr != null)
{
attr.InnerText = comboBoxTimeBase.Text;
if (attr.Value.Length == 0)
{
_xml.DocumentElement.Attributes.Remove(attr);
}
}
else if (comboBoxTimeBase.Text.Length > 0)
{
attr = _xml.CreateAttribute("ttp", "timeBase", _namespaceManager.LookupNamespace("ttp"));
attr.Value = comboBoxTimeBase.Text;
_xml.DocumentElement.Attributes.Append(attr);
}
attr = _xml.DocumentElement.Attributes["ttp:frameRate"];
if (attr != null)
{
attr.InnerText = comboBoxFrameRate.Text;
if (attr.Value.Length == 0)
{
_xml.DocumentElement.Attributes.Remove(attr);
}
}
else if (comboBoxFrameRate.Text.Length > 0)
{
attr = _xml.CreateAttribute("ttp", "frameRate", _namespaceManager.LookupNamespace("ttp"));
attr.Value = comboBoxFrameRate.Text;
_xml.DocumentElement.Attributes.Append(attr);
}
attr = _xml.DocumentElement.Attributes["ttp:frameRateMultiplier"];
if (attr != null)
{
attr.InnerText = comboBoxFrameRateMultiplier.Text;
if (attr.Value.Length == 0)
{
_xml.DocumentElement.Attributes.Remove(attr);
}
}
else if (comboBoxFrameRateMultiplier.Text.Length > 0)
{
attr = _xml.CreateAttribute("ttp", "frameRateMultiplier", _namespaceManager.LookupNamespace("ttp"));
attr.Value = comboBoxFrameRateMultiplier.Text;
_xml.DocumentElement.Attributes.Append(attr);
}
attr = _xml.DocumentElement.Attributes["ttp:dropMode"];
if (attr != null)
{
attr.InnerText = comboBoxDropMode.Text;
if (attr.Value.Length == 0)
{
_xml.DocumentElement.Attributes.Remove(attr);
}
}
else if (comboBoxDropMode.Text.Length > 0)
{
attr = _xml.CreateAttribute("ttp", "dropMode", _namespaceManager.LookupNamespace("ttp"));
attr.Value = comboBoxDropMode.Text;
_xml.DocumentElement.Attributes.Append(attr);
}
node = _xml.DocumentElement.SelectSingleNode("ttml:body", _namespaceManager);
if (node != null && node.Attributes["style"] != null)
{
node.Attributes["style"].Value = comboBoxDefaultStyle.Text;
}
else if (comboBoxDefaultStyle.Text.Length > 0 && node != null)
{
attr = _xml.CreateAttribute("style");
attr.Value = comboBoxDefaultStyle.Text;
node.Attributes.Append(attr);
}
node = _xml.DocumentElement.SelectSingleNode("ttml:body", _namespaceManager);
if (node != null && node.Attributes["region"] != null)
{
node.Attributes["region"].Value = comboBoxDefaultRegion.Text;
}
else if (comboBoxDefaultRegion.Text.Length > 0 && node != null)
{
attr = _xml.CreateAttribute("region");
attr.Value = comboBoxDefaultRegion.Text;
node.Attributes.Append(attr);
}
_subtitle.Header = _xml.OuterXml;
Configuration.Settings.SubtitleSettings.TimedTextImsc11TimeCodeFormat = comboBoxTimeCodeFormat.SelectedItem.ToString();
var currentTimedTextExt = Configuration.Settings.SubtitleSettings.TimedText10FileExtension;
var newTimedTextExt = comboBoxFileExtensions.SelectedItem.ToString();
if (currentTimedTextExt != newTimedTextExt)
{
var favoriteFormats = Configuration.Settings.General.FavoriteSubtitleFormats;
var currentTimedTextWithExt = $"Timed Text 1.0 ({currentTimedTextExt})";
var newTimedTextWithExt = $"Timed Text 1.0 ({newTimedTextExt})";
if (favoriteFormats.Contains(currentTimedTextWithExt))
{
Configuration.Settings.General.FavoriteSubtitleFormats = favoriteFormats.Replace(currentTimedTextWithExt, newTimedTextWithExt);
}
Configuration.Settings.SubtitleSettings.TimedText10FileExtension = newTimedTextExt;
}
DialogResult = DialogResult.OK;
}
private void TimedTextProperties_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
DialogResult = DialogResult.Cancel;
}
}
}
}

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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -665,6 +665,12 @@
<Compile Include="Forms\SeJobs\SeJobExport.Designer.cs">
<DependentUpon>SeJobExport.cs</DependentUpon>
</Compile>
<Compile Include="Forms\TimedTextPropertiesIms11.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\TimedTextPropertiesIms11.Designer.cs">
<DependentUpon>TimedTextPropertiesIms11.cs</DependentUpon>
</Compile>
<Compile Include="Forms\TimedTextPropertiesItunes.cs">
<SubType>Form</SubType>
</Compile>
@ -1918,6 +1924,9 @@
<EmbeddedResource Include="Forms\ShotChanges\AdjustTimingViaShotChanges.resx">
<DependentUpon>AdjustTimingViaShotChanges.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\TimedTextPropertiesIms11.resx">
<DependentUpon>TimedTextPropertiesIms11.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\TimedTextPropertiesItunes.resx">
<DependentUpon>TimedTextPropertiesItunes.cs</DependentUpon>
</EmbeddedResource>