Esempio n. 1
0
        private void ItemsSource_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            try
            {
                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                case NotifyCollectionChangedAction.Move:
                case NotifyCollectionChangedAction.Replace:
                    if (_indexToScrollTo == null)
                    {
                        _indexToScrollTo = e.NewStartingIndex;

                        _ = Task.Run(delegate
                        {
                            PortableDispatcher.GetCurrentDispatcher().Run(delegate
                            {
                                try
                                {
                                    _recyclerView.SmoothScrollToPosition(_indexToScrollTo.Value);
                                }
                                catch { }

                                _indexToScrollTo = null;
                            });
                        });
                    }
                    break;
                }
            }
            catch { }
        }
Esempio n. 2
0
        private void DispatchAndUpdateSyncStateProperties(Action action)
        {
            try
            {
                _updateSyncStatesPropertiesOperation++;
                int thisOperation = _updateSyncStatesPropertiesOperation;
                PortableDispatcher.GetCurrentDispatcher().Run(delegate
                {
                    try
                    {
                        if (_updateSyncStatesPropertiesOperation != thisOperation)
                        {
                            return;
                        }

                        action();
                    }
                    catch (Exception ex)
                    {
                        TelemetryExtension.Current?.TrackException(ex);
                    }
                });
            }
            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
Esempio n. 3
0
        public async void LoadGrades()
        {
            try
            {
                if (_hasGradesBeenRequested)
                {
                    return;
                }

                _hasGradesBeenRequested = true;

                await Task.Run(async delegate
                {
                    try
                    {
                        var dataStore = await GetDataStore();

                        DataItemGrade[] dataGrades;
                        DataItemMegaItem[] dataItems;

                        using (await Locks.LockDataForReadAsync())
                        {
                            Guid[] weightIds = this.Class.WeightCategories.Select(i => i.Identifier).ToArray();

                            dataGrades = dataStore.TableGrades.Where(i => weightIds.Contains(i.UpperIdentifier)).ToArray();

                            dataItems = dataStore.TableMegaItems.Where(i =>
                                                                       (i.MegaItemType == PowerPlannerSending.MegaItemType.Exam || i.MegaItemType == PowerPlannerSending.MegaItemType.Homework) &&
                                                                       i.UpperIdentifier == _classId &&
                                                                       i.WeightCategoryIdentifier != PowerPlannerSending.BaseHomeworkExam.WEIGHT_CATEGORY_EXCLUDED)
                                        .ToArray();

                            var unassignedItems = new MyObservableList <BaseViewItemHomeworkExam>();
                            unassignedItems.InsertSorted(dataItems
                                                         .Where(i => IsUnassignedChild(i))
                                                         .Select(i =>
                                                                 i.MegaItemType == PowerPlannerSending.MegaItemType.Homework ?
                                                                 new ViewItemHomework(i)
                            {
                                Class = this.Class, WeightCategory = ViewItemWeightCategory.UNASSIGNED
                            } as BaseViewItemHomeworkExam
                                        : new ViewItemExam(i)
                            {
                                Class = this.Class, WeightCategory = ViewItemWeightCategory.UNASSIGNED
                            }));

                            PortableDispatcher.GetCurrentDispatcher().Run(delegate
                            {
                                try
                                {
                                    foreach (var weight in this.Class.WeightCategories)
                                    {
                                        weight.AddGradesHelper(ViewItemWeightCategory.CreateGradeHelper);

                                        weight.FilterAndAddChildren <BaseDataItemHomeworkExamGrade>(dataGrades);
                                        weight.FilterAndAddChildren <BaseDataItemHomeworkExamGrade>(dataItems);
                                    }

                                    Class.CalculateEverything();

                                    UnassignedItems    = unassignedItems;
                                    HasUnassignedItems = unassignedItems.Count > 0;

                                    _loadGradesTaskSource.SetResult(true);
                                    IsGradesLoaded = true;
                                }
                                catch (Exception ex)
                                {
                                    TelemetryExtension.Current?.TrackException(ex);
                                }
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        TelemetryExtension.Current?.TrackException(ex);
                    }
                });
            }
            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
Esempio n. 4
0
 public ChangedItemListener(Guid accountId, Guid identifier, PortableDispatcher dispatcher)
 {
     _localAccountId = accountId;
     _identifier     = identifier;
     _dispatcher     = dispatcher;
 }