예제 #1
0
        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)));
        }
예제 #2
0
        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();
        }
예제 #3
0
        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");
            }
        }
예제 #4
0
        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();
            }
        }