private async Task HandleSelectMenuItemActivation(Guid localAccountId, NavigationManager.MainMenuSelections menuItem)
        {
            if (CurrentAccount != null && (localAccountId == Guid.Empty || CurrentAccount.LocalAccountId == localAccountId))
            {
                var mainScreen = GetMainScreenViewModel();
                if (mainScreen != null)
                {
                    Popups.Clear();
                    mainScreen.Popups.Clear();
                    if (mainScreen.AvailableItems.Contains(menuItem))
                    {
                        mainScreen.SelectedItem = menuItem;
                    }
                }
            }

            else
            {
                if (localAccountId != Guid.Empty)
                {
                    AccountsManager.SetLastLoginIdentifier(localAccountId);
                }
                NavigationManager.MainMenuSelection = menuItem;
                await HandleNormalLaunchActivation();
            }
        }
        private async Task HandleQuickAddItem(TaskOrEventType type)
        {
            if (CurrentAccount == null)
            {
                await HandleNormalLaunchActivation();
            }

            var mainScreen = GetMainScreenViewModel();

            if (mainScreen != null && mainScreen.CurrentAccount != null && mainScreen.Classes != null && mainScreen.Classes.Count > 0)
            {
                Popups.Clear();
                var newModel = AddTaskOrEventViewModel.CreateForAdd(mainScreen, new AddTaskOrEventViewModel.AddParameter()
                {
                    Classes = mainScreen.Classes.ToArray(),
                    DueDate = DateTime.Today,
                    Type    = type
                });

                // For iOS, we can't clear and then add, we need to replace
                if (mainScreen.Popups.Count >= 1)
                {
                    mainScreen.Popups[0] = newModel;
                    while (mainScreen.Popups.Count > 1)
                    {
                        mainScreen.Popups.RemoveAt(1);
                    }
                }
                else
                {
                    mainScreen.ShowPopup(newModel);
                }
            }
        }
        private async Task HandleViewTaskOrEventActivation(Guid localAccountId, Guid itemId)
        {
            if (CurrentAccount == null || CurrentAccount.LocalAccountId != localAccountId)
            {
                AccountsManager.SetLastLoginIdentifier(localAccountId);
                await HandleNormalLaunchActivation();
            }

            var mainScreen = GetMainScreenViewModel();

            if (mainScreen != null && mainScreen.CurrentAccount != null)
            {
                Popups.Clear();
                var singleExam = await SingleTaskOrEventViewItemsGroup.LoadAsync(localAccountId, itemId);

                if (singleExam != null && singleExam.Item != null)
                {
                    mainScreen.ShowItem(singleExam.Item);

                    // Remove all but latest popup
                    // Have to do this AFTER showing the popup since on iOS if we first clear and then show immediately, iOS freaks out
                    while (mainScreen.Popups.Count > 1)
                    {
                        mainScreen.Popups.RemoveAt(0);
                    }
                }
            }
        }
        private async Task HandleSelectMenuItemActivation(Guid localAccountId, NavigationManager.MainMenuSelections menuItem)
        {
            // If we already have a current account and it matches the specified (or unspecified) account ID
            if (CurrentAccount != null && (localAccountId == Guid.Empty || CurrentAccount.LocalAccountId == localAccountId))
            {
                var mainScreen = GetMainScreenViewModel();
                if (mainScreen != null)
                {
                    Popups.Clear();
                    mainScreen.Popups.Clear();
                    if (mainScreen.AvailableItems.Contains(menuItem))
                    {
                        mainScreen.SelectedItem = menuItem;
                    }
                }
            }

            // Otherwise it's a fresh boot, or wrong account
            else
            {
                if (localAccountId != Guid.Empty)
                {
                    AccountsManager.SetLastLoginIdentifier(localAccountId);
                }
                NavigationManager.MainMenuSelection = menuItem;
                await HandleNormalLaunchActivation();
            }
        }
 /// <summary>
 /// Tries to clear all popups under the user interaction lock. Won't throw exception.
 /// </summary>
 public async void TryClearPopupsViaUserInteraction()
 {
     try
     {
         await HandleUserInteractionAsync("ClearPopups", delegate
         {
             Popups.Clear();
         });
     }
     catch (Exception ex)
     {
         ExceptionHelper.ReportHandledException(ex);
     }
 }
        /// <summary>
        /// Required to be a valid semester ID
        /// </summary>
        /// <param name="semesterId"></param>
        /// <returns></returns>
        public async Task SetCurrentSemester(Guid semesterId, bool alwaysNavigate = false)
        {
            if (CurrentSemesterId == semesterId)
            {
                if (alwaysNavigate)
                {
                    // This is only called in case where we have a semester, so there'll always be available items
                    if (SelectedItem != AvailableItems.First())
                    {
                        SelectedItem = AvailableItems.First();
                    }

                    if (PowerPlannerApp.DoNotShowYearsInTabItems)
                    {
                        // We need to clear the Years page
                        Popups.Clear();
                    }
                }
                return;
            }

            await CurrentAccount.SetCurrentSemesterAsync(semesterId);

            CurrentSemesterId = semesterId;
            await OnSemesterChanged(); // Loads the classes

            UpdateAvailableItemsAndTriggerUpdateDisplay();

            if (AvailableItems.Any())
            {
                SelectedItem = AvailableItems.First();
            }
            else
            {
                SelectedItem = null;
            }

            if (PowerPlannerApp.DoNotShowYearsInTabItems && AvailableItems.Any())
            {
                // We need to clear the Years page
                Popups.Clear();
            }
        }
        public async Task HandleViewClassActivation(Guid localAccountId, Guid classId)
        {
            if (CurrentAccount != null && CurrentAccount.LocalAccountId == localAccountId)
            {
                var mainScreen = GetMainScreenViewModel();
                if (mainScreen != null)
                {
                    Popups.Clear();
                    mainScreen.Popups.Clear();
                    var dontWait = mainScreen.SelectClass(classId);
                }
            }

            else
            {
                AccountsManager.SetLastLoginIdentifier(localAccountId);
                NavigationManager.MainMenuSelection = NavigationManager.MainMenuSelections.Classes;
                NavigationManager.ClassSelection    = classId;
                await HandleNormalLaunchActivation();
            }
        }
        private async Task HandleQuickAddItem(AddHomeworkViewModel.ItemType type)
        {
            if (CurrentAccount == null)
            {
                await HandleNormalLaunchActivation();
            }

            var mainScreen = GetMainScreenViewModel();

            if (mainScreen != null && mainScreen.CurrentAccount != null && mainScreen.Classes != null && mainScreen.Classes.Count > 0)
            {
                Popups.Clear();
                mainScreen.Popups.Clear();
                mainScreen.ShowPopup(AddHomeworkViewModel.CreateForAdd(mainScreen, new AddHomeworkViewModel.AddParameter()
                {
                    Classes = mainScreen.Classes.ToArray(),
                    DueDate = DateTime.Today,
                    Type    = type
                }));
            }
        }
        public Task HandleViewDayActivation(Guid localAccountId, DateTime date)
        {
            if (CurrentAccount != null && CurrentAccount.LocalAccountId == localAccountId)
            {
                var mainScreen = GetMainScreenViewModel();
                if (mainScreen != null)
                {
                    var dayViewModel = (mainScreen.Content as TasksViewModel)?.Content as DayViewModel;
                    if (dayViewModel != null)
                    {
                        Popups.Clear();
                        mainScreen.Popups.Clear();
                        dayViewModel.CurrentDate = date;
                        return(Task.FromResult(true));
                    }
                }
            }

            NavigationManager.SetSelectedDate(date);
            NavigationManager.SetDisplayMonth(date);
            return(HandleSelectMenuItemActivation(localAccountId, NavigationManager.MainMenuSelections.Day));
        }
Exemplo n.º 10
0
        public async Task HandleQuickAddActivation(Guid localAccountId)
        {
            // If there's no current account, we need to first initialize that
            if (CurrentAccount == null)
            {
                // If we have a specific account, use it
                if (localAccountId != Guid.Empty)
                {
                    AccountsManager.SetLastLoginIdentifier(localAccountId);
                }

                await HandleNormalLaunchActivation();
            }

            // Else if we're logged into the wrong account
            else if (localAccountId != Guid.Empty && CurrentAccount.LocalAccountId != localAccountId)
            {
                AccountsManager.SetLastLoginIdentifier(localAccountId);
                await HandleNormalLaunchActivation();
            }

            // If there's still no account, stop
            if (CurrentAccount == null)
            {
                return;
            }

            var mainScreen = GetMainScreenViewModel();

            if (mainScreen != null && mainScreen.CurrentAccount != null && mainScreen.Classes != null && mainScreen.Classes.Count > 0)
            {
                Popups.Clear();
                mainScreen.Popups.Clear();
                mainScreen.ShowPopup(new QuickAddViewModel(mainScreen));
            }
        }
Exemplo n.º 11
0
 public void ClearPopups()
 {
     lock (Popups) Popups.Clear();
 }