Split up D-cinema smtp to 2007 and 2010 versions - thx Knut :)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2308 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2013-12-16 18:36:23 +00:00
parent fe0d26281e
commit 2ab7e4b0b2
10 changed files with 1190 additions and 50 deletions

View File

@ -12438,25 +12438,24 @@ namespace Nikse.SubtitleEdit.Forms
private void ShowSubtitleTimerTick(object sender, EventArgs e) private void ShowSubtitleTimerTick(object sender, EventArgs e)
{ {
ShowSubtitleTimer.Stop(); ShowSubtitleTimer.Stop();
if (mediaPlayer != null) int oldIndex = FirstSelectedIndex;
int index = ShowSubtitle();
if (index != -1 && checkBoxSyncListViewWithVideoWhilePlaying.Checked && oldIndex != index)
{ {
int index = ShowSubtitle(); if ((DateTime.Now.Ticks - _lastTextKeyDownTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds
if (index != -1 && checkBoxSyncListViewWithVideoWhilePlaying.Checked)
{ {
if ((DateTime.Now.Ticks - _lastTextKeyDownTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds if (_endSeconds <= 0 || !checkBoxAutoRepeatOn.Checked)
{ {
if (_endSeconds <= 0 || !checkBoxAutoRepeatOn.Checked) if (!timerAutoDuration.Enabled && !mediaPlayer.IsPaused)
{ {
if (!timerAutoDuration.Enabled && !mediaPlayer.IsPaused) SubtitleListview1.BeginUpdate();
{ SubtitleListview1.SelectIndexAndEnsureVisible(index, true);
SubtitleListview1.BeginUpdate(); SubtitleListview1.EndUpdate();
SubtitleListview1.SelectIndexAndEnsureVisible(index, true);
SubtitleListview1.EndUpdate();
}
} }
} }
} }
} }
if (_changeSubtitleToString != SerializeSubtitle(_subtitle)) if (_changeSubtitleToString != SerializeSubtitle(_subtitle))
{ {
if (!Text.EndsWith("*")) if (!Text.EndsWith("*"))
@ -13444,7 +13443,7 @@ namespace Nikse.SubtitleEdit.Forms
toolStripMenuItemSubStationAlpha.Visible = false; toolStripMenuItemSubStationAlpha.Visible = false;
} }
if (format.GetType() == typeof(DCSubtitle) || format.GetType() == typeof(DCinemaSmpte)) if (format.GetType() == typeof(DCSubtitle) || format.GetType() == typeof(DCinemaSmpte2010))
{ {
toolStripMenuItemDCinemaProperties.Visible = true; toolStripMenuItemDCinemaProperties.Visible = true;
} }

View File

@ -1,16 +1,17 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression;
using System.Text; using System.Text;
using System.Xml; using System.Xml;
using System.Xml.Schema; using System.Xml.Schema;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{ {
public class DCinemaSmpte : SubtitleFormat public class DCinemaSmpte2007 : SubtitleFormat
{ {
//<?xml version="1.0" encoding="UTF-8"?> //<?xml version="1.0" encoding="UTF-8"?>
//<dcst:SubtitleReel xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcst="http://www.smpte-ra.org/schemas/428-7/2010/DCST"> //<dcst:SubtitleReel xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcst="http://www.smpte-ra.org/schemas/428-7/2007/DCST">
// <Id>urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e</Id> // <Id>urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e</Id>
// <ContentTitleText>2001, A Space Odissey</ContentTitleText> // <ContentTitleText>2001, A Space Odissey</ContentTitleText>
// <AnnotationText>This is a subtitle file</AnnotationText> // <AnnotationText>This is a subtitle file</AnnotationText>
@ -31,6 +32,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
private double frameRate = 24; private double frameRate = 24;
public int Version { get; set; }
public override string Extension public override string Extension
{ {
get { return ".xml"; } get { return ".xml"; }
@ -38,7 +41,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
public override string Name public override string Name
{ {
get { return "D-Cinema SMPTE"; } get { return "D-Cinema SMPTE 2007"; }
} }
public override bool IsTimeBased public override bool IsTimeBased
@ -51,6 +54,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
var sb = new StringBuilder(); var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line)); lines.ForEach(line => sb.AppendLine(line));
string xmlAsString = sb.ToString().Trim(); string xmlAsString = sb.ToString().Trim();
if (xmlAsString.Contains("http://www.smpte-ra.org/schemas/428-7/2010/DCST"))
return false;
if (xmlAsString.Contains("<dcst:SubtitleReel") || xmlAsString.Contains("<SubtitleReel")) if (xmlAsString.Contains("<dcst:SubtitleReel") || xmlAsString.Contains("<SubtitleReel"))
{ {
var xml = new XmlDocument(); var xml = new XmlDocument();
@ -58,7 +65,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{ {
xmlAsString = xmlAsString.Replace("<dcst:", "<").Replace("</dcst:", "</"); xmlAsString = xmlAsString.Replace("<dcst:", "<").Replace("</dcst:", "</");
xmlAsString = xmlAsString.Replace("xmlns=\"http://www.smpte-ra.org/schemas/428-7/2007/DCST\"", string.Empty); xmlAsString = xmlAsString.Replace("xmlns=\"http://www.smpte-ra.org/schemas/428-7/2007/DCST\"", string.Empty);
xmlAsString = xmlAsString.Replace("xmlns=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\"", string.Empty);
xml.LoadXml(xmlAsString); xml.LoadXml(xmlAsString);
var subtitles = xml.DocumentElement.SelectNodes("//Subtitle"); var subtitles = xml.DocumentElement.SelectNodes("//Subtitle");
if (subtitles != null && subtitles.Count >= 0) if (subtitles != null && subtitles.Count >= 0)
@ -443,7 +449,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
} }
string result = ToUtf8XmlString(xml).Replace("encoding=\"utf-8\"", "encoding=\"UTF-8\"").Replace(" xmlns:dcst=\"dcst\"", string.Empty); string result = ToUtf8XmlString(xml).Replace("encoding=\"utf-8\"", "encoding=\"UTF-8\"").Replace(" xmlns:dcst=\"dcst\"", string.Empty);
string res = "Nikse.SubtitleEdit.Resources.SMPTE-428-7-2007-DCST.xsd"; string res = "Nikse.SubtitleEdit.Resources.SMPTE-428-7-2007-DCST.xsd.gz";
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
Stream strm = asm.GetManifestResourceStream(res); Stream strm = asm.GetManifestResourceStream(res);
if (strm != null) if (strm != null)
@ -451,17 +457,22 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
try try
{ {
var xmld = new XmlDocument(); var xmld = new XmlDocument();
xmld.LoadXml(result); var rdr = new StreamReader(strm);
var xr = XmlReader.Create(strm); using (var zip = new GZipStream(rdr.BaseStream, CompressionMode.Decompress))
xmld.Schemas.Add(null, xr); {
xmld.Validate(ValidationCallBack); xmld.LoadXml(result);
xr.Close(); var xr = XmlReader.Create(zip);
strm.Close(); xmld.Schemas.Add(null, xr);
xmld.Validate(ValidationCallBack);
xr.Close();
strm.Close();
}
rdr.Close();
} }
catch (Exception exception) catch (Exception exception)
{ {
if (!BatchMode) if (!BatchMode)
System.Windows.Forms.MessageBox.Show("SMPTE-428-7-2007-DCST.xsd:" + exception.Message); System.Windows.Forms.MessageBox.Show("SMPTE-428-7-2007-DCST.xsd: " + exception.Message);
} }
} }
return result; return result;

View File

@ -0,0 +1,778 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.Xml;
using System.Xml.Schema;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
public class DCinemaSmpte2010 : SubtitleFormat
{
//<?xml version="1.0" encoding="UTF-8"?>
//<dcst:SubtitleReel xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcst="http://www.smpte-ra.org/schemas/428-7/2010/DCST">
// <Id>urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e</Id>
// <ContentTitleText>2001, A Space Odissey</ContentTitleText>
// <AnnotationText>This is a subtitle file</AnnotationText>
// <IssueDate>2012-06-26T12:33:59.000-00:00</IssueDate>
// <ReelNumber>1</ReelNumber>
// <Language>fr</Language>
// <EditRate>25 1</EditRate>
// <TimeCodeRate>25</TimeCodeRate>
// <StartTime>00:00:00:00</StartTime>
// <LoadFont ID="theFontId">urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391</LoadFont>
// <SubtitleList
// <Font ID="theFontId" Size="39" Weight="normal" Color="FFFFFFFF">
// <Subtitle FadeDownTime="00:00:00:00" FadeUpTime="00:00:00:00" TimeOut="00:00:00:01" TimeIn="00:00:00:00" SpotNumber="1">
// <Text Vposition="10.0" Valign="bottom">Hallo</Text>
// </Subtitle>
// </SubtitleList
//</dcst:SubtitleReel>
private double frameRate = 24;
public int Version { get; set; }
public override string Extension
{
get { return ".xml"; }
}
public override string Name
{
get { return "D-Cinema SMPTE 2010"; }
}
public override bool IsTimeBased
{
get { return true; }
}
public override bool IsMine(List<string> lines, string fileName)
{
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
string xmlAsString = sb.ToString().Trim();
if (xmlAsString.Contains("http://www.smpte-ra.org/schemas/428-7/2007/DCST"))
return false;
if (xmlAsString.Contains("<dcst:SubtitleReel") || xmlAsString.Contains("<SubtitleReel"))
{
var xml = new XmlDocument();
try
{
xmlAsString = xmlAsString.Replace("<dcst:", "<").Replace("</dcst:", "</");
xmlAsString = xmlAsString.Replace("xmlns=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\"", string.Empty);
xml.LoadXml(xmlAsString);
var subtitles = xml.DocumentElement.SelectNodes("//Subtitle");
if (subtitles != null && subtitles.Count >= 0)
return subtitles != null && subtitles.Count > 0;
return false;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
return false;
}
}
else
{
return false;
}
}
private static string RemoveSubStationAlphaFormatting(string s)
{
int indexOfBegin = s.IndexOf("{", StringComparison.Ordinal);
while (indexOfBegin >= 0 && s.IndexOf("}", StringComparison.Ordinal) > indexOfBegin)
{
int indexOfEnd = s.IndexOf("}", StringComparison.Ordinal);
s = s.Remove(indexOfBegin, (indexOfEnd - indexOfBegin) + 1);
indexOfBegin = s.IndexOf("{", StringComparison.Ordinal);
}
return s;
}
public override string ToText(Subtitle subtitle, string title)
{
var ss = Configuration.Settings.SubtitleSettings;
if (!string.IsNullOrEmpty(ss.CurrentDCinemaEditRate))
{
string[] temp = ss.CurrentDCinemaEditRate.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
double d1, d2;
if (temp.Length == 2 && double.TryParse(temp[0], out d1) && double.TryParse(temp[1], out d2))
frameRate = d1 / d2;
}
string xmlStructure =
"<dcst:SubtitleReel xmlns:dcst=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" + Environment.NewLine +
" <dcst:Id>urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e</dcst:Id>" + Environment.NewLine +
" <dcst:ContentTitleText></dcst:ContentTitleText> " + Environment.NewLine +
" <dcst:AnnotationText>This is a subtitle file</dcst:AnnotationText>" + Environment.NewLine +
" <dcst:IssueDate>2012-06-26T12:33:59.000-00:00</dcst:IssueDate>" + Environment.NewLine +
" <dcst:ReelNumber>1</dcst:ReelNumber>" + Environment.NewLine +
" <dcst:Language>en</dcst:Language>" + Environment.NewLine +
" <dcst:EditRate>25 1</dcst:EditRate>" + Environment.NewLine +
" <dcst:TimeCodeRate>25</dcst:TimeCodeRate>" + Environment.NewLine +
" <dcst:StartTime>00:00:00:00</dcst:StartTime> " + Environment.NewLine +
" <dcst:LoadFont ID=\"theFontId\">urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391</dcst:LoadFont>" + Environment.NewLine +
" <dcst:SubtitleList>" + Environment.NewLine +
" <dcst:Font ID=\"theFontId\" Size=\"39\" Weight=\"normal\" Color=\"FFFFFFFF\" Effect=\"border\" EffectColor=\"FF000000\">" + Environment.NewLine +
" </dcst:Font>" + Environment.NewLine +
" </dcst:SubtitleList>" + Environment.NewLine +
"</dcst:SubtitleReel>";
var xml = new XmlDocument();
xml.LoadXml(xmlStructure);
xml.PreserveWhitespace = true;
var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("dcst", xml.DocumentElement.NamespaceURI);
if (string.IsNullOrEmpty(ss.CurrentDCinemaMovieTitle))
ss.CurrentDCinemaMovieTitle = title;
if (ss.CurrentDCinemaFontSize == 0 || string.IsNullOrEmpty(ss.CurrentDCinemaFontEffect))
Configuration.Settings.SubtitleSettings.InitializeDCinameSettings(true);
xml.DocumentElement.SelectSingleNode("dcst:ContentTitleText", nsmgr).InnerText = ss.CurrentDCinemaMovieTitle;
xml.DocumentElement.SelectSingleNode("dcst:Id", nsmgr).InnerText = ss.CurrentDCinemaSubtitleId;
xml.DocumentElement.SelectSingleNode("dcst:ReelNumber", nsmgr).InnerText = ss.CurrentDCinemaReelNumber;
xml.DocumentElement.SelectSingleNode("dcst:IssueDate", nsmgr).InnerText = ss.CurrentDCinemaIssueDate;
if (string.IsNullOrEmpty(ss.CurrentDCinemaLanguage))
ss.CurrentDCinemaLanguage = "en";
xml.DocumentElement.SelectSingleNode("dcst:Language", nsmgr).InnerText = ss.CurrentDCinemaLanguage;
if (ss.CurrentDCinemaEditRate == null && ss.CurrentDCinemaTimeCodeRate == null)
{
if (Configuration.Settings.General.CurrentFrameRate == 24)
{
ss.CurrentDCinemaEditRate = "24 1";
ss.CurrentDCinemaTimeCodeRate = "24";
}
else
{
ss.CurrentDCinemaEditRate = "25 1";
ss.CurrentDCinemaTimeCodeRate = "25";
}
}
xml.DocumentElement.SelectSingleNode("dcst:EditRate", nsmgr).InnerText = ss.CurrentDCinemaEditRate;
xml.DocumentElement.SelectSingleNode("dcst:TimeCodeRate", nsmgr).InnerText = ss.CurrentDCinemaTimeCodeRate;
if (string.IsNullOrEmpty(ss.CurrentDCinemaStartTime))
ss.CurrentDCinemaStartTime = "00:00:00:00";
xml.DocumentElement.SelectSingleNode("dcst:StartTime", nsmgr).InnerText = ss.CurrentDCinemaStartTime;
xml.DocumentElement.SelectSingleNode("dcst:LoadFont", nsmgr).InnerText = ss.CurrentDCinemaFontUri;
int fontSize = ss.CurrentDCinemaFontSize;
string loadedFontId = "Font1";
if (!string.IsNullOrEmpty(ss.CurrentDCinemaFontId))
loadedFontId = ss.CurrentDCinemaFontId;
xml.DocumentElement.SelectSingleNode("dcst:LoadFont", nsmgr).Attributes["ID"].Value = loadedFontId;
xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Size"].Value = fontSize.ToString();
xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Color"].Value = "FF" + Utilities.ColorToHex(ss.CurrentDCinemaFontColor).TrimStart('#').ToUpper();
xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["ID"].Value = loadedFontId;
xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Effect"].Value = ss.CurrentDCinemaFontEffect;
xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["EffectColor"].Value = "FF" + Utilities.ColorToHex(ss.CurrentDCinemaFontEffectColor).TrimStart('#').ToUpper();
XmlNode mainListFont = xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr);
int no = 0;
foreach (Paragraph p in subtitle.Paragraphs)
{
if (p.Text != null)
{
XmlNode subNode = xml.CreateElement("dcst:Subtitle", "dcst");
XmlAttribute id = xml.CreateAttribute("SpotNumber");
id.InnerText = (no + 1).ToString();
subNode.Attributes.Append(id);
XmlAttribute fadeUpTime = xml.CreateAttribute("FadeUpTime");
fadeUpTime.InnerText = "00:00:00:00"; //Configuration.Settings.SubtitleSettings.DCinemaFadeUpDownTime.ToString();
subNode.Attributes.Append(fadeUpTime);
XmlAttribute fadeDownTime = xml.CreateAttribute("FadeDownTime");
fadeDownTime.InnerText = "00:00:00:00"; //Configuration.Settings.SubtitleSettings.DCinemaFadeUpDownTime.ToString();
subNode.Attributes.Append(fadeDownTime);
XmlAttribute start = xml.CreateAttribute("TimeIn");
start.InnerText = ConvertToTimeString(p.StartTime);
subNode.Attributes.Append(start);
XmlAttribute end = xml.CreateAttribute("TimeOut");
end.InnerText = ConvertToTimeString(p.EndTime);
subNode.Attributes.Append(end);
bool alignLeft = p.Text.StartsWith("{\\a1}") || p.Text.StartsWith("{\\a5}") || p.Text.StartsWith("{\\a9}") || // sub station alpha
p.Text.StartsWith("{\\an1}") || p.Text.StartsWith("{\\an4}") || p.Text.StartsWith("{\\an7}"); // advanced sub station alpha
bool alignRight = p.Text.StartsWith("{\\a3}") || p.Text.StartsWith("{\\a7}") || p.Text.StartsWith("{\\a11}") || // sub station alpha
p.Text.StartsWith("{\\an3}") || p.Text.StartsWith("{\\an6}") || p.Text.StartsWith("{\\an9}"); // advanced sub station alpha
bool alignVTop = p.Text.StartsWith("{\\a5}") || p.Text.StartsWith("{\\a6}") || p.Text.StartsWith("{\\a7}") || // sub station alpha
p.Text.StartsWith("{\\an7}") || p.Text.StartsWith("{\\an8}") || p.Text.StartsWith("{\\an9}"); // advanced sub station alpha
bool alignVCenter = p.Text.StartsWith("{\\a9}") || p.Text.StartsWith("{\\a10}") || p.Text.StartsWith("{\\a11}") || // sub station alpha
p.Text.StartsWith("{\\an4}") || p.Text.StartsWith("{\\an5}") || p.Text.StartsWith("{\\an6}"); // advanced sub station alpha
// remove styles for display text (except italic)
string text = RemoveSubStationAlphaFormatting(p.Text);
string[] lines = text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
int vPos = 1 + lines.Length * 7;
int vPosFactor = (int)Math.Round(fontSize / 7.4);
if (alignVTop)
{
vPos = Configuration.Settings.SubtitleSettings.DCinemaBottomMargin; // Bottom margin is normally 8
}
else if (alignVCenter)
{
vPos = (int)Math.Round((lines.Length * vPosFactor * -1) / 2.0);
}
else
{
vPos = (lines.Length * vPosFactor) - vPosFactor + Configuration.Settings.SubtitleSettings.DCinemaBottomMargin; // Bottom margin is normally 8
}
bool isItalic = false;
int fontNo = 0;
System.Collections.Generic.Stack<string> fontColors = new Stack<string>();
foreach (string line in lines)
{
XmlNode textNode = xml.CreateElement("dcst:Text", "dcst");
XmlAttribute vPosition = xml.CreateAttribute("Vposition");
vPosition.InnerText = vPos.ToString();
textNode.Attributes.Append(vPosition);
XmlAttribute vAlign = xml.CreateAttribute("Valign");
if (alignVTop)
vAlign.InnerText = "top";
else if (alignVCenter)
vAlign.InnerText = "center";
else
vAlign.InnerText = "bottom";
textNode.Attributes.Append(vAlign); textNode.Attributes.Append(vAlign);
XmlAttribute hAlign = xml.CreateAttribute("Halign");
if (alignLeft)
hAlign.InnerText = "left";
else if (alignRight)
hAlign.InnerText = "right";
else
hAlign.InnerText = "center";
textNode.Attributes.Append(hAlign);
XmlAttribute direction = xml.CreateAttribute("Direction");
direction.InnerText = "ltr";
textNode.Attributes.Append(direction);
int i = 0;
var txt = new StringBuilder();
var html = new StringBuilder();
XmlNode nodeTemp = xml.CreateElement("temp");
while (i < line.Length)
{
if (!isItalic && line.Substring(i).StartsWith("<i>"))
{
if (txt.Length > 0)
{
nodeTemp.InnerText = txt.ToString();
html.Append(nodeTemp.InnerXml);
txt = new StringBuilder();
}
isItalic = true;
i += 2;
}
else if (isItalic && line.Substring(i).StartsWith("</i>"))
{
if (txt.Length > 0)
{
XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst");
XmlAttribute italic = xml.CreateAttribute("Italic");
italic.InnerText = "yes";
fontNode.Attributes.Append(italic);
if (line.Length > i + 5 && line.Substring(i+4).StartsWith("</font>"))
{
XmlAttribute fontColor = xml.CreateAttribute("Color");
fontColor.InnerText = fontColors.Pop();
fontNode.Attributes.Append(fontColor);
fontNo--;
i += 7;
}
fontNode.InnerText = Utilities.RemoveHtmlTags(txt.ToString());
html.Append(fontNode.OuterXml);
txt = new StringBuilder();
}
isItalic = false;
i += 3;
}
else if (line.Substring(i).StartsWith("<font color=") && line.Substring(i + 3).Contains(">"))
{
int endOfFont = line.IndexOf(">", i);
if (txt.Length > 0)
{
nodeTemp.InnerText = txt.ToString();
html.Append(nodeTemp.InnerXml);
txt = new StringBuilder();
}
string c = line.Substring(i + 12, endOfFont - (i + 12));
c = c.Trim('"').Trim('\'').Trim();
if (c.StartsWith("#"))
c = c.TrimStart('#').ToUpper().PadLeft(8, 'F');
fontColors.Push(c);
fontNo++;
i += endOfFont - i;
}
else if (fontNo > 0 && line.Substring(i).StartsWith("</font>"))
{
if (txt.Length > 0)
{
XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst");
XmlAttribute fontColor = xml.CreateAttribute("Color");
fontColor.InnerText = fontColors.Pop();
fontNode.Attributes.Append(fontColor);
if (line.Length > i + 9 && line.Substring(i + 7).StartsWith("</i>"))
{
XmlAttribute italic = xml.CreateAttribute("Italic");
italic.InnerText = "yes";
fontNode.Attributes.Append(italic);
isItalic = false;
i += 4;
}
fontNode.InnerText = Utilities.RemoveHtmlTags(txt.ToString());
html.Append(fontNode.OuterXml);
txt = new StringBuilder();
}
fontNo--;
i += 6;
}
else
{
txt.Append(line.Substring(i, 1));
}
i++;
}
if (fontNo > 0)
{
if (txt.Length > 0)
{
XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst");
XmlAttribute fontColor = xml.CreateAttribute("Color");
fontColor.InnerText = fontColors.Peek();
fontNode.Attributes.Append(fontColor);
if (isItalic)
{
XmlAttribute italic = xml.CreateAttribute("Italic");
italic.InnerText = "yes";
fontNode.Attributes.Append(italic);
}
fontNode.InnerText = Utilities.RemoveHtmlTags(txt.ToString());
html.Append(fontNode.OuterXml);
}
else if (html.Length > 0 && html.ToString().StartsWith("<dcst:Font "))
{
XmlDocument temp = new XmlDocument();
temp.LoadXml("<root>" + html.ToString().Replace("dcst:Font", "Font") + "</root>");
XmlNode fontNode = xml.CreateElement("dcst:Font");
fontNode.InnerXml = temp.DocumentElement.SelectSingleNode("Font").InnerXml;
foreach (XmlAttribute a in temp.DocumentElement.SelectSingleNode("Font").Attributes)
{
XmlAttribute newA = xml.CreateAttribute(a.Name);
newA.InnerText = a.InnerText;
fontNode.Attributes.Append(newA);
}
XmlAttribute fontColor = xml.CreateAttribute("Color");
fontColor.InnerText = fontColors.Peek();
fontNode.Attributes.Append(fontColor);
html = new StringBuilder();
html.Append(fontNode.OuterXml);
}
}
else if (isItalic)
{
if (txt.Length > 0)
{
XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst");
XmlAttribute italic = xml.CreateAttribute("Italic");
italic.InnerText = "yes";
fontNode.Attributes.Append(italic);
fontNode.InnerText = Utilities.RemoveHtmlTags(line);
html.Append(fontNode.OuterXml);
}
}
else
{
if (txt.Length > 0)
{
nodeTemp.InnerText = txt.ToString();
html.Append(nodeTemp.InnerXml);
}
}
textNode.InnerXml = html.ToString();
subNode.AppendChild(textNode);
vPos -= vPosFactor;
}
if (subNode.InnerXml.Length == 0)
{ // Empty text is just one space
XmlNode textNode = xml.CreateElement("dcst:Text", "dcst");
textNode.InnerXml = " ";
subNode.AppendChild(textNode);
XmlAttribute vPosition = xml.CreateAttribute("Vposition");
vPosition.InnerText = vPos.ToString();
textNode.Attributes.Append(vPosition);
XmlAttribute vAlign = xml.CreateAttribute("Valign");
vAlign.InnerText = "bottom";
textNode.Attributes.Append(vAlign);
}
mainListFont.AppendChild(subNode);
no++;
}
}
string result = ToUtf8XmlString(xml).Replace("encoding=\"utf-8\"", "encoding=\"UTF-8\"").Replace(" xmlns:dcst=\"dcst\"", string.Empty);
string res = "Nikse.SubtitleEdit.Resources.SMPTE-428-7-2010-DCST.xsd.gz";
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
Stream strm = asm.GetManifestResourceStream(res);
if (strm != null)
{
try
{
var xmld = new XmlDocument();
var rdr = new StreamReader(strm);
using (var zip = new GZipStream(rdr.BaseStream, CompressionMode.Decompress))
{
xmld.LoadXml(result);
var xr = XmlReader.Create(zip);
xmld.Schemas.Add(null, xr);
xmld.Validate(ValidationCallBack);
xr.Close();
strm.Close();
}
rdr.Close();
}
catch (Exception exception)
{
if (!BatchMode)
System.Windows.Forms.MessageBox.Show("SMPTE-428-7-2010-DCST.xsd: " + exception.Message);
}
}
return result;
}
private void ValidationCallBack(object sender, ValidationEventArgs e)
{
throw new Exception(e.Message);
}
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.LoadXml(sb.ToString().Replace("<dcst:", "<").Replace("</dcst:", "</").Replace("xmlns=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\"", string.Empty)); // tags might be prefixed with namespace (or not)... so we just remove them
var ss = Configuration.Settings.SubtitleSettings;
try
{
ss.InitializeDCinameSettings(true);
XmlNode node = xml.DocumentElement.SelectSingleNode("Id");
if (node != null)
ss.CurrentDCinemaSubtitleId = node.InnerText;
node = xml.DocumentElement.SelectSingleNode("ReelNumber");
if (node != null)
ss.CurrentDCinemaReelNumber = node.InnerText;
node = xml.DocumentElement.SelectSingleNode("EditRate");
if (node != null)
ss.CurrentDCinemaEditRate = node.InnerText;
node = xml.DocumentElement.SelectSingleNode("TimeCodeRate");
if (node != null)
ss.CurrentDCinemaTimeCodeRate = node.InnerText;
node = xml.DocumentElement.SelectSingleNode("StartTime");
if (node != null)
ss.CurrentDCinemaStartTime = node.InnerText;
node = xml.DocumentElement.SelectSingleNode("Language");
if (node != null)
ss.CurrentDCinemaLanguage = node.InnerText;
node = xml.DocumentElement.SelectSingleNode("ContentTitleText");
if (node != null)
ss.CurrentDCinemaMovieTitle = node.InnerText;
node = xml.DocumentElement.SelectSingleNode("IssueDate");
if (node != null)
ss.CurrentDCinemaIssueDate = node.InnerText;
node = xml.DocumentElement.SelectSingleNode("LoadFont");
if (node != null)
ss.CurrentDCinemaFontUri = node.InnerText;
node = xml.DocumentElement.SelectSingleNode("SubtitleList/Font");
if (node != null)
{
if (node.Attributes["ID"] != null)
ss.CurrentDCinemaFontId = node.Attributes["ID"].InnerText;
if (node.Attributes["Size"] != null)
ss.CurrentDCinemaFontSize = Convert.ToInt32(node.Attributes["Size"].InnerText);
if (node.Attributes["Color"] != null)
ss.CurrentDCinemaFontColor = System.Drawing.ColorTranslator.FromHtml("#" + node.Attributes["Color"].InnerText);
if (node.Attributes["Effect"] != null)
ss.CurrentDCinemaFontEffect = node.Attributes["Effect"].InnerText;
if (node.Attributes["EffectColor"] != null)
ss.CurrentDCinemaFontEffectColor = System.Drawing.ColorTranslator.FromHtml("#" + node.Attributes["EffectColor"].InnerText);
}
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.Message);
}
foreach (XmlNode node in xml.DocumentElement.SelectNodes("//Subtitle"))
{
try
{
StringBuilder pText = new StringBuilder();
string lastVPosition = string.Empty;
foreach (XmlNode innerNode in node.ChildNodes)
{
switch (innerNode.Name.ToString())
{
case "Text":
if (innerNode.Attributes["Vposition"] != null)
{
string vPosition = innerNode.Attributes["Vposition"].InnerText;
if (vPosition != lastVPosition)
{
if (pText.Length > 0 && lastVPosition.Length > 0)
pText.AppendLine();
lastVPosition = vPosition;
}
}
bool alignLeft = false;
bool alignRight = false;
bool alignVTop = false;
bool alignVCenter = false;
if (innerNode.Attributes["Halign"] != null)
{
string hAlign = innerNode.Attributes["Halign"].InnerText;
if (hAlign == "left")
alignLeft = true;
else if (hAlign == "right")
alignRight = true;
}
if (innerNode.Attributes["Valign"] != null)
{
string hAlign = innerNode.Attributes["Valign"].InnerText;
if (hAlign == "top")
alignVTop = true;
else if (hAlign == "center")
alignVCenter = true;
}
if (alignLeft || alignRight || alignVCenter || alignVTop)
{
if (!pText.ToString().StartsWith("{\\an"))
{
string pre = string.Empty;
if (alignVTop)
{
if (alignLeft)
pre = "{\\an7}";
else if (alignRight)
pre = "{\\an9}";
else
pre = "{\\an8}";
}
else if (alignVCenter)
{
if (alignLeft)
pre = "{\\an4}";
else if (alignRight)
pre = "{\\an6}";
else
pre = "{\\an5}";
}
else
{
if (alignLeft)
pre = "{\\an1}";
else if (alignRight)
pre = "{\\an3}";
}
string temp = pre + pText.ToString();
pText = new StringBuilder();
pText.Append(temp);
}
}
if (innerNode.ChildNodes.Count == 0)
{
pText.Append(innerNode.InnerText);
}
else
{
foreach (XmlNode innerInnerNode in innerNode)
{
if (innerInnerNode.Name == "Font" && innerInnerNode.Attributes["Italic"] != null &&
innerInnerNode.Attributes["Italic"].InnerText.ToLower() == "yes")
{
if (innerInnerNode.Attributes["Color"] != null)
pText.Append("<i><font color=\"" + GetColorStringFromDCinema(innerInnerNode.Attributes["Color"].Value) + "\">" + innerInnerNode.InnerText + "</font><i>");
else
pText.Append("<i>" + innerInnerNode.InnerText + "</i>");
}
else if (innerInnerNode.Name == "Font" && innerInnerNode.Attributes["Color"] != null)
{
if (innerInnerNode.Attributes["Italic"] != null && innerInnerNode.Attributes["Italic"].InnerText.ToLower() == "yes")
pText.Append("<i><font color=\"" + GetColorStringFromDCinema(innerInnerNode.Attributes["Color"].Value) + "\">" + innerInnerNode.InnerText + "</font><i>");
else
pText.Append("<font color=\"" + GetColorStringFromDCinema(innerInnerNode.Attributes["Color"].Value) + "\">" + innerInnerNode.InnerText + "</font>");
}
else
{
pText.Append(innerInnerNode.InnerText);
}
}
}
break;
default:
pText.Append(innerNode.InnerText);
break;
}
}
string start = node.Attributes["TimeIn"].InnerText;
string end = node.Attributes["TimeOut"].InnerText;
if (node.ParentNode.Name == "Font" && node.ParentNode.Attributes["Italic"] != null && node.ParentNode.Attributes["Italic"].InnerText.ToLower() == "yes" &&
!pText.ToString().Contains("<i>"))
{
string text = pText.ToString();
if (text.StartsWith("{\\an") && text.Length > 6)
text = text.Insert(6, "<i>") + "</i>";
else
text = "<i>" + text + "</i>";
pText = new StringBuilder(text);
}
subtitle.Paragraphs.Add(new Paragraph(GetTimeCode(start), GetTimeCode(end), pText.ToString()));
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
_errorCount++;
}
}
if (subtitle.Paragraphs.Count > 0)
subtitle.Header = xml.OuterXml; // save id/language/font for later use
subtitle.Renumber(1);
}
private string GetColorStringForDCinema(string p)
{
string s = p.ToUpper().Trim();
if (s.Replace("#", string.Empty).
Replace("0", string.Empty).
Replace("1", string.Empty).
Replace("2", string.Empty).
Replace("3", string.Empty).
Replace("4", string.Empty).
Replace("5", string.Empty).
Replace("6", string.Empty).
Replace("7", string.Empty).
Replace("8", string.Empty).
Replace("9", string.Empty).
Replace("A", string.Empty).
Replace("B", string.Empty).
Replace("C", string.Empty).
Replace("D", string.Empty).
Replace("E", string.Empty).
Replace("F", string.Empty).Length == 0)
{
return s.TrimStart('#');
}
else
{
return p;
}
}
private string GetColorStringFromDCinema(string p)
{
string s = p.ToLower().Trim();
if (s.Replace("#", string.Empty).
Replace("0", string.Empty).
Replace("1", string.Empty).
Replace("2", string.Empty).
Replace("3", string.Empty).
Replace("4", string.Empty).
Replace("5", string.Empty).
Replace("6", string.Empty).
Replace("7", string.Empty).
Replace("8", string.Empty).
Replace("9", string.Empty).
Replace("a", string.Empty).
Replace("b", string.Empty).
Replace("c", string.Empty).
Replace("d", string.Empty).
Replace("e", string.Empty).
Replace("f", string.Empty).Length == 0)
{
if (s.StartsWith("#"))
return s;
else
return "#" + s;
}
else
{
return p;
}
}
private TimeCode GetTimeCode(string s)
{
string[] parts = s.Split(new char[] { ':', '.', ',' });
int milliseconds = (int)System.Math.Round(int.Parse(parts[3]) * (1000.0 / frameRate));
if (milliseconds > 999)
milliseconds = 999;
var ts = new TimeSpan(0, int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), milliseconds);
return new TimeCode(ts);
}
private string ConvertToTimeString(TimeCode time)
{
int frames = (int)System.Math.Round(time.Milliseconds / (1000.0 / frameRate));
return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, frames);
}
}
}

View File

@ -43,7 +43,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
new Csv(), new Csv(),
new Csv2(), new Csv2(),
new DCSubtitle(), new DCSubtitle(),
new DCinemaSmpte(), new DCinemaSmpte2010(),
new DCinemaSmpte2007(),
new DigiBeta(), new DigiBeta(),
new DvdStudioPro(), new DvdStudioPro(),
new DvdStudioProSpace(), new DvdStudioProSpace(),

View File

@ -1,4 +1,8 @@
using System; using Nikse.SubtitleEdit.Controls;
using Nikse.SubtitleEdit.Forms;
using Nikse.SubtitleEdit.Logic.SubtitleFormats;
using Nikse.SubtitleEdit.Logic.VideoPlayers;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Globalization; using System.Globalization;
@ -9,10 +13,6 @@ using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
using Nikse.SubtitleEdit.Controls;
using Nikse.SubtitleEdit.Forms;
using Nikse.SubtitleEdit.Logic.SubtitleFormats;
using Nikse.SubtitleEdit.Logic.VideoPlayers;
namespace Nikse.SubtitleEdit.Logic namespace Nikse.SubtitleEdit.Logic
{ {
@ -209,6 +209,27 @@ namespace Nikse.SubtitleEdit.Logic
} }
} }
public static int GetSubtitleIndex(List<Paragraph> paragraphs, VideoPlayerContainer videoPlayerContainer)
{
if (videoPlayerContainer.VideoPlayer != null)
{
double positionInMilliseconds = (videoPlayerContainer.VideoPlayer.CurrentPosition * 1000.0) + 5;
for (int i = 0; i < paragraphs.Count; i++)
{
var p = paragraphs[i];
if (p.StartTime.TotalMilliseconds <= positionInMilliseconds && p.EndTime.TotalMilliseconds > positionInMilliseconds)
{
bool isInfo = p == paragraphs[0] && (p.StartTime.TotalMilliseconds == 0 && p.Duration.TotalMilliseconds == 0 || p.StartTime.TotalMilliseconds == Pac.PacNullTime.TotalMilliseconds);
if (!isInfo)
return i;
}
}
if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText))
videoPlayerContainer.SetSubtitleText(string.Empty, null);
}
return -1;
}
public static int ShowSubtitle(List<Paragraph> paragraphs, VideoPlayerContainer videoPlayerContainer) public static int ShowSubtitle(List<Paragraph> paragraphs, VideoPlayerContainer videoPlayerContainer)
{ {
if (videoPlayerContainer.VideoPlayer != null) if (videoPlayerContainer.VideoPlayer != null)
@ -221,19 +242,14 @@ namespace Nikse.SubtitleEdit.Logic
p.EndTime.TotalMilliseconds > positionInMilliseconds) p.EndTime.TotalMilliseconds > positionInMilliseconds)
{ {
string text = p.Text.Replace("|", Environment.NewLine); string text = p.Text.Replace("|", Environment.NewLine);
bool isInfo = p == paragraphs[0] && ((p.StartTime.TotalMilliseconds == 0 && p.Duration.TotalMilliseconds == 0) || p.StartTime.TotalMilliseconds == Pac.PacNullTime.TotalMilliseconds); bool isInfo = p == paragraphs[0] && (p.StartTime.TotalMilliseconds == 0 && p.Duration.TotalMilliseconds == 0 || p.StartTime.TotalMilliseconds == Pac.PacNullTime.TotalMilliseconds);
if (!isInfo) if (!isInfo)
{ {
if (videoPlayerContainer.LastParagraph != p) if (videoPlayerContainer.LastParagraph != p)
{
videoPlayerContainer.SetSubtitleText(text, p); videoPlayerContainer.SetSubtitleText(text, p);
return i;
}
else if (videoPlayerContainer.SubtitleText != text) else if (videoPlayerContainer.SubtitleText != text)
{
videoPlayerContainer.SetSubtitleText(text, p); videoPlayerContainer.SetSubtitleText(text, p);
} return i;
return -1;
} }
} }
} }
@ -249,8 +265,9 @@ namespace Nikse.SubtitleEdit.Logic
if (videoPlayerContainer.VideoPlayer != null) if (videoPlayerContainer.VideoPlayer != null)
{ {
double positionInMilliseconds = (videoPlayerContainer.VideoPlayer.CurrentPosition * 1000.0) + 15; double positionInMilliseconds = (videoPlayerContainer.VideoPlayer.CurrentPosition * 1000.0) + 15;
foreach (Paragraph p in paragraphs) for (int i = 0; i < paragraphs.Count; i++)
{ {
var p = paragraphs[i];
if (p.StartTime.TotalMilliseconds <= positionInMilliseconds && if (p.StartTime.TotalMilliseconds <= positionInMilliseconds &&
p.EndTime.TotalMilliseconds > positionInMilliseconds) p.EndTime.TotalMilliseconds > positionInMilliseconds)
{ {
@ -264,18 +281,12 @@ namespace Nikse.SubtitleEdit.Logic
if (!isInfo) if (!isInfo)
{ {
if (videoPlayerContainer.LastParagraph != p) if (videoPlayerContainer.LastParagraph != p)
{
videoPlayerContainer.SetSubtitleText(text, p); videoPlayerContainer.SetSubtitleText(text, p);
return index;
}
else if (videoPlayerContainer.SubtitleText != text) else if (videoPlayerContainer.SubtitleText != text)
{
videoPlayerContainer.SetSubtitleText(text, p); videoPlayerContainer.SetSubtitleText(text, p);
} return i;
return -1;
} }
} }
index++;
} }
} }
if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText)) if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText))

