• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TimeCode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TimeCode的典型用法代码示例。如果您正苦于以下问题:C# TimeCode类的具体用法?C# TimeCode怎么用?C# TimeCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TimeCode类属于命名空间,在下文中一共展示了TimeCode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {   //00:02:09:34   00:02:13:07 - Hvad mener du så om konkurrencen?- Jo, det er helt fint.
            //00:02:14:02   00:02:16:41 - Var det den rigtige der vandt?- Ja, bestemt.
            //newline = \r (0D)

            _errorCount = 0;
            Paragraph lastParagraph = null;
            foreach (string line in lines)
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }

                bool success = false;
                bool isTimeCode = false;
                if (line.Length > 26 && line.IndexOf(':') == 2)
                {
                    var match = Regex.Match(line);
                    if (match.Success)
                    {
                        isTimeCode = true;
                        string s = line.Substring(0, match.Length);
                        s = s.Replace('\t', ':');
                        s = s.Replace(" ", string.Empty);
                        s = s.Trim().TrimEnd(':').TrimEnd();
                        string[] parts = s.Split(':');
                        if (parts.Length == 8)
                        {
                            int hours = int.Parse(parts[0]);
                            int minutes = int.Parse(parts[1]);
                            int seconds = int.Parse(parts[2]);
                            int milliseconds = int.Parse(parts[3]) * 10;
                            var start = new TimeCode(hours, minutes, seconds, milliseconds);

                            hours = int.Parse(parts[4]);
                            minutes = int.Parse(parts[5]);
                            seconds = int.Parse(parts[6]);
                            milliseconds = int.Parse(parts[7]) * 10;
                            var end = new TimeCode(hours, minutes, seconds, milliseconds);

                            string text = line.Substring(match.Length).TrimStart();
                            text = text.Replace("|", Environment.NewLine);

                            lastParagraph = new Paragraph(start, end, text);
                            subtitle.Paragraphs.Add(lastParagraph);
                            success = true;
                        }
                    }
                }
                if (!isTimeCode && lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5)
                {
                    lastParagraph.Text += Environment.NewLine + line.Trim();
                    success = true;
                }
                if (!success)
                    _errorCount++;
            }
            subtitle.Renumber();
        }
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:60,代码来源:SonyDVDArchitectTabs.cs


示例2: Paragraph

 public Paragraph(string text, double startTotalMilliseconds, double endTotalMilliseconds)
 {
     StartTime = new TimeCode(startTotalMilliseconds);
     EndTime = new TimeCode(endTotalMilliseconds);
     Text = text;
     ID = GenerateId();
 }
开发者ID:Team-Vengeance,项目名称:SubtitleEdit,代码行数:7,代码来源:Paragraph.cs


示例3: MakeTimeCode

 private static string MakeTimeCode(TimeCode timeCode, Paragraph last)
 {
     double start = 0;
     if (last != null)
         start = last.EndTime.TotalSeconds;
     return string.Format("{0:0.0#}", (timeCode.TotalSeconds - start));
 }
开发者ID:athikan,项目名称:subtitleedit,代码行数:7,代码来源:UnknownSubtitle25.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());

            foreach (XmlNode node in xml.DocumentElement.SelectNodes("text"))
            {
                try
                {
                    string start = node.Attributes["t"].InnerText;
                    string dur = node.Attributes["d"].InnerText;
                    TimeCode startTimeCode = GetTimeCode(start);
                    var endTimeCode = new TimeCode(startTimeCode.TotalMilliseconds + GetTimeCode(dur).TotalMilliseconds);
                    var p = new Paragraph(startTimeCode, endTimeCode, node.InnerText.Replace("   ", " ").Replace("  ", " "));
                    subtitle.Paragraphs.Add(p);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    _errorCount++;
                }
            }
            subtitle.Renumber();
        }
开发者ID:socialpercon,项目名称:subtitleedit,代码行数:28,代码来源:UnknownSubtitle76.cs


示例5: buttonReset_Click

 private void buttonReset_Click(object sender, EventArgs e)
 {
     VideoOffset = new TimeCode();
     DoNotaddVideoOffsetToTimeCodes = checkBoxKeepTimeCodes.Checked;
     Reset = true;
     DialogResult = DialogResult.OK;
 }
