当前位置: 首页>>代码示例>>C#>>正文


C# Subtitle.Renumber方法代码示例

本文整理汇总了C#中Subtitle.Renumber方法的典型用法代码示例。如果您正苦于以下问题:C# Subtitle.Renumber方法的具体用法?C# Subtitle.Renumber怎么用?C# Subtitle.Renumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subtitle的用法示例。


在下文中一共展示了Subtitle.Renumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            _errorCount = 0;
            foreach (string line in lines)
            {
                if (line.Contains(".png") && regexTimeCodes.IsMatch(line))
                {
                    int idx = line.IndexOf("<div");
                    if (idx > 0)
                    {
                        try
                        {
                            var s = line.Replace("&gt;", ">").Substring(0, idx);
                            s = s.Remove(0, s.IndexOf(':') + 1);
                            var arr = s.Split(new char[] { '-', '>' }, StringSplitOptions.RemoveEmptyEntries);
                            var p = new Paragraph();
                            p.StartTime = DecodeTimeCode(arr[0]);
                            p.EndTime = DecodeTimeCode(arr[1]);
                            int start = line.IndexOf("<img src=") + 9;
                            int end = line.IndexOf(".png") + 4;
                            p.Text = (line.Substring(start, end - start)).Trim(new char[] { '"', '\'' });

                            subtitle.Paragraphs.Add(p);
                        }
                        catch
                        {
                            _errorCount++;
                        }
                    }
                }
            }
            subtitle.Renumber();
        }
开发者ID:m1croN,项目名称:subtitleedit,代码行数:33,代码来源:SeImageHtmlIndex.cs

示例2: LoadSubtitle

 public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
 {
     //0001  00:00:19:13 00:00:22:10 a_0001.tif
     var regexTimeCodes = new Regex(@"^\d\d\d\d\t+(\d\d:\d\d:\d\d:\d\d)\t(\d\d:\d\d:\d\d:\d\d)\t.+\.(?:tif|tiff|png|bmp|TIF|TIFF|PNG|BMP)", RegexOptions.Compiled);
     Paragraph p = null;
     subtitle.Paragraphs.Clear();
     _errorCount = 0;
     int index = 0;
     foreach (string line in lines)
     {
         var match = regexTimeCodes.Match(line);
         if (match.Success)
         {
             var start = DecodeTimeCodeFramesFourParts(match.Groups[1].Value.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries));
             var end = DecodeTimeCodeFramesFourParts(match.Groups[2].Value.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries));
             var lastTabIndex = line.LastIndexOf('\t');
             var text = line.Substring(lastTabIndex + 1).Trim();
             p = new Paragraph(start, end, text);
             subtitle.Paragraphs.Add(p);
         }
         else if (index < 10 || string.IsNullOrWhiteSpace(line) || line[0] == '#' || line.StartsWith("Display_Area", StringComparison.Ordinal) || line.StartsWith("Color", StringComparison.Ordinal))
         {
             // skip these lines
         }
         else if (p != null)
         {
             _errorCount++;
         }
         index++;
     }
     subtitle.Renumber();
 }
开发者ID:LeonCheung,项目名称:subtitleedit,代码行数:32,代码来源:Son.cs

示例3: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            //00:01:54:19,00:01:56:17,We should be thankful|they accepted our offer.
            _errorCount = 0;
            subtitle.Paragraphs.Clear();
            foreach (string line in lines)
            {
                if (line.IndexOf(':') == 2 && RegexTimeCodes.IsMatch(line))
                {
                    string start = line.Substring(0, 11);
                    string end = line.Substring(13, 11);

                    try
                    {
                        var startTime = DecodeTimeCodeFramesFourParts(start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries));
                        var endTime = DecodeTimeCodeFramesFourParts(end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries));
                        var p = new Paragraph(startTime, endTime, DecodeText(line.Substring(25).Trim()));
                        subtitle.Paragraphs.Add(p);
                    }
                    catch
                    {
                        _errorCount++;
                    }
                }
                else if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("//", StringComparison.Ordinal) && !line.StartsWith('$'))
                {
                    _errorCount++;
                }
            }
            subtitle.Renumber();
        }
开发者ID:ARASHz4,项目名称:subtitleedit,代码行数:31,代码来源:SpruceWithSpace.cs

