Exemplo n.º 1
0
 public LrcBlock(LrcProperties properties, IList <ISubtitleLine> lines)
 {
     Properties = properties;
     Lines      = lines;
 }
Exemplo n.º 2
0
        public LrcBlock(string lrcFileContent)
        {
            var lrcLines = new ObservableCollection <ISubtitleLine>();

            Properties = new LrcProperties(lrcFileContent);
            Lines      = lrcLines;
            string[] strLines = lrcFileContent.ToLines();

            LrcLine       lrcLine        = null;
            StringBuilder contentBuilder = new StringBuilder();

            foreach (var item in strLines)
            {
                if (String.IsNullOrWhiteSpace(item))
                {
                    continue;
                }

                string line  = item.Trim();
                Match  match = LineRegex.Match(line);
                if (!match.Success && lrcLine is null)
                {
                    continue;
                }

                if (match.Success)
                {
                    if (lrcLine != null)
                    {
                        lrcLine.Content = contentBuilder.ToString().Trim();
                        lrcLines.Add(lrcLine);
                        contentBuilder.Clear();
                    }

                    int min = Int32.Parse(match.Groups["min"].Value);
                    int ss  = Int32.Parse(match.Groups["ss"].Value);

                    string msStr = match.Groups["ms"].Value;
                    int    ms    = Int32.Parse(msStr);

                    for (int i = msStr.Length; i < 3; i++)
                    {
                        ms *= 10;
                    }


                    lrcLine = new LrcLine(new TimeSpan(0, 0, min, ss, ms));

                    contentBuilder.AppendLine(match.Groups["content"].Value);
                }
                else
                {
                    contentBuilder.AppendLine(line);
                }
            }

            if (lrcLine != null)
            {
                lrcLine.Content = contentBuilder.ToString().Trim();
                lrcLines.Add(lrcLine);
            }
        }
Exemplo n.º 3
0
 public LrcBlock()
 {
     Properties = new LrcProperties();
     Lines      = new ObservableCollection <ISubtitleLine>();
 }