private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { AssStyleOptionsList.SaveToFile( _styleOptions.Where(p => !_builtinStyleNames.Contains(p.Key)) .Select(p => p.Value) ); }
private static IEnumerable GetForwardConversionTestCases() { List <AssStyleOptions> options = AssStyleOptionsList.LoadFromFile(Path.Combine(DllFolderPath, "StyleOptions.xml")); foreach (string assFilePath in Directory.EnumerateFiles(Path.Combine(DllFolderPath, "Files"), "*.ass")) { string name = Path.GetFileNameWithoutExtension(assFilePath); string yttFilePath = Path.ChangeExtension(assFilePath, ".ytt"); yield return(new TestCaseData(assFilePath, options, yttFilePath).SetName(name)); } }
private static IEnumerable GetTestCases() { string baseFolderPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath); List <AssStyleOptions> options = AssStyleOptionsList.Load(Path.Combine(baseFolderPath, "StyleOptions.xml")); foreach (string assFilePath in Directory.EnumerateFiles(Path.Combine(baseFolderPath, "Files"), "*.ass")) { string name = Path.GetFileNameWithoutExtension(assFilePath); string yttFilePath = Path.ChangeExtension(assFilePath, ".ytt"); yield return(new TestCaseData(assFilePath, options, yttFilePath).SetName(name)); } }
public AssDocument(SubtitleDocument doc) : this(new MemoryStream(Resources.DefaultStyles), AssStyleOptionsList.LoadFromString(Resources.DefaultStyleOptions)) { float sizeFactor = (float)doc.VideoDimensions.Height / VideoDimensions.Height; foreach (AssStyle style in _styles.Values) { style.LineHeight *= sizeFactor; } VideoDimensions = doc.VideoDimensions; Lines.Clear(); Lines.AddRange(doc.Lines.Select(l => l as AssLine ?? new AssLine(l))); }
public MainForm() { InitializeComponent(); _windowsScaleFactor = AutoScaleDimensions.Height / 12; LocalizeUI(); List <AssStyleOptions> builtinStyleOptions = AssStyleOptionsList.LoadFromString(YTSubConverter.Resources.DefaultStyleOptions); List <AssStyleOptions> customStyleOptions = AssStyleOptionsList.LoadFromFile(); _styleOptions = customStyleOptions.Concat(builtinStyleOptions).ToDictionaryOverwrite(o => o.Name); _builtinStyleNames = builtinStyleOptions.Select(o => o.Name).ToHashSet(); ExpandCollapseStyleOptions(); ClearUi(); }
public static SubtitleDocument Load(string filePath) { switch (Path.GetExtension(filePath)?.ToLower()) { case ".ass": return(new AssDocument(filePath, AssStyleOptionsList.LoadFromFile().Concat(AssStyleOptionsList.LoadFromString(Resources.DefaultStyleOptions)).ToList())); case ".sbv": return(new SbvDocument(filePath)); case ".srt": return(new SrtDocument(filePath)); case ".srv3": case ".ytt": return(new YttDocument(filePath)); default: throw new NotSupportedException(); } }
public void TestReverseConversion(string inputYttFilePath) { SubtitleDocument yttDoc = new YttDocument(inputYttFilePath); SubtitleDocument assDoc = new AssDocument(yttDoc); try { assDoc.Save("actual.ass"); assDoc = new AssDocument("actual.ass", AssStyleOptionsList.LoadFromString(Resources.DefaultStyleOptions)); yttDoc = new YttDocument(assDoc); yttDoc.Save("actual.ytt"); string actual = File.ReadAllText("actual.ytt"); string expected = RoundYttTimestamps(File.ReadAllText(inputYttFilePath)); Assert.That(actual, Is.EqualTo(expected)); } finally { File.Delete("actual.ass"); File.Delete("actual.ytt"); } }