示例4: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            _errorCount = 0;

            var sb = new StringBuilder();
            lines.ForEach(line => sb.AppendLine(line));
            var xml = new XmlDocument { XmlResolver = null };
            xml.LoadXml(sb.ToString().Trim());

            XmlNode div = xml.DocumentElement.SelectSingleNode("subtitles");
            foreach (XmlNode node in div.ChildNodes)
            {
                try
                {
                    //<subtitle duration="2256" effect="" end="124581" layer="0" margin-l="0" margin-r="0" margin-v="0" name="" note="" path="0" start="122325" style="Default" text="The fever hath weakened thee." translation="" />
                    var p = new Paragraph { StartTime = { TotalMilliseconds = int.Parse(node.Attributes["start"].Value) } };
                    p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + int.Parse(node.Attributes["duration"].Value);
                    p.Text = node.Attributes["text"].Value;

                    subtitle.Paragraphs.Add(p);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    _errorCount++;
                }
            }
            subtitle.Renumber();
        }
开发者ID:ARASHz4,项目名称:subtitleedit,代码行数:29,代码来源:SubtitleEditorProject.cs

示例5: Initialize

        /// <summary>
        /// The initialize.
        /// </summary>
        /// <param name="subtitle">
        /// The subtitle.
        /// </param>
        public void Initialize(Subtitle subtitle)
        {
            if (subtitle.Paragraphs.Count > 0)
            {
                subtitle.Renumber(subtitle.Paragraphs[0].Number);
            }

            this.Text = Configuration.Settings.Language.MergeDoubleLines.Title;
            this.labelMaxMillisecondsBetweenLines.Text = Configuration.Settings.Language.MergeDoubleLines.MaxMillisecondsBetweenLines;
            this.checkBoxIncludeIncrementing.Text = Configuration.Settings.Language.MergeDoubleLines.IncludeIncrementing;
            this.numericUpDownMaxMillisecondsBetweenLines.Left = this.labelMaxMillisecondsBetweenLines.Left + this.labelMaxMillisecondsBetweenLines.Width + 3;
            this.checkBoxIncludeIncrementing.Left = this.numericUpDownMaxMillisecondsBetweenLines.Left + this.numericUpDownMaxMillisecondsBetweenLines.Width + 10;

            this.listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply;
            this.listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber;
            this.listViewFixes.Columns[2].Text = Configuration.Settings.Language.MergedShortLines.MergedText;

            this.buttonOK.Text = Configuration.Settings.Language.General.Ok;
            this.buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
            this.SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings);
            Utilities.InitializeSubtitleFont(this.SubtitleListview1);
            this.SubtitleListview1.AutoSizeAllColumns(this);
            this.NumberOfMerges = 0;
            this._subtitle = subtitle;
            this.MergeDoubleLines_ResizeEnd(null, null);
        }
开发者ID:KatyaMarincheva,项目名称:SubtitleEditOriginal,代码行数:32,代码来源:MergeDoubleLines.cs

示例6: LoadSubtitle

 public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
 {
     _errorCount = 0;
     subtitle.Paragraphs.Clear();
     foreach (string line in lines)
     {
         var s = line.Trim();
         if (s.Length > 35 && RegexTimeCodes.IsMatch(s))
         {
             try
             {
                 string timePart = s.Substring(4, 10).TrimEnd();
                 var start = DecodeTimeCode(timePart);
                 timePart = s.Substring(15, 10).Trim();
                 var end = DecodeTimeCode(timePart);
                 var paragraph = new Paragraph { StartTime = start, EndTime = end };
                 paragraph.Text = s.Substring(38).Replace(" \\n ", Environment.NewLine).Replace("\\n", Environment.NewLine);
                 subtitle.Paragraphs.Add(paragraph);
             }
             catch
             {
                 _errorCount++;
             }
         }
     }
     subtitle.Renumber();
 }
开发者ID:LeonCheung,项目名称:subtitleedit,代码行数:27,代码来源:ZeroG.cs

示例7: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            //00:03:15.22 00:03:23.10 This is line one.//This is line two.
            _errorCount = 0;
            Paragraph p = null;
            subtitle.Paragraphs.Clear();
            char[] splitChars = { ':', '.' };
            foreach (string line in lines)
            {
                var match = RegexTimeCodes.Match(line);
                if (match.Success)
                {
                    string temp = line.Substring(0, match.Length);
                    if (line.Length >= 23)
                    {
                        string text = line.Remove(0, 23).Trim();
                        if (!text.Contains(Environment.NewLine))
                            text = text.Replace("//", Environment.NewLine);
                        p = new Paragraph(DecodeTimeCodeFrames(temp.Substring(0, 11), splitChars), DecodeTimeCodeFrames(temp.Substring(12, 11), splitChars), text);
                        subtitle.Paragraphs.Add(p);
                    }
                }
                else if (string.IsNullOrWhiteSpace(line))
                {
                }
                else if (p != null)
                {
                    if (p.Text.Length < 200)
                        p.Text = (p.Text + Environment.NewLine + line).Trim();
                }
            }

            subtitle.Renumber();
        }
开发者ID:ARASHz4,项目名称:subtitleedit,代码行数:34,代码来源:UnknownSubtitle57.cs

示例8: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            _errorCount = 0;
            var regexTimeCode = new Regex(@"^E 1 \d:\d\d:\d\d.\d\d \d:\d\d:\d\d.\d\d Default NTP ", RegexOptions.Compiled);
            //E 1 0:50:05.42 0:50:10.06 Default NTP

            subtitle.Paragraphs.Clear();
            foreach (string line in lines)
            {
                if (regexTimeCode.IsMatch(line))
                {
                    try
                    {
                        string timePart = line.Substring(4, 10).Trim();
                        var start = DecodeTimeCode(timePart);
                        timePart = line.Substring(15, 10).Trim();
                        var end = DecodeTimeCode(timePart);
                        var paragraph = new Paragraph();
                        paragraph.StartTime = start;
                        paragraph.EndTime = end;
                        paragraph.Text = line.Substring(38).Replace(" \\n ", Environment.NewLine).Replace("\\n", Environment.NewLine);
                        subtitle.Paragraphs.Add(paragraph);
                    }
                    catch
                    {
                        _errorCount++;
                    }
                }
            }
            subtitle.Renumber();
        }
开发者ID:Team-Vengeance,项目名称:SubtitleEdit,代码行数:31,代码来源:ZeroG.cs

示例9: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            const int startPosition = 0xa99;
            const int textPosition = 72;

            _errorCount = 0;
            subtitle.Paragraphs.Clear();
            subtitle.Header = null;
            var buffer = FileUtil.ReadAllBytesShared(fileName);
            int index = startPosition;
            if (buffer[index] != 1)
            {
                return;
            }

            while (index + textPosition < buffer.Length)
            {
                int textLength = buffer[index + 16];
                if (textLength > 0 && index + textPosition + textLength < buffer.Length)
                {
                    string text = GetText(index + textPosition, textLength, buffer);
                    if (!string.IsNullOrWhiteSpace(text))
                    {
                        int startFrames = GetFrames(index + 4, buffer);
                        int endFrames = GetFrames(index + 8, buffer);
                        subtitle.Paragraphs.Add(new Paragraph(text, FramesToMilliseconds(startFrames), FramesToMilliseconds(endFrames)));
                    }
                }
                index += textPosition + textLength;
            }
            subtitle.Renumber();
        }
开发者ID:ARASHz4,项目名称:subtitleedit,代码行数:32,代码来源:Ayato.cs

示例10: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            //00:03:15:22 00:03:23:10 This is line one.
            //This is line two.
            subtitle.Paragraphs.Clear();
            _errorCount = 0;
            foreach (string line in lines)
            {
                if (RegexTimeCodes.IsMatch(line))
                {
                    string temp = line.Substring(0, RegexTimeCodes.Match(line).Length);
                    string start = temp.Substring(0, 11);
                    string end = temp.Substring(12, 11);

                    string[] startParts = start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries);
                    string[] endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries);
                    if (startParts.Length == 4 && endParts.Length == 4)
                    {
                        string text = line.Remove(0, RegexTimeCodes.Match(line).Length - 1).Trim();
                        text = text.Replace("//", Environment.NewLine);
                        var p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text);
                        subtitle.Paragraphs.Add(p);
                    }
                }
                else
                {
                    _errorCount += 10;
                }
            }

            subtitle.Renumber();
        }
开发者ID:ARASHz4,项目名称:subtitleedit,代码行数:32,代码来源:DvdSubtitleSystem.cs

示例11: LoadSubtitle

 public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
 {
     _errorCount = 0;
     subtitle.Paragraphs.Clear();
     char[] trimChars = { '–', '.', ';', ':' };
     foreach (string line in lines)
     {
         if (RegexTimeCodes.IsMatch(line))
         {
             int splitter = line.IndexOf(':') + 3;
             string text = line.Remove(0, splitter);
             var p = new Paragraph(DecodeTimeCode(line.Substring(0, splitter)), new TimeCode(0, 0, 0, 0), text);
             subtitle.Paragraphs.Add(p);
             text = text.Trim().Trim(trimChars).Trim();
             if (text.Length > 0 && char.IsDigit(text[0]))
                 _errorCount++;
         }
         else
         {
             _errorCount += 2;
         }
     }
     foreach (Paragraph p2 in subtitle.Paragraphs)
     {
         p2.Text = Utilities.AutoBreakLine(p2.Text);
     }
     subtitle.RecalculateDisplayTimes(Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds, null);
     subtitle.Renumber();
 }
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:29,代码来源:YouTubeTranscriptOneLine.cs