开发者ID:LeonCheung,项目名称:subtitleedit,代码行数:7,代码来源:SetVideoOffset.cs


示例6: WriteTimeCode

 private static void WriteTimeCode(FileStream fs, TimeCode tc)
 {
     fs.WriteByte((byte)(tc.Hours));
     fs.WriteByte((byte)(tc.Minutes));
     fs.WriteByte((byte)(tc.Seconds));
     fs.WriteByte((byte)(MillisecondsToFramesMaxFrameRate(tc.Milliseconds)));
 }
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:7,代码来源:AvidStl.cs


示例7: GetFormattingObject

        /// <summary>
        /// Get formatting object for body element
        /// </summary>
        /// <param name="regionId"></param>
        /// <param name="tick"></param>
        /// <returns></returns>
        public override FormattingObject GetFormattingObject(TimeCode tick)
        {

            Block block = null;

            if (TemporallyActive(tick))
            {
                block = new Block(this);

                foreach (var child in Children)
                {
                    if (child is DivElement)
                    {
                        var fo = (child as DivElement).GetFormattingObject(tick);
                        if (fo != null)
                        {
                            fo.Parent = block;
                            block.Children.Add(fo);
                        }
                    }

                    if (child is SetElement)
                    {
                        var fo = ((child as SetElement).GetFormattingObject(tick)) as Animation;
                        if (fo != null)
                        {
                            // fo.Parent = block;
                            block.Animations.Add(fo);
                        }
                    }
                }
            }
            return block;
        }
开发者ID:Ginichen,项目名称:Silverlight-Player-for-PlayReady-with-Token-Auth,代码行数:40,代码来源:BodyElement.cs


示例8: ToText

 public override string ToText(Subtitle subtitle, string title)
 {
     var sb = new StringBuilder();
     sb.AppendLine("Title: " + title);
     sb.AppendLine("Translator: No Author");
     sb.AppendLine("Date: " + DateTime.Now.ToString("dd-MM-yyyy").Replace("-", ".")); //  25.08.2011
     double milliseconds = 0;
     if (subtitle.Paragraphs.Count > 0)
         milliseconds = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds;
     var tc = new TimeCode(milliseconds);
     sb.AppendLine(string.Format("Duration: {0:00}:{1:00}:{2:00}:{3:00}", tc.Hours, tc.Minutes, tc.Seconds, MillisecondsToFramesMaxFrameRate(tc.Milliseconds))); // 01:20:49:12
     sb.AppendLine("Program start: 00:00:00:00");
     sb.AppendLine("Title count: " + subtitle.Paragraphs.Count);
     sb.AppendLine();
     sb.AppendLine("#\tIn\tOut\tDuration");
     sb.AppendLine();
     int count = 0;
     foreach (Paragraph p in subtitle.Paragraphs)
     {
         count++;
         string text = Utilities.RemoveHtmlTags(p.Text);
         sb.AppendLine(string.Format("{13}\t{0:00}:{1:00}:{2:00}:{3:00}\t{4:00}:{5:00}:{6:00}:{7:00}\t{8:00}:{9:00}:{10:00}:{11:00}\r\n{12}" + Environment.NewLine,
                                     p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds),
                                     p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds),
                                     p.Duration.Hours, p.Duration.Minutes, p.Duration.Seconds, MillisecondsToFramesMaxFrameRate(p.Duration.Milliseconds),
                                     text, count));
     }
     return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine;
 }
开发者ID:athikan,项目名称:subtitleedit,代码行数:29,代码来源:SonyDVDArchitectLineAndDuration.cs


