Пример #1
0
        protected override IList <Subtitle> GetSubtitles()
        {
            var result   = new List <Subtitle>();
            var module   = ModuleDefMD.Load(Path);
            var usStream = module.USStream;

            using (var ms = new MemoryStream(usStream.CreateReader().ToArray()))
                using (var input = new ExtendedBinaryReader(ms, System.Text.Encoding.Unicode))
                {
                    input.Skip(1);
                    while (input.Position < input.Length)
                    {
                        var offset = input.Position;
                        var length = input.ReadCompressedUInt32();
                        if (length > 0)
                        {
                            var str = System.Text.Encoding.Unicode.GetString(input.ReadBytes((int)length - 1));
                            input.Skip(1);

                            var subtitle = new Subtitle {
                                Text = str, Loaded = str, Translation = str, Offset = offset
                            };
                            subtitle.PropertyChanged += SubtitlePropertyChanged;
                            result.Add(subtitle);
                        }
                    }
                }

            result.Sort();
            LoadChanges(result);

            return(result);
        }