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


C# TimeCode类代码示例

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


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


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