示例9: ToText

        public override string ToText(Subtitle subtitle, string title)
        {
            var sb = new StringBuilder();
            if (!string.IsNullOrEmpty(subtitle.Header) && (subtitle.Header.Contains("[ar:") || subtitle.Header.Contains("[ti:")))
                sb.Append(subtitle.Header);

            for (int i = 0; i < subtitle.Paragraphs.Count; i++)
            {
                Paragraph p = subtitle.Paragraphs[i];
                Paragraph next = null;
                if (i + 1 < subtitle.Paragraphs.Count)
                    next = subtitle.Paragraphs[i + 1];

                string text = Utilities.RemoveHtmlTags(p.Text);
                text = text.Replace(Environment.NewLine, " "); // text = text.Replace(Environment.NewLine, "|");
                sb.AppendLine(string.Format("[{0:00}:{1:00}.{2:00}]{3}", p.StartTime.Hours * 60 + p.StartTime.Minutes, p.StartTime.Seconds, (int)Math.Round(p.StartTime.Milliseconds / 10.0), text));

                if (next == null || next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds > 100)
                {
                    TimeCode tc = new TimeCode(TimeSpan.FromMilliseconds(p.EndTime.TotalMilliseconds));
                    sb.AppendLine(string.Format("[{0:00}:{1:00}.{2:00}]{3}", tc.Hours * 60 + tc.Minutes, tc.Seconds, (int)Math.Round(tc.Milliseconds / 10.0), string.Empty));
                }
            }
            return sb.ToString().Trim();
        }
开发者ID:IlgnerBri,项目名称:subtitleedit,代码行数:25,代码来源:Lrc.cs


示例10: ConvertToTimeString

 internal static string ConvertToTimeString(TimeCode time)
 {
     var timeCodeFormat = Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormat.Trim().ToLowerInvariant();
     if (timeCodeFormat == "source" && !string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormatSource))
     {
         timeCodeFormat = Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormatSource.Trim().ToLowerInvariant();
     }
     switch (timeCodeFormat)
     {
         case "source":
         case "seconds":
             return string.Format(CultureInfo.InvariantCulture, "{0:0.0##}s", time.TotalSeconds);
         case "milliseconds":
             return string.Format(CultureInfo.InvariantCulture, "{0}ms", time.TotalMilliseconds);
         case "ticks":
             return string.Format(CultureInfo.InvariantCulture, "{0}t", TimeSpan.FromMilliseconds(time.TotalMilliseconds).Ticks);
         case "hh:mm:ss.ms":
             return string.Format(CultureInfo.InvariantCulture, "{0:00}:{1:00}:{2:00}.{3:000}", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
         case "hh:mm:ss.ms-two-digits":
             return string.Format(CultureInfo.InvariantCulture, "{0:00}:{1:00}:{2:00}.{3:00}", time.Hours, time.Minutes, time.Seconds, (int)Math.Round(time.Milliseconds / 10.0));
         case "hh:mm:ss,ms":
             return string.Format(CultureInfo.InvariantCulture, "{0:00}:{1:00}:{2:00},{3:000}", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
         default:
             return string.Format(CultureInfo.InvariantCulture, "{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, MillisecondsToFramesMaxFrameRate(time.Milliseconds));
     }
 }
开发者ID:bestwpw,项目名称:subtitleedit,代码行数:26,代码来源:TimedText10.cs


示例11: buttonOK_Click

 private void buttonOK_Click(object sender, EventArgs e)
 {
     VideoOffset = timeUpDownVideoPosition.TimeCode;
     FromCurrentVideoPosition = checkBoxFromCurrentPosition.Checked;
     DoNotaddVideoOffsetToTimeCodes = checkBoxKeepTimeCodes.Checked;
     DialogResult = DialogResult.OK;
 }
开发者ID:mgziminsky,项目名称:subtitleedit,代码行数:7,代码来源:SetVideoOffset.cs


示例12: Paragraph

 public Paragraph(TimeCode startTime, TimeCode endTime, string text)
 {
     StartTime = startTime;
     EndTime = endTime;
     Text = text;
     ID = GenerateId();
 }
开发者ID:KatyaMarincheva,项目名称:SubtitleEditOriginal,代码行数:7,代码来源:Paragraph.cs


示例13: Paragraph

 /// <summary>
 /// Initializes a new instance of the <see cref="Paragraph"/> class.
 /// </summary>
 /// <param name="startTime">
 /// The start time.
 /// </param>
 /// <param name="endTime">
 /// The end time.
 /// </param>
 /// <param name="text">
 /// The text.
 /// </param>
 public Paragraph(TimeCode startTime, TimeCode endTime, string text)
 {
     this.StartTime = startTime;
     this.EndTime = endTime;
     this.Text = text;
     this.ID = this.GenerateId();
 }
开发者ID:KatyaMarincheva,项目名称:SubtitleEditOriginal,代码行数:19,代码来源:Paragraph.cs


示例14: GetFormattingObject

 /// <summary>
 /// Return formatting object for br element
 /// </summary>
 /// <param name="regionId"></param>
 /// <param name="tick"></param>
 /// <returns></returns>
 public override FormattingObject GetFormattingObject(TimeCode tick)
 {
     if (TemporallyActive(tick))
     {
         return new InlineContent(this);
     }
     return null;
 }
开发者ID:bondarenkod,项目名称:pf-arm-deploy-error,代码行数:14,代码来源:BrElement.cs


示例15: EncodeTimeCode

 private static string EncodeTimeCode(TimeCode time)
 {
     //00:03:15:22 (last is frame)
     int sec = time.Seconds;
     if (time.Milliseconds >= 500)
         sec++;
     return string.Format("{0:00}:{1:00}:{2:00}:", time.Hours, time.Minutes, sec);
 }
开发者ID:rragu,项目名称:subtitleedit,代码行数:8,代码来源:UnknownSubtitle27.cs


示例16: EncodeTimeCode

 private static string EncodeTimeCode(TimeCode time)
 {
     //00:50
     int seconds = time.Seconds;
     if (time.Milliseconds >= 500)
         seconds++;
     return string.Format("{0}:{1:00}", time.Hours * 60 + time.Minutes, time.Seconds);
 }
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:8,代码来源:UnknownSubtitle40.cs


示例17: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            // 00:04:10:92 - 00:04:13:32    Raise Yourself To Help Mankind
            // 00:04:27:92 - 00:04:30:92    الجهة المتولية للمسئولية الاجتماعية لشركتنا.

            _errorCount = 0;
            Paragraph lastParagraph = null;
            foreach (string line in lines)
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }

                bool success = false;

                Match match = null;
                if (line.Length > 26 && line[2] == ':')
                    match = Regex.Match(line);

                if (match != null && match.Success)
                {
                    string s = line.Substring(0, match.Length);
                    s = s.Replace(" - ", ":");
                    s = s.Replace(" ", string.Empty);
                    string[] parts = s.Split(':');
                    if (parts.Length == 8)
                    {
                        int hours = int.Parse(parts[0]);
                        int minutes = int.Parse(parts[1]);
                        int seconds = int.Parse(parts[2]);
                        int milliseconds = int.Parse(parts[3]) * 10;
                        var start = new TimeCode(hours, minutes, seconds, milliseconds);

                        hours = int.Parse(parts[4]);
                        minutes = int.Parse(parts[5]);
                        seconds = int.Parse(parts[6]);
                        milliseconds = int.Parse(parts[7]) * 10;
                        var end = new TimeCode(hours, minutes, seconds, milliseconds);

                        string text = line.Substring(match.Length).TrimStart();
                        text = text.Replace("|", Environment.NewLine);

                        lastParagraph = new Paragraph(start, end, text);
                        subtitle.Paragraphs.Add(lastParagraph);
                        success = true;
                    }
                }
                else if (lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5)
                {
                    lastParagraph.Text += Environment.NewLine + line.Trim();
                    success = true;
                }
                if (!success)
                    _errorCount++;
            }
            subtitle.Renumber();
        }
开发者ID:ARASHz4,项目名称:subtitleedit,代码行数:58,代码来源:SonyDVDArchitect.cs


示例18: LoadSubtitle

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

            subtitle.Paragraphs.Clear();
            char[] splitChars = { ':', ']', '[', ' ' };
            foreach (string line in lines)
            {
                if (line.StartsWith('[') && RegexTimeCode.IsMatch(line))
                {
                    string[] parts = line.Split(splitChars, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length == 3)
                    {
                        try
                        {
                            int startHours = int.Parse(parts[0]);
                            int startMinutes = int.Parse(parts[1]);
                            int startSeconds = int.Parse(parts[2]);
                            var tc = new TimeCode(startHours, startMinutes, startSeconds, 0);
                            if (expecting == ExpectingLine.TimeStart)
                            {
                                paragraph = new Paragraph();
                                paragraph.StartTime = tc;
                                expecting = ExpectingLine.Text;
                            }
                            else if (expecting == ExpectingLine.TimeEnd)
                            {
                                paragraph.EndTime = tc;
                                expecting = ExpectingLine.TimeStart;
                                subtitle.Paragraphs.Add(paragraph);
                                paragraph = new Paragraph();
                            }
                        }
                        catch
                        {
                            _errorCount++;
                            expecting = ExpectingLine.TimeStart;
                        }
                    }
                }
                else
                {
                    if (expecting == ExpectingLine.Text)
                    {
                        if (line.Length > 0)
                        {
                            string text = line.Replace("|", Environment.NewLine);
                            paragraph.Text = text;
                            expecting = ExpectingLine.TimeEnd;
                        }
                    }
                }
            }
            subtitle.Renumber();
        }
