Ejemplo n.º 1
0
        public ClassTableob(string html, DateTime begin, string studentnum = "10150111")
        {
            RandomColor rc = new RandomColor(studentnum);

            ClassTable = new List <List <Classob> >();
            TermBegin  = begin;
            if (ClassTable.Count == 0)
            {
                for (int i = 0; i < 8; i++)
                {
                    List <Classob> list = new List <Classob>();
                    ClassTable.Add(list);
                }
            }
            Regex regex = new Regex("<table[^>]*>.*</Table>");
            Match m     = regex.Match(html);

            regex = new Regex("<tr[^>]*>.*?</tr[^>]*>");
            MatchCollection mc        = regex.Matches(m.Value);
            string          teacher   = "";
            string          classname = "";
            string          date      = "";
            string          room      = "";
            Color           thiscolor = rc.Next();

            for (int trnum = 1; trnum < mc.Count; trnum++)
            {
                m = mc[trnum];
                string now = m.Value;
                if (Regex.IsMatch(now, "tr height=24"))
                {
                    thiscolor = rc.Next();
                    regex     = new Regex("<td[^>]*rowspan=(?<howmanytimes>\\d+)[^>]*>(?<class>[^<]*)</td><td[^>]*>\\d+</td><td[^>]*>(?<teacher>[^<]*)</td><td[^>]*>(?<date>[^<]*)</td><td [^>]*>(?<room>[^<]*)</td><td[^>]*>[^<]*</td><td[^>]*>[^<]*</td><td[^>]*>[^<]*</td></tr>");
                    m         = regex.Match(now);
                    GroupCollection gc = m.Groups;
                    teacher   = gc["teach"].Value;
                    classname = gc["class"].Value;
                    date      = gc["date"].Value;
                    room      = gc["room"].Value;
                    Classob nowclass = new Classob(teacher, classname, date, room, thiscolor);
                    ClassTable[nowclass.weekcode].Add(nowclass);
                }
                else
                {
                    regex = new Regex("<td[^>]*>(?<date>[^<]*)(<td[^>]*>(?<room>[^<]*))?");
                    m     = regex.Match(now);
                    GroupCollection gc = m.Groups;
                    date = gc["date"].Value;
                    if (!string.IsNullOrEmpty(gc["room"].Value))
                    {
                        room = gc["room"].Value;
                    }
                    Classob nowclass = new Classob(teacher, classname, date, room, thiscolor);
                    ClassTable[nowclass.weekcode].Add(nowclass);
                }
            }
            sort();
        }
Ejemplo n.º 2
0
 public EnemyBlob() : base(Colorizer.Next())
 {
     GenerateNewTargetPosition();
 }