public override SubtitlesUnit clone() { ASSUnit au = new ASSUnit(this); au.Layer = this.Layer; au.Style = this.Style; au.Name = this.Name; au.Actor = this.Actor; au.MarginL = this.MarginL; au.MarginR = this.MarginR; au.MarginV = this.MarginV; au.Effect = this.Effect; return(au); }
override public void readSubtitles(string path) { base.readSubtitles(path); if (textLines == null || textLines.Length <= 0) { return; } if (subtitlesUnits != null && subtitlesUnits.Count > 0) { subtitlesUnits.Clear(); } else { subtitlesUnits = new List <SubtitlesUnit>(); } if (styleList != null && styleList.Count > 0) { styleList.Clear(); } else { styleList = new List <Styles>(); } Console.WriteLine("lines length ==> " + textLines.Length); uint currentType = 0; string[] format = null; for (int i = 0; i < textLines.Length; i++) { textLines[i] = textLines[i].Trim(); if (textLines[i].IndexOf("[Script Info]") > -1) { currentType = 1; } else if (textLines[i].IndexOf("[V4+ Styles]") > -1 || textLines[i].IndexOf("[V4 Styles]") > -1) { currentType = 2; } else if (textLines[i].IndexOf("[Events]") > -1) { currentType = 3; } switch (currentType) { case 1: //Script Info break; case 2: //Styles if (textLines[i].IndexOf("Format") == 0) { format = textLines[i].Replace("Format:", "").Trim().Split(new char[] { ',' }); } else if (textLines[i].IndexOf("Style") == 0) { string[] dialogue = textLines[i].Replace("Style:", "").Trim().Split(new char[] { ',' }, StringSplitOptions.None); Styles st = new Styles(); for (int j = 0; j < format.Length - 1; j++) { setPropertyValue(st, format[j].Trim(), dialogue[j]); } styleList.Add(st); } break; case 3: //Dialogue if (textLines[i].IndexOf("Format") == 0) { format = textLines[i].Replace("Format:", "").Trim().Split(new char[] { ',' }); } else if (textLines[i].IndexOf("Dialogue") == 0) { string[] dialogue = textLines[i].Replace("Dialogue:", "").Trim().Split(new char[] { ',' }, StringSplitOptions.None); ASSUnit au = new ASSUnit(); for (int j = 0; j < format.Length - 1; j++) { if (format[j].Trim() == "Start") { au.BeginStr = dialogue[j]; } else if (format[j].Trim() == "End") { au.EndStr = dialogue[j]; } else { setPropertyValue(au, format[j].Trim(), dialogue[j]); } } string content = String.Join(",", dialogue.Skip(format.Length - 1)); au.Contents = content.Split(new string[] { "\\N" }, StringSplitOptions.RemoveEmptyEntries).ToList(); //Console.WriteLine(string.Join("\n\t", au.Contents)); subtitlesUnits.Add(au); } break; } } //Console.WriteLine("subtitlesUnits length ==> " + subtitlesUnits.Count); }