Beispiel #1
0
        //为ComboBox创建数据绑定列表
        private void semesterComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string key = selectedCourseComboBox.SelectedItem.ToString();

            if (!File.Exists(".\\data\\SC-" + semesterToPara[key] + ".mt"))
            {
                File.Create(".\\data\\SC-" + semesterToPara[key] + ".mt").Close();
                string       rawData      = schedule.GetSelectedCourseRawData(semesterToPara[key]);
                StreamWriter streamWriter = new StreamWriter(".\\data\\SC-" + semesterToPara[key] + ".mt");
                streamWriter.Write(rawData);
                streamWriter.Close();
            }
            StreamReader reader     = new StreamReader(".\\data\\SC-" + semesterToPara[key] + ".mt");
            var          courseData = HtmlToTuple.SelectedCourseConverter(reader.ReadToEnd());

            reader.Close();
            List <SelectedCourse> courseList = new List <SelectedCourse>();

            foreach (var course in courseData.Item2)
            {
                courseList.Add(new SelectedCourse(course[0], course[1], course[2],
                                                  course[3], course[4], course[5], course[6]));
            }
            selectCourseListView.ItemsSource = courseList;
        }
Beispiel #2
0
        private void ComboBoxBinding()
        {
            semesterToPara = HtmlToTuple.SemesterGenerate(webVpnUsername.Text);
            selectedCourseComboBox.ItemsSource = semesterToPara.Keys;
            semesterComboBox2.ItemsSource      = semesterToPara.Keys;

            List <int> weekList = new List <int>();

            for (int i = 1; i < 23; i++)
            {
                weekList.Add(i);
            }
            weekComboBox.ItemsSource  = weekList;
            weekComboBox2.ItemsSource = weekList;
        }
Beispiel #3
0
        private void creditTabitem_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!File.Exists(".\\data\\credit.mt"))
            {
                return;
            }
            StreamReader reader      = new StreamReader(".\\data\\credit.mt");
            var          creditTuple = HtmlToTuple.CreditConverter(reader.ReadToEnd());

            reader.Close();
            List <Credits> creditList = new List <Credits>();

            foreach (var item in creditTuple.Item2)
            {
                creditList.Add(new Credits(item[0], item[1], item[2], item[3], item[4], item[5], item[6], item[7], item[8]));
            }
            creditListView.ItemsSource = creditList;
        }
Beispiel #4
0
        private void scoreTabitem_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!File.Exists(".\\data\\score.mt"))
            {
                return;
            }
            StreamReader reader     = new StreamReader(".\\data\\score.mt");
            var          scoreTuple = HtmlToTuple.ScoreConverter(reader.ReadToEnd());

            reader.Close();
            List <Scores> scoreList = new List <Scores>();

            foreach (var item in scoreTuple.Item2)
            {
                scoreList.Add(new Scores(item[0], item[1], item[2], item[3], item[4], item[5]));
            }
            scoreListView.ItemsSource = scoreList;
        }
Beispiel #5
0
        private void todayScheduleTabitem_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!File.Exists(".\\data\\time.dat"))
            {
                return;
            }
            weekComboBox2.IsEnabled = false;
            resetButton.IsEnabled   = true;
            List <string> header = new List <string> {
                "第1,2节", "第3,4节", "第5,6节", "第7,8节", "晚上"
            };
            StreamReader reader             = new StreamReader(".\\data\\time.dat");
            DateTime     firstDayOfSemester = DateTime.Parse(reader.ReadToEnd());

            reader.Close();
            DateTime today    = DateTime.Now.Date;
            int      span     = today.Subtract(firstDayOfSemester).Days;
            int      remainer = span % 7;

            reader = new StreamReader(".\\data\\CC-" + semesterToPara.Last().Value + ".mt");
            var courseSchedule = HtmlToTuple.CourseScheduleConverter(
                reader.ReadToEnd());

            reader.Close();
            List <TodaySchedule> todaySchedules = new List <TodaySchedule>();
            int temp = 0, count = 0;

            foreach (var time in courseSchedule.Item2[span / 7])
            {
                todaySchedules.Add(new TodaySchedule(header[temp], time[remainer]));
                temp++;
                if (time[remainer] != null)
                {
                    count++;
                }
            }
            todayScheduleListView.ItemsSource = todaySchedules;
            todayLabel.Content = "今天是" + today.ToShortDateString() + " " + today.DayOfWeek + ", 你有" + count + "节课";
        }
Beispiel #6
0
        private void semesterComboBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            weekComboBox.IsEnabled = true;
            string key = semesterComboBox2.SelectedItem.ToString();

            if (!File.Exists(".\\data\\CC-" + semesterToPara[key] + ".mt"))
            {
                File.Create(".\\data\\CC-" + semesterToPara[key] + ".mt").Close();
                string       rawData      = schedule.GetScheduleRawData(semesterToPara[key]);
                StreamWriter streamWriter = new StreamWriter(".\\data\\CC-" + semesterToPara[key] + ".mt");
                streamWriter.Write(rawData);
                streamWriter.Close();
            }

            if (weekComboBox.SelectedIndex == -1)
            {
                weekComboBox.SelectedIndex = 1;
            }

            StreamReader reader = new StreamReader(".\\data\\CC-" + semesterToPara[key] + ".mt");
            Tuple <List <string>, List <List <List <string> > > > tuple = HtmlToTuple.CourseScheduleConverter(
                reader.ReadToEnd());

            reader.Close();

            List <CourseSchedule> schedulesList = new List <CourseSchedule>();
            int index = 0;

            foreach (var timeSchedule in tuple.Item2[weekComboBox.SelectedIndex])
            {
                schedulesList.Add(new CourseSchedule(tuple.Item1[index],
                                                     timeSchedule[0], timeSchedule[1], timeSchedule[2],
                                                     timeSchedule[3], timeSchedule[4], timeSchedule[5], timeSchedule[6]));
                index++;
            }
            weekScheduleListView.ItemsSource = schedulesList;
        }