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


C# Paragraph.CalculateTimeCodesFromFrameNumbers方法代码示例

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


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

示例1: InsertAfter

        private void InsertAfter()
        {
            var format = GetCurrentSubtitleFormat();
            bool useExtraForStyle = format.HasStyleSupport;
            var styles = new List<string>();
            if (format.GetType() == typeof(AdvancedSubStationAlpha) || format.GetType() == typeof(SubStationAlpha))
                styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header);
            else if (format.GetType() == typeof(TimedText10) || format.GetType() == typeof(ItunesTimedText))
                styles = TimedText10.GetStylesFromHeader(_subtitle.Header);
            else if (format.GetType() == typeof(Sami) || format.GetType() == typeof(SamiModern))
                styles = Sami.GetStylesFromHeader(_subtitle.Header);
            string style = "Default";
            if (styles.Count > 0)
                style = styles[0];

            MakeHistoryForUndo(_language.BeforeInsertLine);

            int firstSelectedIndex = 0;
            if (SubtitleListview1.SelectedItems.Count > 0)
                firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index + 1;

            var newParagraph = new Paragraph();
            if (useExtraForStyle)
            {
                newParagraph.Extra = style;
                if (format.GetType() == typeof(TimedText10) || format.GetType() == typeof(ItunesTimedText))
                {
                    if (styles.Count > 0)
                        newParagraph.Style = style;
                    newParagraph.Extra = TimedText10.SetExtra(newParagraph);
                }
            }

            Paragraph prev = _subtitle.GetParagraphOrDefault(firstSelectedIndex - 1);
            Paragraph next = _subtitle.GetParagraphOrDefault(firstSelectedIndex);
            if (prev != null)
            {
                int addMilliseconds = Configuration.Settings.General.MininumMillisecondsBetweenLines;
                if (addMilliseconds < 1)
                    addMilliseconds = 1;

                newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + addMilliseconds;
                newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs;
                if (next != null && newParagraph.EndTime.TotalMilliseconds > next.StartTime.TotalMilliseconds)
                    newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
                if (newParagraph.StartTime.TotalMilliseconds > newParagraph.EndTime.TotalMilliseconds)
                    newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1;
            }
            else if (next != null)
            {
                newParagraph.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 2000;
                newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
            }
            else
            {
                newParagraph.StartTime.TotalMilliseconds = 1000;
                newParagraph.EndTime.TotalMilliseconds = 3000;
            }
            if (GetCurrentSubtitleFormat().IsFrameBased)
            {
                newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
                newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
            }

            if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
            {
                _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
                _subtitleAlternate.Renumber(1);
            }

            if (_networkSession != null)
            {
                _networkSession.TimerStop();
                NetworkGetSendUpdates(new List<int>(), firstSelectedIndex, newParagraph);
            }
            else
            {
                _subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph);
                _subtitle.Renumber(1);
                SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
            }
            SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex);
            ShowSource();
            ShowStatus(_language.LineInserted);
        }
开发者ID:IlgnerBri,项目名称:subtitleedit,代码行数:85,代码来源:Main.cs

示例2: SplitSelectedParagraph


//.........这里部分代码省略.........
                            lines = s.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        }

                        if (lines.Length == 1)
                        {
                            string s = Utilities.AutoBreakLine(lines[0], 3, Configuration.Settings.General.SubtitleLineMaximumLength, 20);
                            lines = s.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        }
                        if (lines.Length == 1)
                        {
                            string s = Utilities.AutoBreakLine(lines[0], 3, Convert.ToInt32(Configuration.Settings.General.SubtitleLineMaximumLength * 0.7), 18);
                            lines = s.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        }
                        if (lines.Length == 1)
                        {
                            string s = Utilities.AutoBreakLine(lines[0], 3, Convert.ToInt32(Configuration.Settings.General.SubtitleLineMaximumLength * 0.5), 15);
                            lines = s.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        }
                        if (lines.Length == 2)
                        {
                            string a = lines[0].Trim();
                            string b = lines[1].Trim();
                            if (oldText.TrimStart().StartsWith("<i>") && oldText.TrimEnd().EndsWith("</i>") &&
                                Utilities.CountTagInText(oldText, "<i>") == 1 && Utilities.CountTagInText(oldText, "</i>") == 1)
                            {
                                a = a + "</i>";
                                b = "<i>" + b;
                            }
                            if (oldText.TrimStart().StartsWith("<b>") && oldText.TrimEnd().EndsWith("</b>") &&
                                Utilities.CountTagInText(oldText, "<b>") == 1 && Utilities.CountTagInText(oldText, "</b>") == 1)
                            {
                                a = a + "</b>";
                                b = "<b>" + b;
                            }
                            if (a.StartsWith("-") && (a.EndsWith(".") || a.EndsWith("!") || a.EndsWith("?")) &&
                                b.StartsWith("-") && (b.EndsWith(".") || b.EndsWith("!") || b.EndsWith("?")))
                            {
                                a = a.TrimStart('-').TrimStart();
                                b = b.TrimStart('-').TrimStart();
                            }
                            if (a.StartsWith("<i>-") && (a.EndsWith(".</i>") || a.EndsWith("!</i>") || a.EndsWith("?</i>")) &&
                                b.StartsWith("<i>-") && (b.EndsWith(".</i>") || b.EndsWith("!</i>") || b.EndsWith("?</i>")))
                            {
                                a = a.Remove(3, 1).Replace("  ", " ");
                                b = b.Remove(3, 1).Replace("  ", " ");
                            }

                            lines[0] = a;
                            lines[1] = b;

                            originalCurrent.Text = Utilities.AutoBreakLine(lines[0]);
                            originalNew.Text = Utilities.AutoBreakLine(lines[1]);
                        }
                        else if (lines.Length == 1)
                        {
                            originalNew.Text = string.Empty;
                        }
                        if (originalCurrent != null && originalNew != null)
                        {
                            if (originalCurrent.Text.StartsWith("<i> "))
                                originalCurrent.Text = originalCurrent.Text.Remove(3, 1);
                            if (originalNew.Text.StartsWith("<i> "))
                                originalCurrent.Text = originalCurrent.Text.Remove(3, 1);
                        }
                        _subtitleAlternate.InsertParagraphInCorrectTimeOrder(originalNew);
                        _subtitleAlternate.Renumber(1);
                    }
                }

                if (_networkSession != null)
                {
                    _networkSession.TimerStop();
                    SetDurationInSeconds(currentParagraph.Duration.TotalSeconds);
                    _networkSession.UpdateLine(_subtitle.GetIndex(currentParagraph), currentParagraph);
                    NetworkGetSendUpdates(new List<int>(), firstSelectedIndex+1, newParagraph);
                }
                else
                {
                    if (GetCurrentSubtitleFormat().IsFrameBased)
                    {
                        if (currentParagraph != null)
                        {
                            currentParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
                            currentParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
                        }
                        newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
                        newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
                    }
                    _subtitle.Paragraphs.Insert(firstSelectedIndex + 1, newParagraph);
                    _subtitle.Renumber(1);
                    SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
                }
                SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex);
                ShowSource();
                ShowStatus(_language.LineSplitted);
                SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged;
                RefreshSelectedParagraph();
                SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true);
            }
        }
开发者ID:IlgnerBri,项目名称:subtitleedit,代码行数:101,代码来源:Main.cs

示例3: addParagraphHereToolStripMenuItem_Click

        private void addParagraphHereToolStripMenuItem_Click(object sender, EventArgs e)
        {
            audioVisualizer.ClearSelection();
            Paragraph newParagraph = new Paragraph(audioVisualizer.NewSelectionParagraph);
            if (newParagraph == null)
                return;

            var format = GetCurrentSubtitleFormat();
            bool useExtraForStyle = format.HasStyleSupport;
            var styles = new List<string>();
            if (format.GetType() == typeof(AdvancedSubStationAlpha) || format.GetType() == typeof(SubStationAlpha))
                styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header);
            else if (format.GetType() == typeof(TimedText10) || format.GetType() == typeof(ItunesTimedText))
                styles = TimedText10.GetStylesFromHeader(_subtitle.Header);
            else if (format.GetType() == typeof(Sami) || format.GetType() == typeof(SamiModern))
                styles = Sami.GetStylesFromHeader(_subtitle.Header);
            string style = "Default";
            if (styles.Count > 0)
                style = styles[0];
            if (useExtraForStyle)
                newParagraph.Extra = style;

            mediaPlayer.Pause();

            // find index where to insert
            int index = 0;
            foreach (Paragraph p in _subtitle.Paragraphs)
            {
                if (p.StartTime.TotalMilliseconds > newParagraph.StartTime.TotalMilliseconds)
                    break;
                index++;
            }

            MakeHistoryForUndo(Configuration.Settings.Language.Main.BeforeInsertLine);

            // create and insert
            if (format.IsFrameBased)
            {
                newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
                newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
            }


            if (_networkSession != null)
            {
                _networkSession.TimerStop();
                NetworkGetSendUpdates(new List<int>(), index, newParagraph);
            }
            else
            {
                _subtitle.Paragraphs.Insert(index, newParagraph);

                if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.AllowEditOfOriginalSubtitle)
                {
                    _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
                    _subtitleAlternate.Renumber(1);
                }

                _subtitleListViewIndex = -1;
                _subtitle.Renumber(1);
                SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
            }
            SubtitleListview1.SelectIndexAndEnsureVisible(index);

            textBoxListViewText.Focus();
            audioVisualizer.NewSelectionParagraph = null;

            ShowStatus(string.Format(_language.VideoControls.NewTextInsertAtX, newParagraph.StartTime.ToShortString()));
            audioVisualizer.Invalidate();
        }
开发者ID:IlgnerBri,项目名称:subtitleedit,代码行数:70,代码来源:Main.cs

示例4: InsertNewTextAtVideoPosition

        private Paragraph InsertNewTextAtVideoPosition()
        {
            // current movie pos
            double videoPositionInMilliseconds = mediaPlayer.CurrentPosition * 1000.0;
            if (!mediaPlayer.IsPaused)
                videoPositionInMilliseconds -= Configuration.Settings.General.SetStartEndHumanDelay;

            var tc = new TimeCode(TimeSpan.FromMilliseconds(videoPositionInMilliseconds));
            MakeHistoryForUndo(_language.BeforeInsertSubtitleAtVideoPosition + "  " + tc.ToString());

            // find index where to insert
            int index = 0;
            foreach (Paragraph p in _subtitle.Paragraphs)
            {
                if (p.StartTime.TotalMilliseconds > videoPositionInMilliseconds)
                    break;
                index++;
            }

            // create and insert
            var newParagraph = new Paragraph("", videoPositionInMilliseconds, videoPositionInMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs);
            if (GetCurrentSubtitleFormat().IsFrameBased)
            {
                newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
                newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
            }

            if (_networkSession != null)
            {
                _networkSession.TimerStop();
                NetworkGetSendUpdates(new List<int>(), index, newParagraph);
            }
            else
            {
                _subtitle.Paragraphs.Insert(index, newParagraph);

                // check if original is available - and insert new paragraph in the original too
                if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
                {
                    _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
                    _subtitleAlternate.Renumber(1);
                }

                _subtitleListViewIndex = -1;
                _subtitle.Renumber(1);
                SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
            }
            SubtitleListview1.SelectIndexAndEnsureVisible(index);
            return newParagraph;
        }
开发者ID:IlgnerBri,项目名称:subtitleedit,代码行数:50,代码来源:Main.cs

示例5: ImportTimeCodesInFramesOnSameSeperateLine

        private Subtitle ImportTimeCodesInFramesOnSameSeperateLine(string[] lines)
        {
            Paragraph paragraph = null;
            var subtitle = new Subtitle();
            var sb = new StringBuilder();
            foreach (string t in lines)
            {
                string line = t;
                string lineWithPerhapsOnlyNumbers = line
                    .Replace(" ", string.Empty)
                    .Replace(".", string.Empty)
                    .Replace(",", string.Empty)
                    .Replace("\t", string.Empty)
                    .Replace(":", string.Empty)
                    .Replace(";", string.Empty)
                    .Replace("{", string.Empty)
                    .Replace("}", string.Empty)
                    .Replace("[", string.Empty)
                    .Replace("]", string.Empty)
                    .Replace("-", string.Empty)
                    .Replace(">", string.Empty)
                    .Replace("<", string.Empty);

                bool allNumbers = lineWithPerhapsOnlyNumbers.Length > 0;
                foreach (char c in lineWithPerhapsOnlyNumbers)
                {
                    if (!char.IsDigit(c))
                    {
                        allNumbers = false;
                    }
                }

                if (allNumbers && lineWithPerhapsOnlyNumbers.Length > 2)
                {
                    string[] arr = line
                        .Replace("-", " ")
                        .Replace(">", " ")
                        .Replace("{", " ")
                        .Replace("}", " ")
                        .Replace("[", " ")
                        .Replace("]", " ")
                        .Trim()
                        .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    if (arr.Length == 2)
                    {
                        string[] start = arr[0].Trim().Split(new[] { '.', ',', ';', ':' }, StringSplitOptions.RemoveEmptyEntries);
                        string[] end = arr[0].Trim().Split(new[] { '.', ',', ';', ':' }, StringSplitOptions.RemoveEmptyEntries);
                        if (start.Length == 1 && end.Length == 1)
                        {
                            if (paragraph != null)
                            {
                                paragraph.Text = sb.ToString().Trim();
                                subtitle.Paragraphs.Add(paragraph);
                            }

                            paragraph = new Paragraph();
                            sb = new StringBuilder();
                            try
                            {
                                if (UseFrames)
                                {
                                    paragraph.StartFrame = int.Parse(start[0]);
                                    paragraph.EndFrame = int.Parse(end[0]);
                                    paragraph.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
                                }
                                else
                                {
                                    paragraph.StartTime.TotalMilliseconds = double.Parse(start[0]);
                                    paragraph.EndTime.TotalMilliseconds = double.Parse(end[0]);
                                }
                            }
                            catch
                            {
                                paragraph = null;
                            }
                        }
                    }
                    else if (arr.Length == 3)
                    {
                        string[] start = arr[0].Trim().Split(new[] { '.', ',', ';', ':' }, StringSplitOptions.RemoveEmptyEntries);
                        string[] end = arr[0].Trim().Split(new[] { '.', ',', ';', ':' }, StringSplitOptions.RemoveEmptyEntries);
                        string[] duration = arr[0].Trim().Split(new[] { '.', ',', ';', ':' }, StringSplitOptions.RemoveEmptyEntries);

                        if (end.Length == 1 && duration.Length == 1)
                        {
                            start = end;
                            end = duration;
                        }

                        if (start.Length == 1 && end.Length == 1)
                        {
                            if (paragraph != null)
                            {
                                paragraph.Text = sb.ToString().Trim();
                                subtitle.Paragraphs.Add(paragraph);
                            }

                            paragraph = new Paragraph();
                            sb = new StringBuilder();
                            try
//.........这里部分代码省略.........
开发者ID:AsenTahchiyski,项目名称:SoftUni-Projects,代码行数:101,代码来源:UknownFormatImporter.cs

示例6: ImportTimeCodesInFramesAndTextOnSameLine

        private Subtitle ImportTimeCodesInFramesAndTextOnSameLine(string[] lines)
        {
            var regexTimeCodes1 = new Regex(@"\d+", RegexOptions.Compiled);
            Paragraph paragraph = null;
            var subtitle = new Subtitle();
            var sb = new StringBuilder();
            foreach (string t in lines)
            {
                string line = t;

                var matches = regexTimeCodes1.Matches(line);
                if (matches.Count >= 2)
                {
                    string start = matches[0].ToString();
                    string end = matches[1].ToString();

                    if (paragraph != null)
                    {
                        paragraph.Text = sb.ToString().Trim();
                        subtitle.Paragraphs.Add(paragraph);
                    }

                    paragraph = new Paragraph();
                    sb = new StringBuilder();
                    try
                    {
                        if (UseFrames)
                        {
                            paragraph.StartFrame = int.Parse(start);
                            paragraph.EndFrame = int.Parse(end);
                            paragraph.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
                        }
                        else
                        {
                            paragraph.StartTime.TotalMilliseconds = double.Parse(start);
                            paragraph.EndTime.TotalMilliseconds = double.Parse(end);
                        }
                    }
                    catch
                    {
                        paragraph = null;
                    }

                    if (matches[0].Index < 9)
                    {
                        line = line.Remove(0, matches[0].Index);
                    }

                    line = line.Replace(matches[0].ToString(), string.Empty);
                    line = line.Replace(matches[1].ToString(), string.Empty);
                    line = line.Trim();
                    if (line.StartsWith("}{}") || line.StartsWith("][]"))
                    {
                        line = line.Remove(0, 3);
                    }

                    line = line.Trim();
                }

                if (paragraph == null || line.Length <= 1)
                {
                    continue;
                }

                sb.AppendLine(line.Trim());
                if (sb.Length > 200)
                {
                    return new Subtitle();
                }
            }

            if (paragraph != null)
            {
                paragraph.Text = sb.ToString().Trim();
                subtitle.Paragraphs.Add(paragraph);
            }

            subtitle.Renumber();
            return subtitle;
        }
开发者ID:AsenTahchiyski,项目名称:SoftUni-Projects,代码行数:80,代码来源:UknownFormatImporter.cs

示例7: ImportTimeCodesInFramesOnSameSeperateLine

        private Subtitle ImportTimeCodesInFramesOnSameSeperateLine(string[] lines)
        {
            Paragraph p = null;
            var subtitle = new Subtitle();
            var sb = new StringBuilder();
            for (int idx = 0; idx < lines.Length; idx++)
            {
                string line = lines[idx];
                string lineWithPerhapsOnlyNumbers = line.Replace(" ", string.Empty).Replace(".", string.Empty).Replace(",", string.Empty).Replace("\t", string.Empty).Replace(":", string.Empty).Replace(";", string.Empty).Replace("{", string.Empty).Replace("}", string.Empty).Replace("[", string.Empty).Replace("]", string.Empty).Replace("-", string.Empty).Replace(">", string.Empty).Replace("<", string.Empty);
                bool allNumbers = lineWithPerhapsOnlyNumbers.Length > 0;
                foreach (char c in lineWithPerhapsOnlyNumbers)
                {
                    if (!"0123456789".Contains(c.ToString()))
                        allNumbers = false;
                }
                if (allNumbers && lineWithPerhapsOnlyNumbers.Length > 2)
                {
                    string[] arr = line.Replace("-", " ").Replace(">", " ").Replace("{", " ").Replace("}", " ").Replace("[", " ").Replace("]", " ").Trim().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (arr.Length == 2)
                    {
                        string[] start = arr[0].Trim().Split(".,;:".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        string[] end = arr[0].Trim().Split(".,;:".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        if (start.Length == 1 && end.Length == 1)
                        {
                            if (p != null)
                            {
                                p.Text = sb.ToString().Trim();
                                subtitle.Paragraphs.Add(p);
                            }
                            p = new Paragraph();
                            sb = new StringBuilder();
                            try
                            {
                                if (UseFrames)
                                {
                                    p.StartFrame = int.Parse(start[0]);
                                    p.EndFrame = int.Parse(end[0]);
                                    p.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
                                }
                                else
                                {
                                    p.StartTime.TotalMilliseconds = double.Parse(start[0]);
                                    p.EndTime.TotalMilliseconds = double.Parse(end[0]);
                                }
                            }
                            catch
                            {
                                p = null;
                            }
                        }
                    }
                    else if (arr.Length == 3)
                    {
                        string[] start = arr[0].Trim().Split(".,;:".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        string[] end = arr[0].Trim().Split(".,;:".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        string[] duration = arr[0].Trim().Split(".,;:".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                        if (end.Length == 1 && duration.Length == 1)
                        {
                            start = end;
                            end = duration;
                        }

                        if (start.Length == 1 && end.Length == 1)
                        {
                            if (p != null)
                            {
                                p.Text = sb.ToString().Trim();
                                subtitle.Paragraphs.Add(p);
                            }
                            p = new Paragraph();
                            sb = new StringBuilder();
                            try
                            {
                                if (UseFrames)
                                {
                                    p.StartFrame = int.Parse(start[0]);
                                    p.EndFrame = int.Parse(end[0]);
                                    p.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
                                }
                                else
                                {
                                    p.StartTime.TotalMilliseconds = double.Parse(start[0]);
                                    p.EndTime.TotalMilliseconds = double.Parse(end[0]);
                                }
                            }
                            catch
                            {
                                p = null;
                            }
                        }
                    }
                }
                if (p != null && !allNumbers && line.Length > 1)
                {
                    line = line.Trim();
                    if (line.StartsWith("}{}") || line.StartsWith("][]"))
                        line = line.Remove(0, 3);
                    sb.AppendLine(line.Trim());
                }
//.........这里部分代码省略.........
开发者ID:IlgnerBri,项目名称:subtitleedit,代码行数:101,代码来源:UknownFormatImporter.cs


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