コード例 #1
0
        private void UpdatePinButton()
        {
            try
            {
                if (ViewModel.Account == null || ViewModel.Class == null)
                {
                    return;
                }

                if (ClassTileHelper.IsPinned(ViewModel.Account.LocalAccountId, ViewModel.Class.Identifier))
                {
                    appBarPin.Icon  = new SymbolIcon(Symbol.UnPin);
                    appBarPin.Label = LocalizedResources.GetString("Settings_Tiles_ClassTile_ButtonUnpinLabel");
                }

                else
                {
                    appBarPin.Icon  = new SymbolIcon(Symbol.Pin);
                    appBarPin.Label = LocalizedResources.GetString("Settings_Tiles_ClassTile_ButtonPinLabel");
                }
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
コード例 #2
0
        private void UpdatePinButton()
        {
            try
            {
                if (ViewModel == null || ViewModel.ViewItemsGroupClass.Class == null)
                {
                    return;
                }

                if (ClassTileHelper.IsPinned(ViewModel.MainScreenViewModel.CurrentLocalAccountId, ViewModel.ViewItemsGroupClass.Class.Identifier))
                {
                    AppBarPinClass.Icon  = new SymbolIcon(Symbol.UnPin);
                    AppBarPinClass.Label = LocalizedResources.GetString("String_UnpinClass");
                }

                else
                {
                    AppBarPinClass.Icon  = new SymbolIcon(Symbol.Pin);
                    AppBarPinClass.Label = LocalizedResources.GetString("String_PinClass");
                }
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
コード例 #3
0
        private async void appBarPin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!await PowerPlannerApp.Current.IsFullVersionAsync())
                {
                    PowerPlannerApp.Current.PromptPurchase(LocalizedResources.GetString("Settings_Tiles_ClassTile_PromptPremiumFeature"));
                    return;
                }

                if (ViewModel.Account == null || ViewModel.Class == null)
                {
                    return;
                }

                if ((appBarPin.Icon as SymbolIcon).Symbol == Symbol.Pin)
                {
                    var data = await AccountDataStore.Get(ViewModel.Account.LocalAccountId);

                    await ClassTileHelper.PinTileAsync(ViewModel.Account, data, ViewModel.Class.Identifier, ViewModel.Class.Name, ColorTools.GetColor(ViewModel.Class.Color));
                }

                else
                {
                    await ClassTileHelper.UnpinTile(ViewModel.Account.LocalAccountId, ViewModel.Class.Identifier);
                }

                UpdatePinButton();
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
コード例 #4
0
        private async void UpdatePreviewTileNotifications()
        {
            try
            {
                XmlDocument notifContent = await ClassTileHelper.GetCurrentTileNotificationContentAsync(ViewModel.Account, ViewModel.Class.Identifier);

                if (notifContent == null)
                {
                    foreach (var tile in AllTiles())
                    {
                        tile.CreateTileUpdater().Clear();
                    }
                }

                else
                {
                    foreach (var tile in AllTiles())
                    {
                        tile.CreateTileUpdater().Update(new TileNotification(notifContent));
                    }
                }
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
コード例 #5
0
        private async void UpdateRealTile()
        {
            try
            {
                await ClassTileHelper.UpdateTileAsync(ViewModel.Account, await AccountDataStore.Get(ViewModel.Account.LocalAccountId), ViewModel.Class.Identifier);
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
コード例 #6
0
        protected override async Task LoadAsyncOverride()
        {
            await base.LoadAsyncOverride();

            if (Account.CurrentSemesterId == Guid.Empty)
            {
                return;
            }

            try
            {
                var viewItems = await ScheduleViewItemsGroup.LoadAsync(Account.LocalAccountId, Account.CurrentSemesterId, trackChanges : true, includeWeightCategories : false);

                HasSemester = true;

                // We lock since we're tracking changes, and can't let the list change while enumerating it initially
                using (await viewItems.DataChangeLock.LockForReadAsync())
                {
                    if (viewItems.Classes.Count == 0)
                    {
                        return;
                    }

                    HasClasses = true;

                    var classes = new List <ClassAndPinnedStatus>();

                    foreach (var c in viewItems.Classes)
                    {
                        classes.Add(new ClassAndPinnedStatus()
                        {
                            Class    = c,
                            IsPinned = ClassTileHelper.IsPinned(Account.LocalAccountId, c.Identifier)
                        });
                    }

                    Classes = classes;
                }
            }
            catch (SemesterNotFoundException) { }
        }
コード例 #7
0
        private async void appBarPinClass_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!(await PowerPlannerApp.Current.IsFullVersionAsync()))
                {
                    PowerPlannerApp.Current.PromptPurchase(LocalizedResources.GetString("String_PinningClassPremiumFeatureMessage"));
                    return;
                }

                if (ViewModel == null || ViewModel.ViewItemsGroupClass.Class == null)
                {
                    return;
                }

                if ((AppBarPinClass.Icon as SymbolIcon).Symbol == Symbol.Pin)
                {
                    var acct = await AccountsManager.GetOrLoad(ViewModel.MainScreenViewModel.CurrentLocalAccountId);

                    var data = await AccountDataStore.Get(ViewModel.MainScreenViewModel.CurrentLocalAccountId);

                    await ClassTileHelper.PinTileAsync(acct, data, ViewModel.ViewItemsGroupClass.Class.Identifier, ViewModel.ViewItemsGroupClass.Class.Name, ColorTools.GetColor(ViewModel.ViewItemsGroupClass.Class.Color));
                }

                else
                {
                    await ClassTileHelper.UnpinTile(ViewModel.MainScreenViewModel.CurrentLocalAccountId, ViewModel.ViewItemsGroupClass.Class.Identifier);
                }

                UpdatePinButton();
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }