当前位置: 首页>>代码示例>>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;未经允许,请勿转载。