Exemplo n.º 1
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();
            var week = await SemesterTime.GetWeekAsync();

            WeekToolbarItem.Text = $"第{week}周";
        }
Exemplo n.º 2
0
        public SemesterSelectionViewModel()
        {
            Semesters = new ObservableCollection <string>();
            Weeks     = new ObservableCollection <int>();

            // 一般是 20 周,如果 remote api 给的周数过多,则进行适配
            int max_week = Math.Max(20, SemesterTime.Week);
            var weeks    = Enumerable.Range(1, max_week).ToList();

            foreach (var w in weeks)
            {
                Weeks.Add(w);
                if (w == SemesterTime.Week)
                {
                    WeekSelectedItem = w;
                }
            }


            var semesters = SemesterTime.GetSemesterAll(2018);

            foreach (var s in semesters)
            {
                Semesters.Add(s);
                if (s == SemesterTime.Semester)
                {
                    SemesterSelectedItem = s;
                }
            }
        }
Exemplo n.º 3
0
        private async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                IEnumerable <IListItem> items;

                string semester = SemesterTime.GetThisSemester();
                int    week     = await SemesterTime.GetWeekAsync();

                if (Items.Count == 0)
                {
                    // 第一次获取先从本地文件缓存获取
                    items = await DataStore.GetCoursesFromCacheAsync(semester, week, dayOfWeek);
                }
                else
                {
                    // 手动刷新,则从网络Api获取
                    Items.Clear();
                    items = await DataStore.GetCoursesAsync(semester, week, dayOfWeek);
                }

                foreach (var item in items)
                {
                    Items.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 4
0
 public Semester(SemesterTime sname, int date)
 {
     season         = sname;
     SchoolYear     = date;
     coursesOffered = new TeachingCourse[10];
 }