Esempio n. 1
0
        private async void Refresh_Click(object sender, RoutedEventArgs e)
        {
            contentRing.IsActive = true;

            var htmlResources = await LNUWebProcess.GetLNUFromLeftRequest(MainPage.LoginClient, currentUri.ToString());

            await CacheHelpers.SaveSpecificCacheValue(MainPage.LoginCache.UserID, htmlResources);

            var nameList = DataProcess.FetchScheduleTableFromHtml(htmlResources);

            TableGrid.Children.Clear();
            // Show the schedule table
            InitTableView(nameList);

            var list = DataProcess.FetchScheduleListFromHtml(htmlResources);

            ScheduleQueue.Clear();
            ScheduleQueue.AddRange(list);
            nameList.ForEach(item => { // finish lecture message into ScheduleQueue items .
                ScheduleQueue.FindAll(i => i.Title == GetSingleTitle(item.WholeTitle)).ForEach(s => { if (s.Lecturer == null)
                                                                                                      {
                                                                                                          s.Lecturer = GetLecturerName(item.WholeTitle);
                                                                                                      }
                                                                                               });
            });

            CourseListView.ItemsSource = ScheduleQueue;

            contentRing.IsActive = false;
        }
Esempio n. 2
0
        private void InitTableView(List <Core.Models.ContentModels.ScheduleTip> nameList)
        {
            var random = new Random();

            for (int row = 0; row < 8; row++)
            {
                for (int column = 0; column < 8; column++)
                {
                    var find   = nameList.FindIndex(item => item.Row == row && item.Column == column);
                    var newTip = find == -1 ?
                                 new Controls.ScheduleTip { // the (row, column) has no course to set in.
                        Background = (row == 0 || column == 0) ?
                                     TableFrameBackColor :
                                     TableContentBackColor,
                        ClickVisible = Visibility.Collapsed,
                    } :
                    new Controls.ScheduleTip {
                        Background   = Background = GetBackgroundRandom(random.Next() % 16),
                        TipTitle     = GetSingleTitle(nameList[find].WholeTitle),
                        TipLecture   = GetLecturerName(nameList[find].WholeTitle),
                        ClickVisible = Visibility.Visible,
                        Tag          = column + "-" + row,
                    };
                    if (find != -1)
                    {
                        newTip.InnerButton.CommandParameter = newTip.Tag;
                        newTip.InnerButton.Click           += (sender, args) => {
                            PopupBackground.Background = newTip.Background;
                            SetPopupOpenStatus(ScheduleQueue.Find(i => { return(i.Time == (sender as Button).CommandParameter as string); }));
                        };
                    }
                    if (column == 0)
                    {
                        newTip.Width = 50;
                    }
                    if (row == 0)
                    {
                        newTip.Height = 50;
                    }
                    if (row == 0 && column > 0)
                    {
                        newTip.TipFront = GetWeekDay(column);
                    }
                    if (row > 0 && column == 0)
                    {
                        newTip.TipFront = row + "";
                    }
                    TableGrid.Children.Add(newTip);
                    Grid.SetRow(newTip, row);
                    Grid.SetColumn(newTip, column);
                }
            }
        }
Esempio n. 3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var args = e.Parameter as NavigateParameter;

            if (args == null || args.ToUri == null)   // make sure the navigation action is right.
            {
                ReportHelper.ReportAttention(GetUIString("WebViewLoadError"));
                return;
            }
            if (args.MessageBag as string != null)
            {
                navigateTitle = navigateTitlePath.Text = args.MessageBag as string;
            }
            contentRing.IsActive = true;
            currentUri           = args.ToUri;
            thisPageType         = args.ToFetchType;
            thisNaviType         = args.NaviType;

            var cache = await CacheHelpers.ReadSpecificCacheValue(MainPage.LoginCache.UserID);

            var htmlResources = cache ?? await LNUWebProcess.GetLNUFromLeftRequest(MainPage.LoginClient, args.ToUri.ToString());

            if (cache == null && htmlResources != null)
            {
                await CacheHelpers.SaveSpecificCacheValue(MainPage.LoginCache.UserID, htmlResources);
            }
            var nameList = DataProcess.FetchScheduleTableFromHtml(htmlResources);

            // Show the schedule table
            InitTableView(nameList);

            var list = DataProcess.FetchScheduleListFromHtml(htmlResources);

            ScheduleQueue.Clear();
            ScheduleQueue.AddRange(list);
            nameList.ForEach(item => { // finish lecture message into ScheduleQueue items .
                ScheduleQueue.FindAll(i => i.Title == GetSingleTitle(item.WholeTitle)).ForEach(s => { if (s.Lecturer == null)
                                                                                                      {
                                                                                                          s.Lecturer = GetLecturerName(item.WholeTitle);
                                                                                                      }
                                                                                               });
            });

            CourseListView.ItemsSource = ScheduleQueue;

            contentRing.IsActive = false;
        }