using System; using System.Collections.Generic; using System.Text; using System.Xml; namespace Nikse.SubtitleEdit.Core.SubtitleFormats { public class RhozetHarmonic : SubtitleFormat { public override string Extension => ".xml"; public override string Name => "Rhozet Harmonic"; private static string ToTimeCode(TimeCode time) { return time.ToHHMMSSFF(); } public override string ToText(Subtitle subtitle, string title) { // // string xmlStructure = "" + Environment.NewLine + ""; var xml = new XmlDocument(); xml.LoadXml(xmlStructure); XmlNode paragraph = xml.CreateElement("Data"); XmlAttribute charSize = xml.CreateAttribute("CharSize"); charSize.InnerText = HtmlUtil.RemoveHtmlTags("0.2"); paragraph.Attributes.Append(charSize); XmlAttribute posX = xml.CreateAttribute("PosX"); posX.InnerText = "0.5"; paragraph.Attributes.Append(posX); XmlAttribute posY = xml.CreateAttribute("PosY"); posY.InnerText = "0.75"; paragraph.Attributes.Append(posY); XmlAttribute colorR = xml.CreateAttribute("ColorR"); colorR.InnerText = "245"; paragraph.Attributes.Append(colorR); XmlAttribute colorG = xml.CreateAttribute("ColorG"); colorG.InnerText = "245"; paragraph.Attributes.Append(colorG); XmlAttribute colorB = xml.CreateAttribute("ColorB"); colorB.InnerText = "245"; paragraph.Attributes.Append(colorB); XmlAttribute transparency = xml.CreateAttribute("Transparency"); transparency.InnerText = "0.0"; paragraph.Attributes.Append(transparency); XmlAttribute shadowSize = xml.CreateAttribute("ShadowSize"); shadowSize.InnerText = "0.5"; paragraph.Attributes.Append(shadowSize); XmlAttribute bkgEnable = xml.CreateAttribute("BkgEnable"); bkgEnable.InnerText = "1"; paragraph.Attributes.Append(bkgEnable); XmlAttribute bkgExtraWidth = xml.CreateAttribute("BkgExtraWidth"); bkgExtraWidth.InnerText = "0.02"; paragraph.Attributes.Append(bkgExtraWidth); XmlAttribute bkgExtraHeight = xml.CreateAttribute("BkgExtraHeight"); bkgExtraHeight.InnerText = "0.02"; paragraph.Attributes.Append(bkgExtraHeight); xml.DocumentElement.AppendChild(paragraph); foreach (Paragraph p in subtitle.Paragraphs) { paragraph = xml.CreateElement("Data"); XmlAttribute start = xml.CreateAttribute("StartTimecode"); start.InnerText = ToTimeCode(p.StartTime); paragraph.Attributes.Append(start); XmlAttribute end = xml.CreateAttribute("EndTimecode"); end.InnerText = ToTimeCode(p.EndTime); paragraph.Attributes.Append(end); XmlAttribute text = xml.CreateAttribute("Title"); text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); paragraph.Attributes.Append(text); xml.DocumentElement.AppendChild(paragraph); } string s = "" + Environment.NewLine + ToUtf8XmlString(xml, true).Replace("\"", "__@____").Replace("'", "'").Replace("__@____", "'").Replace(" />", "/>"); while (s.Contains(Environment.NewLine + " ")) { s = s.Replace(Environment.NewLine + " ", Environment.NewLine); } return s; } public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) { _errorCount = 0; var sb = new StringBuilder(); lines.ForEach(line => sb.AppendLine(line)); string allText = sb.ToString(); if (!allText.Contains("