Binary file not shown.

View File

@ -0,0 +1,334 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace="http://www.smpte-ra.org/schemas/428-7/2010/DCST"
xmlns:dcst="http://www.smpte-ra.org/schemas/428-7/2010/DCST"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- SubtitleReel -->
<xs:element name="SubtitleReel" type="dcst:SubtitleReelType"/>
<xs:complexType name="SubtitleReelType">
<xs:sequence>
<xs:element name="Id" type="dcst:UUID"/>
<xs:element name="ContentTitleText" type="dcst:UserText"/>
<xs:element name="AnnotationText" type="dcst:UserText" minOccurs="0"/>
<xs:element name="IssueDate" type="xs:dateTime"/>
<xs:element name="ReelNumber" type="xs:positiveInteger" minOccurs="0"/>
<xs:element name="Language" type="xs:language" minOccurs="0"/>
<xs:element name="EditRate" type="dcst:RationalType"/>
<xs:element name="TimeCodeRate" type="xs:positiveInteger"/>
<xs:element name="StartTime" type="dcst:TimeCodeType" minOccurs="0"/>
<xs:element name="DisplayType" type="dcst:scopedTokenType" minOccurs="0"/>
<xs:element name="LoadFont" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attribute name="ID" type="xs:string" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="SubtitleList">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Subtitle" type="dcst:SubtitleType"/>
<xs:element name="Font">
<xs:complexType mixed="true">
<xs:complexContent mixed="true">
<xs:extension base="dcst:FontType">
<xs:sequence>
<xs:element name="Subtitle" type="dcst:SubtitleType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<!-- Subtitle -->
<xs:complexType name="SubtitleType">
<xs:choice maxOccurs="unbounded">
<xs:element name="Text" type="dcst:TextType"/>
<xs:element name="Image" type="dcst:ImageType"/>
<xs:element name="Font">
<xs:complexType mixed="true">
<xs:complexContent mixed="true">
<xs:extension base="dcst:FontType">
<xs:sequence>
<xs:element name="Text" type="dcst:TextType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="SpotNumber" type="xs:string" use="optional"/>
<xs:attribute name="TimeIn" type="dcst:TimeCodeType" use="required"/>
<xs:attribute name="TimeOut" type="dcst:TimeCodeType" use="required"/>
<xs:attribute name="FadeUpTime" type="dcst:TimeCodeType" use="optional"/>
<xs:attribute name="FadeDownTime" type="dcst:TimeCodeType" use="optional"/>
</xs:complexType>
<!-- Image -->
<xs:complexType name="ImageType" mixed="false">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attribute name="Halign" use="optional" default="center">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="center"/>
<xs:enumeration value="left"/>
<xs:enumeration value="right"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Hposition" use="optional" default="0">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="-100"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Valign" use="optional" default="center">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="center"/>
<xs:enumeration value="bottom"/>
<xs:enumeration value="top"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Vposition" use="optional" default="0">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="-100"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- Font -->
<xs:complexType name="FontType" mixed="true">
<xs:attribute name="Script" use="optional" default="normal">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="normal"/>
<xs:enumeration value="super"/>
<xs:enumeration value="sub"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Effect" use="optional" default="none">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="none"/>
<xs:enumeration value="border"/>
<xs:enumeration value="shadow"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Italic" use="optional" default="no">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Underline" use="optional" default="no">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Weight" use="optional" default="normal">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="bold"/>
<xs:enumeration value="normal"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="ID" type="xs:string" use="optional"/>
<xs:attribute name="Color" use="optional">
<xs:simpleType>
<xs:restriction base="xs:hexBinary">
<xs:length value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="EffectColor" use="optional">
<xs:simpleType>
<xs:restriction base="xs:hexBinary">
<xs:length value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Size" use="optional" default="42">
<xs:simpleType>
<xs:restriction base="xs:positiveInteger"/>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="AspectAdjust" use="optional" type="xs:decimal" default="1.0" />
<xs:attribute name="Spacing" use="optional" type="xs:decimal" default="1.0" />
</xs:complexType>
<!-- Text -->
<xs:complexType name="TextType" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Font" type="dcst:FontType"/>
<xs:element name="Ruby" type="dcst:RubyType"/>
<xs:element name="Space" type="dcst:SpaceType"/>
<xs:element name="HGroup" type="xs:string"/>
<xs:element name="Rotate" type="dcst:RotateType"/>
</xs:choice>
<xs:attribute name="Halign" use="optional" default="center">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="center"/>
<xs:enumeration value="left"/>
<xs:enumeration value="right"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Hposition" use="optional" default="0">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="-100"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Valign" use="optional" default="center">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="center"/>
<xs:enumeration value="bottom"/>
<xs:enumeration value="top"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Vposition" use="optional" default="0">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="-100"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Direction" use="optional" default="ltr">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="ltr"/>
<xs:enumeration value="rtl"/>
<xs:enumeration value="ttb"/>
<xs:enumeration value="btt"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<!-- Rational Type -->
<xs:simpleType name="RationalType">
<xs:restriction>
<xs:simpleType>
<xs:list itemType="xs:long"/>
</xs:simpleType>
<xs:length value="2"/>
</xs:restriction>
</xs:simpleType>
<!-- TimeCode Type -->
<xs:simpleType name="TimeCodeType">
<xs:restriction base="xs:string">
<xs:pattern value="[0-2][0-9]:[0-5][0-9]:[0-5][0-9]:[0-2][0-9]"/>
</xs:restriction>
</xs:simpleType>
<!-- Ruby Type -->
<xs:complexType name="RubyType">
<xs:sequence>
<xs:element name="Rb" type="xs:string"/>
<xs:element name="Rt">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Size" type="xs:decimal" use="optional" default="0.5"/>
<xs:attribute name="Position" use="optional" default="before">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="before"/>
<xs:enumeration value="after"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Spacing" type="xs:decimal" use="optional" default="0.5"/>
<xs:attribute name="Offset" type="xs:decimal" use="optional" default="0.5"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<!-- Rotate Type -->
<xs:complexType name="RotateType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Direction" use="optional" default="none">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="none"/>
<xs:enumeration value="left"/>
<xs:enumeration value="right"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- Space Type -->
<xs:complexType name="SpaceType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Size" type="xs:decimal" use="optional" default="1.0"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- UUID Type -->
<xs:simpleType name="UUID">
<xs:restriction base="xs:anyURI">
<xs:pattern value="urn:uuid:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"/>
</xs:restriction>
</xs:simpleType>
<!-- UserText Type -->
<xs:complexType name="UserText">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="language" type="xs:language" use="optional" default="en"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- Scoped Token Type -->
<xs:complexType name="scopedTokenType">
<xs:simpleContent>
<xs:extension base="xs:token">
<xs:attribute name="scope" type="xs:anyURI" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>

Binary file not shown.

View File

@ -861,6 +861,7 @@
<Compile Include="Logic\SubtitleFormats\CaraokeXml.cs" /> <Compile Include="Logic\SubtitleFormats\CaraokeXml.cs" />
<Compile Include="Logic\SubtitleFormats\Cavena890.cs" /> <Compile Include="Logic\SubtitleFormats\Cavena890.cs" />
<Compile Include="Logic\SubtitleFormats\CheetahCaption.cs" /> <Compile Include="Logic\SubtitleFormats\CheetahCaption.cs" />
<Compile Include="Logic\SubtitleFormats\DCinemaSmpte2007.cs" />
<Compile Include="Logic\SubtitleFormats\FinalCutProImage.cs" /> <Compile Include="Logic\SubtitleFormats\FinalCutProImage.cs" />
<Compile Include="Logic\SubtitleFormats\ELRStudioClosedCaption.cs" /> <Compile Include="Logic\SubtitleFormats\ELRStudioClosedCaption.cs" />
<Compile Include="Logic\SubtitleFormats\ScenaristClosedCaptionsDropFrame.cs" /> <Compile Include="Logic\SubtitleFormats\ScenaristClosedCaptionsDropFrame.cs" />
@ -892,7 +893,7 @@
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle54.cs" /> <Compile Include="Logic\SubtitleFormats\UnknownSubtitle54.cs" />
<Compile Include="Logic\SubtitleFormats\FinalCutProTest2Xml.cs" /> <Compile Include="Logic\SubtitleFormats\FinalCutProTest2Xml.cs" />
<Compile Include="Logic\SubtitleFormats\JsonType4.cs" /> <Compile Include="Logic\SubtitleFormats\JsonType4.cs" />
<Compile Include="Logic\SubtitleFormats\DCinemaSmpte.cs" /> <Compile Include="Logic\SubtitleFormats\DCinemaSmpte2010.cs" />
<Compile Include="Logic\SubtitleFormats\DCSubtitle.cs" /> <Compile Include="Logic\SubtitleFormats\DCSubtitle.cs" />
<Compile Include="Logic\SubtitleFormats\DvdStudioProSpace.cs" /> <Compile Include="Logic\SubtitleFormats\DvdStudioProSpace.cs" />
<Compile Include="Logic\SubtitleFormats\Eeg708.cs" /> <Compile Include="Logic\SubtitleFormats\Eeg708.cs" />
@ -1465,9 +1466,14 @@
<EmbeddedResource Include="Resources\HunspellDictionaries.xml.zip" /> <EmbeddedResource Include="Resources\HunspellDictionaries.xml.zip" />
<EmbeddedResource Include="Resources\TesseractDictionaries.xml.zip" /> <EmbeddedResource Include="Resources\TesseractDictionaries.xml.zip" />
<EmbeddedResource Include="Resources\nOCR_TesseractHelper.xml.zip" /> <EmbeddedResource Include="Resources\nOCR_TesseractHelper.xml.zip" />
<EmbeddedResource Include="Resources\SMPTE-428-7-2007-DCST.xsd"> <None Include="Resources\SMPTE-428-7-2007-DCST.xsd">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </None>
<EmbeddedResource Include="Resources\SMPTE-428-7-2007-DCST.xsd.gz" />
<None Include="Resources\SMPTE-428-7-2010-DCST.xsd">
<SubType>Designer</SubType>
</None>
<EmbeddedResource Include="Resources\SMPTE-428-7-2010-DCST.xsd.gz" />
<None Include="Web References\MicrosoftTranslationService\GetTranslationsResponse.datasource"> <None Include="Web References\MicrosoftTranslationService\GetTranslationsResponse.datasource">
<DependentUpon>Reference.map</DependentUpon> <DependentUpon>Reference.map</DependentUpon>
</None> </None>

