private async void RegisterWindow(ShortcutAction?shortcutAction) { this.Window = new UIWindow(UIScreen.MainScreen.Bounds); Window.BackgroundColor = new UIColor(1, 1); Window.TintColor = ColorResources.PowerPlannerAccentBlue; this.Window.RootViewController = UIStoryboard.FromName("LaunchScreen", null).InstantiateInitialViewController(); this.Window.MakeKeyAndVisible(); _mainAppWindow = new MainAppWindow(); await PortableApp.Current.RegisterWindowAsync(_mainAppWindow, new NativeiOSAppWindow(Window)); // Launch the app var mainWindowViewModel = _mainAppWindow.GetViewModel(); if (shortcutAction != null) { HandleShortcutAction(shortcutAction.Value); // We make sure to activate the normal launch, and then later the HandleLaunch kicks in if (!_hasActivatedWindow) { await mainWindowViewModel.HandleNormalLaunchActivation(); } } else { await mainWindowViewModel.HandleNormalLaunchActivation(); } ViewManager.RootViewModel = _mainAppWindow.ViewModel; }
private async void RegisterWindow() { this.Window = new UIWindow(UIScreen.MainScreen.Bounds); Window.BackgroundColor = new UIColor(1, 1); Window.TintColor = ColorResources.PowerPlannerAccentBlue; this.Window.RootViewController = UIStoryboard.FromName("LaunchScreen", null).InstantiateInitialViewController(); this.Window.MakeKeyAndVisible(); _mainAppWindow = new MainAppWindow(); await PortableApp.Current.RegisterWindowAsync(_mainAppWindow, new NativeiOSAppWindow(Window)); // Launch the app await _mainAppWindow.GetViewModel().HandleNormalLaunchActivation(); ViewManager.RootViewModel = _mainAppWindow.ViewModel; }
protected override void OnStop() { _mainAppWindow?.GetViewModel()?.HandleBeingLeft(); base.OnStop(); }
private async void HandleIntent() { try { if (Intent.Action == Intent.ActionView && Intent.DataString != null && Intent.DataString.StartsWith("powerplanner:?")) { var args = ArgumentsHelper.Parse(Intent.DataString.Substring("powerplanner:?".Length)); LaunchSurface launchContext = LaunchSurface.Normal; if (args != null) { launchContext = args.LaunchSurface; } var viewModel = _mainAppWindow.GetViewModel(); if (args is ViewPageArguments) { var viewPageArgs = args as ViewPageArguments; TrackLaunch(args, launchContext, "View" + viewPageArgs.Page); switch (viewPageArgs.Page) { // View agenda case ViewPageArguments.Pages.Agenda: await viewModel.HandleViewAgendaActivation(viewPageArgs.LocalAccountId); return; } } else if (args is ViewScheduleArguments) { var viewScheduleArgs = args as ViewScheduleArguments; TrackLaunch(args, launchContext, "ViewSchedule"); await viewModel.HandleViewScheduleActivation(viewScheduleArgs.LocalAccountId); return; } else if (args is ViewClassArguments) { var viewClassArgs = args as ViewClassArguments; TrackLaunch(args, launchContext, "ViewClass"); await viewModel.HandleViewClassActivation(viewClassArgs.LocalAccountId, viewClassArgs.ItemId); return; } else if (args is ViewHolidayArguments) { var viewHolidayArgs = args as ViewHolidayArguments; TrackLaunch(args, launchContext, "ViewHoliday"); await viewModel.HandleViewHolidayActivation(viewHolidayArgs.LocalAccountId, viewHolidayArgs.ItemId); return; } else if (args is ViewHomeworkArguments) { TrackLaunch(args, launchContext, "HomeworkExam"); var viewHomeworkArgs = args as ViewHomeworkArguments; await viewModel.HandleViewHomeworkActivation(viewHomeworkArgs.LocalAccountId, viewHomeworkArgs.ItemId); return; } else if (args is ViewExamArguments) { TrackLaunch(args, launchContext, "HomeworkExam"); var viewExamArgs = args as ViewExamArguments; await viewModel.HandleViewExamActivation(viewExamArgs.LocalAccountId, viewExamArgs.ItemId); return; } else if (args is QuickAddToCurrentAccountArguments) { TrackLaunch(args, launchContext, "QuickAdd"); await viewModel.HandleQuickAddActivation(Guid.Empty); return; } else if (args is QuickAddArguments) { TrackLaunch(args, launchContext, "QuickAdd"); var quickAddArgs = args as QuickAddArguments; await viewModel.HandleQuickAddActivation(quickAddArgs.LocalAccountId); return; } // Otherwise still track launch if from special surface TrackLaunch(args, launchContext, "Launch"); } } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } // For all other cases (like ActionMain), fallback action is launch as main await _mainAppWindow.GetViewModel().HandleNormalLaunchActivation(); }
private static async System.Threading.Tasks.Task HandleArguments(MainAppWindow mainAppWindow, string arguments, LaunchSurface launchContext) { try { MainWindowViewModel viewModel = mainAppWindow.GetViewModel(); var args = ArgumentsHelper.Parse(arguments); Guid desiredLocalAccountId = Guid.Empty; if (args is BaseArgumentsWithAccount) { desiredLocalAccountId = (args as BaseArgumentsWithAccount).LocalAccountId; } else { desiredLocalAccountId = AccountsManager.GetLastLoginLocalId(); } Guid currentLocalAccountId = Guid.Empty; if (viewModel.CurrentAccount != null) { currentLocalAccountId = viewModel.CurrentAccount.LocalAccountId; } // View schedule if (args is ViewScheduleArguments) { TrackLaunch(args, launchContext, "Schedule"); await viewModel.HandleViewScheduleActivation(desiredLocalAccountId); } // View class else if (args is ViewClassArguments) { TrackLaunch(args, launchContext, "Class"); var viewClassArgs = args as ViewClassArguments; await viewModel.HandleViewClassActivation(viewClassArgs.LocalAccountId, viewClassArgs.ItemId); } else if (args is ViewTaskArguments) { TrackLaunch(args, launchContext, "Task"); var viewTaskArgs = args as ViewTaskArguments; await viewModel.HandleViewTaskActivation(viewTaskArgs.LocalAccountId, viewTaskArgs.ItemId); } else if (args is ViewEventArguments) { TrackLaunch(args, launchContext, "Event"); var viewEventArgs = args as ViewEventArguments; await viewModel.HandleViewEventActivation(viewEventArgs.LocalAccountId, viewEventArgs.ItemId); } else if (args is ViewHolidayArguments) { TrackLaunch(args, launchContext, "Holiday"); var viewHolidayArgs = args as ViewHolidayArguments; await viewModel.HandleViewHolidayActivation(viewHolidayArgs.LocalAccountId, viewHolidayArgs.ItemId); } else if (args is QuickAddArguments) { TrackLaunch(args, launchContext, "QuickAdd"); var quickAddArgs = args as QuickAddArguments; await viewModel.HandleQuickAddActivation(quickAddArgs.LocalAccountId); } else if (args is QuickAddTaskToCurrentAccountArguments) { // Jump list was created before we included the launch surface, so we'll manually port it if (launchContext == LaunchSurface.Normal) { launchContext = LaunchSurface.JumpList; } TrackLaunch(args, launchContext, "QuickAddTask"); await viewModel.HandleQuickAddTask(); } else if (args is QuickAddEventToCurrentAccountArguments) { // Jump list was created before we included the launch surface, so we'll manually port it if (launchContext == LaunchSurface.Normal) { launchContext = LaunchSurface.JumpList; } TrackLaunch(args, launchContext, "QuickAddEvent"); await viewModel.HandleQuickAddEvent(); } else { TrackLaunch(args, launchContext, "Launch"); if (viewModel.Content == null) { await viewModel.HandleNormalLaunchActivation(); } } } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } }