/// <summary>
        /// 从 ASS 加载
        /// </summary>
        /// <param name="text">ASS 文本</param>
        public void LoadAss(string text)
        {
            _styles = new List<SubStationStyle>();
            _events = new List<SubStationEvent>();

            string[] lines = text.Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            int mode = 0;

            int playRexX = 0;
            int playRexY = 0;
            bool isStyle = false;
            bool isEvent = false;

            foreach (string s in lines)
            {
                string line = s.Trim();

                if (line == "[Script Info]")
                {
                    mode = 1;
                    System.Diagnostics.Debug.WriteLine(line);
                }
                else if (line == "[V4+ Styles]")
                {
                    mode = 2;
                    System.Diagnostics.Debug.WriteLine(line);
                }
                else if (line == "[Events]")
                {
                    mode = 3;
                    System.Diagnostics.Debug.WriteLine(line);
                }
                else
                {
                    switch (mode)
                    {
                        case 1:
                            if (line.Length > 9)
                            {
                                if (line.Substring(0, 9) == "PlayResX:")
                                {
                                    playRexX = int.Parse(line.Substring(9).Trim());
                                }
                                else if (line.Substring(0, 9) == "PlayResY:")
                                {
                                    playRexY = int.Parse(line.Substring(9).Trim());
                                }
                                
                                if (playRexX > 0 && playRexY > 0)
                                {
                                    _scriptInfo = new SubStationInfo(playRexX, playRexY);
                                }
                            }
                            break;
                        case 2:
                            if (line.Replace(" ", "") == "Format:Name,Fontname,Fontsize,PrimaryColour,SecondaryColour,OutlineColour,BackColour,Bold,Italic,Underline,StrikeOut,ScaleX,ScaleY,Spacing,Angle,BorderStyle,Outline,Shadow,Alignment,MarginL,MarginR,MarginV,Encoding")
                            {
                                isStyle = true;
                            }

                            if (isStyle)
                            {
                                if (line.Length > 6)
                                {
                                    if (line.Substring(0, 6) == "Style:")
                                    {
                                        SubStationStyle substyle = new SubStationStyle(line);
                                        _styles.Add(substyle);
                                    }
                                }
                            }
                            break;
                        case 3:
                            if (line.Replace(" ", "") == "Format:Layer,Start,End,Style,Actor,MarginL,MarginR,MarginV,Effect,Text")
                            {
                                isEvent = true;
                            }

                            if (isEvent)
                            {
                                if (line.Length > 9)
                                {
                                    if (line.Substring(0, 9) == "Dialogue:")
                                    {
                                        SubStationEvent subevent = new SubStationEvent(line);
                                        _events.Add(subevent);
                                    }
                                }
                            }
                            break;
                        default:
                            //do nothing
                            break;
                    }
                }
            }

            bool hasDefault = false;
            foreach (SubStationStyle _style in _styles)
            {
                if (_style.Name == "Default") hasDefault = true;
            }
            if (!hasDefault) _styles.Insert(0, new SubStationStyle());
        }
        /// <summary>
        /// 从 XingSub 时间轴加载
        /// </summary>
        /// <param name="text">XingSub 对白时间轴文本</param>
        public void LoadXss(string text)
        {
            if (_styles.Count == 0)
            {
                _styles.Add(new SubStationStyle());
            }

            _events = new List<SubStationEvent>();
            string[] line = text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < line.Length - 1; i++)
            {
                if (line[i].Length > 7 && line[i + 1].Length >= 7)
                {
                    string startTime = TimeToStamp(line[i].Substring(0, 7));
                    string endTime = TimeToStamp(line[i + 1].Substring(0, 7));
                    string subtitle = line[i].Substring(7);

                    SubStationEvent subevent = new SubStationEvent(startTime, endTime, subtitle);
                    _events.Add(subevent);
                }
            }
        }