View File

@ -375,7 +375,7 @@ Dialogue: Marked=0,0:00:01.00,0:00:03.00,Default,NTP,0000,0000,0000,!Effect," +
[DeploymentItem("SubtitleEdit.exe")] [DeploymentItem("SubtitleEdit.exe")]
public void DcinemaSmpteItalic() public void DcinemaSmpteItalic()
{ {
var target = new DCinemaSmpte(); var target = new DCinemaSmpte2010();
var subtitle = new Subtitle(); var subtitle = new Subtitle();
subtitle.Paragraphs.Add(new Paragraph("<i>Italic</i>", 1000, 5000)); subtitle.Paragraphs.Add(new Paragraph("<i>Italic</i>", 1000, 5000));
string text = target.ToText(subtitle, "title"); string text = target.ToText(subtitle, "title");
@ -386,7 +386,7 @@ Dialogue: Marked=0,0:00:01.00,0:00:03.00,Default,NTP,0000,0000,0000,!Effect," +
[DeploymentItem("SubtitleEdit.exe")] [DeploymentItem("SubtitleEdit.exe")]
public void DcinemaSmpteColorAndItalic() public void DcinemaSmpteColorAndItalic()
{ {
var target = new DCinemaSmpte(); var target = new DCinemaSmpte2010();
var subtitle = new Subtitle(); var subtitle = new Subtitle();
subtitle.Paragraphs.Add(new Paragraph("<font color=\"#ff0000\"><i>Red</i></font>", 1000, 5000)); subtitle.Paragraphs.Add(new Paragraph("<font color=\"#ff0000\"><i>Red</i></font>", 1000, 5000));
string text = target.ToText(subtitle, "title"); string text = target.ToText(subtitle, "title");