开发者ID:ARASHz4,项目名称:subtitleedit,代码行数:57,代码来源:SubViewer10.cs


示例19: EncodeTime

 private static string EncodeTime(TimeCode time)
 {
     //3:15:22
     if (time.Hours > 0)
         return string.Format("{0:00}:{1:00}:{2:00}.{3:00}", time.Hours, time.Minutes, time.Seconds, time.Milliseconds / 10);
     if (time.Minutes > 9)
         return string.Format("{0:00}:{1:00}.{2:00}", time.Minutes, time.Seconds, time.Milliseconds / 10);
     return string.Format("{0}:{1:00}.{2:00}", time.Minutes, time.Seconds, time.Milliseconds / 10);
 }
开发者ID:radinamatic,项目名称:subtitleedit,代码行数:9,代码来源:SmilTimesheetData.cs


示例20: LoadSubtitle

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {   //00:02:10.354  00:02:13.047    00:00:02.693    Her er endnu en tekstfil fra DVD-Architect.Med 2 linier.
            //00:02:14.018  00:02:19.018    00:00:05.000    - Prøvetekst 2- Linie 2
            //newline = \r (0D)

            var regex = new Regex(@"^\d\d:\d\d:\d\d\.\d\d\d[ \t]+\d\d:\d\d:\d\d\.\d\d\d[ \t]+\d\d:\d\d:\d\d\.\d\d\d[ \t]+", RegexOptions.Compiled);
            _errorCount = 0;
            Paragraph lastParagraph = null;
            foreach (string line in lines)
            {
                if (line.Trim().Length > 0)
                {
                    string l = line;
                    string s = l;
                    bool success = false;
                    var match = regex.Match(s);
                    if (s.Length > 26 && match.Success)
                    {
                        s = s.Substring(0, match.Length);
                        s = s.Replace("\t", ":");
                        s = s.Replace(".", ":");
                        s = s.Replace(" ", string.Empty);
                        s = s.Trim().TrimEnd(':').TrimEnd();
                        string[] parts = s.Split(':');
                        if (parts.Length == 12)
                        {
                            int hours = int.Parse(parts[0]);
                            int minutes = int.Parse(parts[1]);
                            int seconds = int.Parse(parts[2]);
                            int milliseconds = int.Parse(parts[3]);
                            var start = new TimeCode(hours, minutes, seconds, milliseconds);

                            hours = int.Parse(parts[4]);
                            minutes = int.Parse(parts[5]);
                            seconds = int.Parse(parts[6]);
                            milliseconds = int.Parse(parts[7]);
                            var end = new TimeCode(hours, minutes, seconds, milliseconds);

                            string text = l.Substring(match.Length).TrimStart();
                            text = text.Replace("|", Environment.NewLine);

                            lastParagraph = new Paragraph(start, end, text);
                            subtitle.Paragraphs.Add(lastParagraph);
                            success = true;
                        }
                    }
                    else if (l.Trim().Length > 0 && lastParagraph != null && Utilities.CountTagInText(lastParagraph.Text, Environment.NewLine) < 4)
                    {
                        lastParagraph.Text += Environment.NewLine + l.Trim();
                        success = true;
                    }
                    if (!success && l.Trim().Length > 0)
                        _errorCount++;
                }
            }
            subtitle.Renumber(1);
        }
开发者ID:IlgnerBri,项目名称:subtitleedit,代码行数:57,代码来源:SonyDVDArchitectExplicitDuration.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TimeEntryModel类代码示例发布时间:2022-05-24
下一篇:
C# Time类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap