public static List <List <Attr> > LinesFromSubtitle <T>(ISubtitleObject <T> subtitle) { List <Attr> attrs = FromSubtitle(subtitle); List <List <Attr> > lines = new List <List <Attr> >(); List <Attr> line = new List <Attr>(); int index = 0; lines.Add(line); foreach (Attr attr in attrs) { if ((index = attr.text.IndexOf('\n')) >= 0) { line.Add(new Attr(attr) { text = attr.text.Substring(0, index) }); lines.Add(line = new List <Attr>()); line.Add(new Attr(attr) { text = attr.text.Substring(index) }); } else { line.Add(attr); } } return(lines); }
public static void ToSubtitle <T>(List <Attr> attrs, ISubtitleObject <T> subtitle) { subtitle.FromAttr(attrs); }
public static List <Attr> FromSubtitle <T>(ISubtitleObject <T> subtitle) { return(subtitle.ToAttr()); }