Ejemplo n.º 1
0
        private bool InitializeSubIdx(string vobSubFileName)
        {
            var vobSubParser = new VobSubParser(true);
            string idxFileName = Path.ChangeExtension(vobSubFileName, ".idx");
            vobSubParser.OpenSubIdx(vobSubFileName, idxFileName);
            _vobSubMergedPackist = vobSubParser.MergeVobSubPacks();
            _palette = vobSubParser.IdxPalette;
            vobSubParser.VobSubPacks.Clear();

            var languageStreamIds = new List<int>();
            foreach (var pack in _vobSubMergedPackist)
            {
                if (pack.SubPicture.Delay.TotalMilliseconds > 500 && !languageStreamIds.Contains(pack.StreamId))
                    languageStreamIds.Add(pack.StreamId);
            }
            if (languageStreamIds.Count > 1)
            {
                using (var chooseLanguage = new DvdSubRipChooseLanguage())
                {
                    if (ShowInTaskbar)
                    {
                        chooseLanguage.Icon = (Icon)Icon.Clone();
                        chooseLanguage.ShowInTaskbar = true;
                        chooseLanguage.ShowIcon = true;
                    }
                    chooseLanguage.Initialize(_vobSubMergedPackist, _palette, vobSubParser.IdxLanguages, string.Empty);
                    Form form = _main;
                    if (form == null)
                        form = this;
                    chooseLanguage.Activate();
                    if (chooseLanguage.ShowDialog(form) == DialogResult.OK)
                    {
                        _vobSubMergedPackist = chooseLanguage.SelectedVobSubMergedPacks;
                        SetTesseractLanguageFromLanguageString(chooseLanguage.SelectedLanguageString);
                        _importLanguageString = chooseLanguage.SelectedLanguageString;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            return true;
        }