當前位置: 首頁>>代碼示例>>C#>>正文


C# Subtitle.GetAllTexts方法代碼示例

本文整理匯總了C#中Nikse.SubtitleEdit.Core.Subtitle.GetAllTexts方法的典型用法代碼示例。如果您正苦於以下問題:C# Subtitle.GetAllTexts方法的具體用法?C# Subtitle.GetAllTexts怎麽用?C# Subtitle.GetAllTexts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nikse.SubtitleEdit.Core.Subtitle的用法示例。


在下文中一共展示了Subtitle.GetAllTexts方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Initialize

        internal void Initialize(Subtitle subtitle, int firstSelectedIndex)
        {
            var watermark = ReadWaterMark(subtitle.GetAllTexts().Trim());
            labelWatermark.Text = string.Format(_language.WatermarkX, watermark);
            if (watermark.Length == 0)
            {
                buttonRemove.Enabled = false;
                textBoxWatermark.Focus();
            }
            else
            {
                groupBoxGenerate.Enabled = false;
                buttonOK.Focus();
            }

            _firstSelectedIndex = firstSelectedIndex;
            var current = subtitle.GetParagraphOrDefault(_firstSelectedIndex);
            if (current != null)
            {
                radioButtonCurrentLine.Text = string.Format(_language.CurrentLineOnlyX, current.Text.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString));
            }
            else
            {
                radioButtonCurrentLine.Text = string.Format(_language.CurrentLineOnlyX, string.Empty);
                radioButtonCurrentLine.Enabled = false;
            }
        }
開發者ID:LeonCheung,項目名稱:subtitleedit,代碼行數:27,代碼來源:Watermark.cs

示例2: AutoDetectLanguageName

        public static string AutoDetectLanguageName(string languageName, Subtitle subtitle)
        {
            if (string.IsNullOrEmpty(languageName))
                languageName = "en_US";
            int bestCount = subtitle.Paragraphs.Count / 14;

            string text = subtitle.GetAllTexts();
            List<string> dictionaryNames = Utilities.GetDictionaryLanguages();

            bool containsEnGb = false;
            bool containsEnUs = false;
            bool containsHrHr = false;
            bool containsSrLatn = false;
            foreach (string name in dictionaryNames)
            {
                if (name.Contains("[en_GB]"))
                    containsEnGb = true;
                if (name.Contains("[en_US]"))
                    containsEnUs = true;
                if (name.Contains("[hr_HR]"))
                    containsHrHr = true;
                if (name.Contains("[sr-Latn]"))
                    containsSrLatn = true;
            }

            foreach (string name in dictionaryNames)
            {
                string shortName = string.Empty;
                int start = name.IndexOf('[');
                int end = name.IndexOf(']');
                if (start > 0 && end > start)
                {
                    start++;
                    shortName = name.Substring(start, end - start);
                }

                int count;
                switch (shortName)
                {
                    case "da_DK":
                        count = GetCount(text, AutoDetectWordsDanish);
                        if (count > bestCount)
                        {
                            int norwegianCount = GetCount(text, "ut", "deg", "meg", "merkelig", "mye", "spørre");
                            int dutchCount = GetCount(text, AutoDetectWordsDutch);
                            if (norwegianCount < 2 && dutchCount < count)
                                languageName = shortName;
                        }
                        break;
                    case "nb_NO":
                        count = GetCount(text, AutoDetectWordsNorwegian);
                        if (count > bestCount)
                        {
                            int danishCount = GetCount(text, "siger", "dig", "mig", "mærkelig", "tilbage", "spørge");
                            int dutchCount = GetCount(text, AutoDetectWordsDutch);
                            if (danishCount < 2 && dutchCount < count)
                                languageName = shortName;
                        }
                        break;
                    case "sv_SE":
                        count = GetCount(text, AutoDetectWordsSwedish);
                        if (count > bestCount)
                            languageName = shortName;
                        break;
                    case "en_US":
                        count = GetCount(text, AutoDetectWordsEnglish);
                        if (count > bestCount)
                        {
                            int dutchCount = GetCount(text, AutoDetectWordsDutch);
                            if (dutchCount < count)
                            {
                                languageName = shortName;
                                if (containsEnGb)
                                {
                                    int usCount = GetCount(text, "color", "flavor", "honor", "humor", "neighbor", "honor");
                                    int gbCount = GetCount(text, "colour", "flavour", "honour", "humour", "neighbour", "honour");
                                    if (gbCount > usCount)
                                        languageName = "en_GB";
                                }
                            }
                        }
                        break;
                    case "en_GB":
                        count = GetCount(text, AutoDetectWordsEnglish);
                        if (count > bestCount)
                        {
                            int dutchCount = GetCount(text, AutoDetectWordsDutch);
                            if (dutchCount < count)
                            {
                                languageName = shortName;
                                if (containsEnUs)
                                {
                                    int usCount = GetCount(text, "color", "flavor", "honor", "humor", "neighbor", "honor");
                                    int gbCount = GetCount(text, "colour", "flavour", "honour", "humour", "neighbour", "honour");
                                    if (gbCount < usCount)
                                        languageName = "en_US";
                                }
                            }
                        }
                        break;
//.........這裏部分代碼省略.........
開發者ID:mgziminsky,項目名稱:subtitleedit,代碼行數:101,代碼來源:LanguageAutoDetect.cs

示例3: AutoDetectGoogleLanguageOrNull

        public static string AutoDetectGoogleLanguageOrNull(Subtitle subtitle)
        {
            string languageId = AutoDetectGoogleLanguage(subtitle.GetAllTexts(), subtitle.Paragraphs.Count / 14);
            if (string.IsNullOrEmpty(languageId))
                languageId = null;

            return languageId;
        }
開發者ID:mgziminsky,項目名稱:subtitleedit,代碼行數:8,代碼來源:LanguageAutoDetect.cs


注:本文中的Nikse.SubtitleEdit.Core.Subtitle.GetAllTexts方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。