Ass2Srt.AssAnalyzerForSrt.GetDialogue C# (CSharp) Method

GetDialogue() private method

private GetDialogue ( string strDialogue ) : List
strDialogue string
return List
        private List<string> GetDialogue(string strDialogue)
        {
            List<string> lDialogues = new List<string>();
            Regex rx = new Regex(@"[^\{^\}]+");
            Regex exEngOrChi = new Regex(@"[\u4e00-\u9fa5]");
            strDialogue = strDialogue.Replace("\\h", " ");
            MatchCollection MC = rx.Matches(strDialogue);
            string strDialogueLong = "";
            string strControlCmd = "";
            if (MC.Count > 0)
            {
                if (MC[0].ToString().Contains(",,"))
                {
                    string t = MC[0].ToString();
                    string[] tt = SplitString(t, ",,");
                    strDialogueLong += tt[tt.Length - 1];
                }
            }

            for (int i = 1; i < MC.Count; i++)
            {
                string t = MC[i].ToString();

                if (t[0] == '\\')
                {
                    string[] controlCmds = t.Split('\\');
                    foreach (string s in controlCmds)
                    {
                        //Keep only {\an} and {\pos} tags in srt files
                        if (s.Contains("an") || s.Contains("pos"))
                        {
                            strControlCmd += "{" + "\\" + s + "}";
                            continue;
                        }
                    }

                    continue;
                }

                else if (t == " ")
                {
                    continue;
                }

                //if (t.Contains("\\N"))
                //{

                strDialogueLong += t;
            }

            //strDialogue = strControlCmd + strDialogue;
            //lDialogues.Add(GetTime(strDialogue));
            string[] ss = SplitString(strDialogueLong, "\\N");
            List<string> lSS = new List<string>();
            foreach (string s in ss)
            {
                if (s == "")
                {
                    continue;
                }

                //Skip lines of ass bitmaps.
                if ( CountDigitsInString(s) + CountSpacesInString(s) + CountLettersInString(s, 'l')
                   + CountLettersInString(s, 'm') + CountLettersInString(s, 'b')
                   > 0.8 * s.Length )
                {
                    continue;
                }

                switch (type)
                {
                    case 0:
                        {
                            lSS.Add(s);
                            break;
                        }
                    case 1:
                        {
                            if (exEngOrChi.IsMatch(s))
                            {
                                lSS.Add(ConvertToTrad(s));
                            }

                            else
                            {
                                lSS.Add(s);
                            }

                            break;
                        }
                    case 2:
                        {
                            if (DoubleOrSingle)
                            {
                                if (exEngOrChi.IsMatch(s))
                                {
                                    lSS.Add(s);
                                }

                                else
                                {

                                }
                            }

                            else
                            {
                                lSS.Add(s);
                            }

                            break;
                        }
                    case 3:
                        {
                            if (DoubleOrSingle)
                            {
                                if (exEngOrChi.IsMatch(s))
                                {
                                    lSS.Add(ConvertToTrad(s));
                                }

                                else
                                {

                                }
                            }

                            else
                            {
                                lSS.Add(ConvertToTrad(s));
                            }

                            break;
                        }
                    case 4:
                        {
                            if (exEngOrChi.IsMatch(s))
                            {

                            }
                            else
                            {
                                lSS.Add(s);
                            }

                            break;
                        }
                }

            }
                //}

            if (lSS.Count > 0)
            {
                if (lSS[0] != "■")
                {
                    lDialogues.Add(GetTime(strDialogue));
                    lSS[0] = strControlCmd + lSS[0];
                    lDialogues.AddRange(lSS);
                }
            }

            return lDialogues;
        }