예제 #1
0
                public UIShowHideOldItemsCell(string cellId, ClassViewItemsGroup classItemsGroup, TaskOrEventType type) : base(cellId)
                {
                    ContentView.BackgroundColor = UIColorCompat.SecondarySystemBackgroundColor;

                    _labelText = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Font          = UIFont.PreferredSubheadline,
                        TextColor     = ColorResources.PowerPlannerAccentBlue,
                        TextAlignment = UITextAlignment.Center
                    };

                    DataContext = classItemsGroup;

                    if (type == TaskOrEventType.Task)
                    {
                        BindingHost.SetLabelTextBinding(_labelText, nameof(classItemsGroup.IsPastCompletedTasksDisplayed), (isDisplayed) =>
                        {
                            return(((bool)isDisplayed) ? "Hide old tasks" : "Show old tasks");
                        });
                    }
                    else
                    {
                        BindingHost.SetLabelTextBinding(_labelText, nameof(classItemsGroup.IsPastCompletedEventsDisplayed), (isDisplayed) =>
                        {
                            return(((bool)isDisplayed) ? "Hide old events" : "Show old events");
                        });
                    }

                    ContentView.AddSubview(_labelText);
                    _labelText.StretchWidthAndHeight(ContentView, left: 16, top: 8, bottom: 8);

                    ContentView.SetHeight(44);
                }
예제 #2
0
        private static async Task <ClassData> LoadDataBlocking(AccountDataStore data, Guid classId, DateTime todayAsUtc, ClassTileSettings settings)
        {
            DateTime dateToStartDisplayingFrom = DateTime.SpecifyKind(settings.GetDateToStartDisplayingOn(todayAsUtc), DateTimeKind.Local);

            Guid semesterId = Guid.Empty;

            // We lock the outside, since we are allowing trackChanges on the view items groups (so we have a chance of loading a cached one)... and since we're on a background thread, the lists inside the
            // view items groups could change while we're enumerating, hence throwing an exception. So we lock it to ensure this won't happen, and then we return a copy of the items that we need.
            using (await Locks.LockDataForReadAsync())
            {
                // First we need to obtain the semester id
                var c = data.TableClasses.FirstOrDefault(i => i.Identifier == classId);

                if (c == null)
                {
                    return(null);
                }

                semesterId = c.UpperIdentifier;
            }

            // We need all classes loaded, to know what time the end of day is
            var scheduleViewItemsGroup = await ScheduleViewItemsGroup.LoadAsync(data.LocalAccountId, semesterId, trackChanges : true, includeWeightCategories : false);

            var classViewItemsGroup = await ClassViewItemsGroup.LoadAsync(
                localAccountId : data.LocalAccountId,
                classId : classId,
                today : DateTime.SpecifyKind(todayAsUtc, DateTimeKind.Local),
                viewItemSemester : scheduleViewItemsGroup.Semester,
                includeWeights : false);

            classViewItemsGroup.LoadTasksAndEvents();
            await classViewItemsGroup.LoadTasksAndEventsTask;

            List <ViewItemTaskOrEvent> copied;

            using (await classViewItemsGroup.DataChangeLock.LockForReadAsync())
            {
                // Class view group sorts the items, so no need to sort
                copied = classViewItemsGroup.Class.TasksAndEvents.Where(i => i.Date.Date >= dateToStartDisplayingFrom).ToList();
            }

            return(new ClassData()
            {
                Class = classViewItemsGroup.Class,
                AllUpcoming = copied
            });
        }
예제 #3
0
        protected override async Task LoadAsyncOverride()
        {
            try
            {
                ViewItemsGroupClass = await ClassViewItemsGroup.LoadAsync(_localAccountId, ClassId, _today, _semester);

                DetailsViewModel  = new ClassDetailsViewModel(this);
                HomeworkViewModel = new ClassHomeworkOrExamsViewModel(this, ClassHomeworkOrExamsViewModel.ItemType.Homework);
                ExamsViewModel    = new ClassHomeworkOrExamsViewModel(this, ClassHomeworkOrExamsViewModel.ItemType.Exams);
                TimesViewModel    = new ClassTimesViewModel(this);
                GradesViewModel   = new Class.ClassGradesViewModel(this);
            }
            catch (ClassViewItemsGroup.ClassNotFoundExcetion)
            {
                var parent = FindAncestor <PagedViewModel>();
                parent.Replace(this, new ClassesViewModel(parent));
                throw;
            }
            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
                RemoveViewModel();
            }
        }