Esempio n. 1
0
        protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            base.OnNavigatingFrom(e);

            LocationService.PositionChanged -= LoadNearestStations;

            if (nearestLazyBlock != null)
            {
                nearestLazyBlock.Cancel();
            }
        }
Esempio n. 2
0
        private void Load(bool refresh)
        {
            if (lecturesLazyBlock != null)
            {
                lecturesLazyBlock.Cancel();
                lecturesLazyBlock = null;
            }
            var course = App.Crawler.GetCourse(courseId);

            if (!course.Active)
            {
                if (course.HasFinished)
                {
                    messageTextBlock.Text = "Lectures no longer available";
                }
                else
                {
                    messageTextBlock.Text = "Lectures not available yet";
                }
            }
            else
            {
                if (refresh)
                {
                    course = App.Crawler.RefreshCourse(course.Id);
                }
                lecturesLazyBlock = new LazyBlock <LectureSection[]>(
                    "lectures",
                    "No lectures available. Make sure you have accepted the honor code.",
                    course.LectureSections,
                    a => a.Length == 0,
                    new LazyBlockUI <LectureSection[]>(
                        this,
                        lectureSections => pivot.ItemsSource = lectureSections,
                        () => pivot.ItemsSource != null,
                        messageTextBlock),
                    false,
                    null,
                    success =>
                {
                    if (!success)
                    {
                        ErrorReporting.Log("Failed to get lectures");
                    }
                },
                    null);
            }
        }
Esempio n. 3
0
 protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     base.OnNavigatingFrom(e);
     if (coursesLazyBlock != null)
     {
         coursesLazyBlock.Cancel();
     }
 }
Esempio n. 4
0
 protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     base.OnNavigatingFrom(e);
     if (lecturesLazyBlock != null)
     {
         lecturesLazyBlock.Cancel();
     }
     if (videoLazyBlock != null)
     {
         videoLazyBlock.Cancel();
     }
 }
Esempio n. 5
0
 protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     base.OnNavigatingFrom(e);
     if (e.NavigationMode == NavigationMode.New && e.Uri.OriginalString == "app://external/")
     {
         //running in background
         return;
     }
     if (journeyElementsLazyBlock != null)
     {
         journeyElementsLazyBlock.Cancel();
     }
 }
Esempio n. 6
0
 private void LoadCourses(string email, string password, bool refresh)
 {
     if (App.Crawler == null)
     {
         App.Crawler = new Crawler(email, password, Cache.GetFiles(), Cache.SaveFile, DownloadInfo.Create);
     }
     if (refresh)
     {
         App.Crawler.RefreshCourses();
     }
     if (coursesLazyBlock != null)
     {
         coursesLazyBlock.Cancel();
     }
     coursesLazyBlock = new LazyBlock <Course[]>(
         "courses",
         null,
         App.Crawler.Courses,
         _ => false,
         new LazyBlockUI <Course[]>(
             this,
             courses =>
     {
         var active   = new List <Course>();
         var upcoming = new List <Course>();
         var finished = new List <Course>();
         foreach (var course in courses)
         {
             if (course.HasFinished)
             {
                 finished.Add(course);
             }
             else if (course.Active)
             {
                 active.Add(course);
             }
             else
             {
                 upcoming.Add(course);
             }
         }
         activeCourses.ItemsSource   = active;
         upcomingCourses.ItemsSource = upcoming;
         finishedCourses.ItemsSource = finished;
         activeCoursesCourseCatalogButton.Visibility   = activeCoursesEmptyMessage.Visibility = active.Count == 0 ? Visibility.Visible : Visibility.Collapsed;
         upcomingCoursesCourseCatalogButton.Visibility = upcomingCoursesEmptyMessage.Visibility = upcoming.Count == 0 ? Visibility.Visible : Visibility.Collapsed;
         finishedCoursesEmptyMessage.Visibility        = finished.Count == 0 ? Visibility.Visible : Visibility.Collapsed;
         if (active.Count == 0)
         {
             if (upcoming.Count == 0)
             {
                 pivot.SelectedIndex = 2;
             }
             else
             {
                 pivot.SelectedIndex = 1;
             }
         }
     },
             () => activeCourses.ItemsSource != null,
             messageTextBlock),
         false,
         _ =>
     {
         activeCoursesEmptyMessage.Visibility   = Visibility.Collapsed;
         upcomingCoursesEmptyMessage.Visibility = Visibility.Collapsed;
         finishedCoursesEmptyMessage.Visibility = Visibility.Collapsed;
     },
         success =>
     {
         if (!success)
         {
             ErrorReporting.Log("Failed to get courses");
         }
     },
         null);
 }