示例12: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            //00:01:54:19,00:01:56:17,We should be thankful|they accepted our offer.
            _errorCount = 0;
            subtitle.Paragraphs.Clear();
            var regexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d,\d\d:\d\d:\d\d:\d\d,.+", RegexOptions.Compiled);
            if (fileName != null && fileName.EndsWith(".stl", StringComparison.OrdinalIgnoreCase)) // allow empty text if extension is ".stl"...
                regexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d,\d\d:\d\d:\d\d:\d\d,", RegexOptions.Compiled);
            foreach (string line in lines)
            {
                if (line.IndexOf(':') == 2 && regexTimeCodes.IsMatch(line))
                {
                    string start = line.Substring(0, 11);
                    string end = line.Substring(12, 11);

                    try
                    {
                        Paragraph p = new Paragraph(DecodeTimeCode(start), DecodeTimeCode(end), DecodeText(line.Substring(24)));
                        subtitle.Paragraphs.Add(p);
                    }
                    catch
                    {
                        _errorCount++;
                    }
                }
                else if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("//") && !line.StartsWith('$'))
                {
                    _errorCount++;
                }
            }
            subtitle.Renumber();
        }
开发者ID:ARASHz4,项目名称:subtitleedit,代码行数:32,代码来源:Spruce.cs

示例13: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            var paragraph = new Paragraph();
            _errorCount = 0;

            subtitle.Paragraphs.Clear();
            foreach (string line in lines)
            {
                if (regexTimeCode.IsMatch(line) && line.Length > 24)
                {
                    string[] parts = line.Substring(0, 11).Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length == 4)
                    {
                        try
                        {
                            var start = DecodeTimeCode(parts);
                            parts = line.Substring(12, 11).Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                            var end = DecodeTimeCode(parts);
                            paragraph = new Paragraph();
                            paragraph.StartTime = start;
                            paragraph.EndTime = end;

                            paragraph.Text = line.Substring(24).Trim().Replace("\t", Environment.NewLine);
                            subtitle.Paragraphs.Add(paragraph);
                        }
                        catch
                        {
                            _errorCount++;
                        }
                    }
                }
            }
            subtitle.Renumber(1);
        }
开发者ID:IlgnerBri,项目名称:subtitleedit,代码行数:34,代码来源:DigiBeta.cs

示例14: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            //<Time begin="0:03:24.8" end="0:03:29.4" /><clear/>Man stjæler ikke fra Chavo, nej.
            subtitle.Paragraphs.Clear();
            _errorCount = 0;
            foreach (string line in lines)
            {
                try
                {
                    if (line.Contains("<Time ") && line.Contains(" begin=") && line.Contains("end="))
                    {
                        int indexOfBegin = line.IndexOf(" begin=", StringComparison.Ordinal);
                        int indexOfEnd = line.IndexOf(" end=", StringComparison.Ordinal);
                        string begin = line.Substring(indexOfBegin + 7, 11);
                        string end = line.Substring(indexOfEnd + 5, 11);

                        string[] startParts = begin.Split(new[] { ':', '.', '"' }, StringSplitOptions.RemoveEmptyEntries);
                        string[] endParts = end.Split(new[] { ':', '.', '"' }, StringSplitOptions.RemoveEmptyEntries);
                        if (startParts.Length == 4 && endParts.Length == 4)
                        {
                            string text = line.Substring(line.LastIndexOf("/>", StringComparison.Ordinal) + 2);
                            var p = new Paragraph(DecodeTimeCode(startParts), DecodeTimeCode(endParts), text);
                            subtitle.Paragraphs.Add(p);
                        }
                    }
                }
                catch
                {
                    _errorCount++;
                }
            }

            subtitle.Renumber();
        }
开发者ID:lalberto8085,项目名称:subtitleedit,代码行数:34,代码来源:RealTime.cs

示例15: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            _errorCount = 0;

            var sb = new StringBuilder();
            foreach (string s in lines)
                sb.Append(s);

            string allText = sb.ToString();
            if (!allText.Contains("\"text\""))
                return;

            var startTimes = Json.ReadArray(allText, "start");
            var endTimes = Json.ReadArray(allText, "end");
            var texts = Json.ReadArray(allText, "text");

            for (int i = 0; i < Math.Min(Math.Min(startTimes.Count, texts.Count), endTimes.Count); i++)
            {
                try
                {
                    string text = Json.DecodeJsonText(texts[i]);
                    var p = new Paragraph(text, int.Parse(startTimes[i]), int.Parse(endTimes[i]));
                    subtitle.Paragraphs.Add(p);
                }
                catch
                {
                    _errorCount++;
                }
            }
            subtitle.RemoveEmptyLines();
            subtitle.Renumber();
        }
开发者ID:LeonCheung,项目名称:subtitleedit,代码行数:32,代码来源:JsonType7.cs


注:本文中的Subtitle.Renumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。