コード例 #1
0
ファイル: CourseTime.cs プロジェクト: delavet/HelperUWP
 public CourseTime(int _day, int _start, int _timeSpan, week_kind _week_kind)
 {
     Day      = _day;
     Start    = _start;
     TimeSpan = _timeSpan;
     End      = Start + TimeSpan - 1;
     Week     = _week_kind;
 }
コード例 #2
0
 private static bool WeekKindInterrupt(week_kind w1, week_kind w2)
 {
     if (w1 == week_kind.all || w2 == week_kind.all)
     {
         return(true);
     }
     if (w1 == w2)
     {
         return(true);
     }
     return(false);
 }
コード例 #3
0
        public CourseChooseBlock(int day, int classOfDay, week_kind kind = week_kind.none)
        {
            this.InitializeComponent();

            REC                 = new Border();
            REC.Background      = new SolidColorBrush(Color.FromArgb(0XAF, 0XFF, 0XFF, 0XFF));
            REC.BorderBrush     = new SolidColorBrush(Colors.Gray);
            REC.BorderThickness = new Thickness(1);
            GRID.Children.Add(REC);
            REC.HorizontalAlignment = HorizontalAlignment.Stretch;
            REC.VerticalAlignment   = VerticalAlignment.Stretch;
            Day        = day;
            ClassOfDay = classOfDay;
            Kind       = kind;
        }
コード例 #4
0
ファイル: CourseTime.cs プロジェクト: delavet/HelperUWP
        public CourseTime(int _day, String start_end, week_kind _week_kind)
        {
            Day = _day;
            int    split     = start_end.IndexOf('-');
            String str_start = start_end.Substring(0, split);
            String str_end   = start_end.Substring(split + 1);

            try
            {
                Start = int.Parse(str_start);
                End   = int.Parse(str_end);
            }
            catch
            {
                Start = 2;
                End   = 1;
            }
            TimeSpan = End - Start + 1;
            Week     = _week_kind;
        }
コード例 #5
0
 public TimePoint(int _day, int _class, week_kind kind = week_kind.all)
 {
     DayOfWeek  = _day;
     ClassOfDay = _class;
     WeekKind   = kind;
 }
コード例 #6
0
 public static void DecodeElectiveHtml(String html)
 {
     ElectiveCourses.Clear();
     try
     {
         HtmlDocument doc = new HtmlDocument();
         doc.LoadHtml(html);
         HtmlNode           table = doc.GetElementbyId("classAssignment");
         HtmlNodeCollection trs   = table.ChildNodes;
         int row = -1;
         foreach (var tr in trs)
         {
             if (!tr.OuterHtml.Contains("</tr>"))
             {
                 continue;
             }
             ++row;
             if (row == 0)
             {
                 continue;
             }
             int col = -1;
             HtmlNodeCollection tds = tr.ChildNodes;
             foreach (var td in tds)
             {
                 if (!td.OuterHtml.Contains("</td>"))
                 {
                     continue;
                 }
                 ++col;
                 if (col == 0)
                 {
                     continue;
                 }
                 var attributes = td.Attributes;
                 if (attributes.AttributesWithName("style").Count() < 1)
                 {
                     continue;
                 }
                 HtmlNode  span        = td.Element("span");
                 String    innerString = span.InnerHtml;
                 week_kind tempKind    = week_kind.all;
                 if (innerString.Contains("单周"))
                 {
                     tempKind    = week_kind.odd;
                     innerString = innerString.Remove(innerString.IndexOf("单周"), 2);
                 }
                 else if (innerString.Contains("双周"))
                 {
                     tempKind    = week_kind.even;
                     innerString = innerString.Remove(innerString.IndexOf("双周"), 2);
                 }
                 else if (innerString.Contains("每周"))
                 {
                     innerString = innerString.Remove(innerString.IndexOf("每周"), 2);
                 }
                 String[] strings = innerString.Split(new String[] { "<br>" }, StringSplitOptions.RemoveEmptyEntries);
                 int      k       = 0;
                 while (k < strings.Length && strings[k].Replace(" ", "").Length == 0)
                 {
                     ++k;
                 }
                 if (k == strings.Length)
                 {
                     continue;
                 }
                 String tempCourseName = strings[k].Replace(" ", "");
                 if (ElectiveCourses.ContainsKey(tempCourseName))
                 {
                     ElectiveCourses[tempCourseName].TimePoints.Add(new TimePoint(col, row, tempKind));
                     continue;
                 }
                 ++k;
                 while (k < strings.Length && strings[k].Replace(" ", "").Length == 0)
                 {
                     ++k;
                 }
                 if (k == strings.Length)
                 {
                     continue;
                 }
                 String where = strings[k].Replace(" ", "");
                 String tempLocation = "未知地点", tempOther = "", tempExam = "";
                 int    pos = where.IndexOf(')');
                 if (pos != -1)
                 {
                     tempLocation = where.Substring(1, pos - 1);
                     if (tempLocation.Contains("备注"))
                     {
                         tempOther    = tempLocation;
                         tempLocation = "未知地点";
                     }
                 }
                 ++k;
                 while (k < strings.Length)
                 {
                     if (strings[k].Contains("考试时间:"))
                     {
                         int examPos = strings[k].IndexOf(':');
                         if (examPos != -1)
                         {
                             tempExam = strings[k].Substring(examPos + 1, 8);
                         }
                     }
                     else
                     {
                         tempOther += "\n" + strings[k];
                     }
                     ++k;
                 }
                 ElectiveCourses.Add(tempCourseName, new CourseInfo(tempCourseName, tempLocation, tempExam, CourseKind.Elective, tempOther));
                 ElectiveCourses[tempCourseName].TimePoints.Add(new TimePoint(col, row, tempKind));
             }
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine("fail to decode elective's HTML! at" + e.StackTrace);
     }
     foreach (var course in ElectiveCourses)
     {
         course.Value.Merge();
     }
     SaveCourses("ElectiveCourses", ElectiveCourses);
 }
コード例 #7
0
 private void REC_Tapped(object sender, TappedRoutedEventArgs e)
 {
     Kind = (week_kind)(((int)(_kind + 1)) % 4);
 }