public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // long-running startup tasks go here db = new DataService(); db.createDB(); foreach (var device in db.DevicesTable) { IDevice dev = DeviceTypeFactory.MakeDevice(device.FirmwareName, device); dev.DeviceDetails.Status = DeviceStatus.Missing; devices.Add(dev); } NavigationService.Navigate(typeof(Views.MainPage)); ssdpClient.Search(); wifiClient.Search(); searchTimer.Tick += SearchTimer_Tick; searchTimer.Interval = new TimeSpan(0, 1, 0); searchTimer.Start(); return Task.CompletedTask; }
// runs only when not restored from state public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // navigate to first page NavigationService.Navigate(typeof(Views.MainPage)); return Task.CompletedTask; }
// runs only when not restored from state public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { await Task.Delay(50); if (_settings.FirstRun) { Window.Current.Activate(); } else { NavigationService.Navigate(typeof(Views.MainPage)); } if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { var statusBar = StatusBar.GetForCurrentView(); if (statusBar != null) { statusBar.BackgroundOpacity = 1; statusBar.BackgroundColor = (Color)Application.Current.Resources["AccentColour"]; statusBar.ForegroundColor = Colors.White; } } }
// runs only when not restored from state public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // set hamburger menu to full screen mode on Mobile devices. if (DeviceUtils.Current().IsPhone()) Views.Shell.HamburgerMenu.IsFullScreen = true; if (!AuthHelper.IsCachedCredentialsAvailable()) { Debug.WriteLine("App.OnStartAsync() : no cached credentials available, loading login page..."); NavigationService.Navigate(typeof(Views.LoginPage)); } else { Debug.WriteLine("App.OnStartAsync() : cached credentials found, bypassing login page..."); await AuthHelper.AuthenticateAsync(); if (Settings.IsAlreadyConfigured) { Debug.WriteLine("App.OnStartAsync() : already set up, skipping to MainPage..."); NavigationService.Navigate(typeof(Views.MainPage)); } else { Debug.WriteLine("App.OnStartAsync() : not configured, starting setup wizard..."); NavigationService.Navigate(typeof(Views.SetupWizardHomePage)); } } }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { GoogleAnalytics.EasyTracker.GetTracker().SendEvent("Lifecycle", startKind.ToString(), null, 0); bool isNewLaunch = args.PreviousExecutionState == ApplicationExecutionState.NotRunning; if (isNewLaunch) { await InitLibrary(); var nav = new MergedNavigationService(NavigationService); nav.Configure(ViewModelLocator.SplashPageKey, typeof(Pages.SplashScreen)); nav.Configure(ViewModelLocator.FrontPageKey, typeof(FrontPage)); nav.Configure(ViewModelLocator.SubGalleryPageKey, typeof(SubGalleryPage)); nav.Configure(ViewModelLocator.SubredditBrowserPageKey, typeof(SubredditBrowserPage)); nav.Configure(ViewModelLocator.BrowserPageKey, typeof(BrowserPage)); if (!SimpleIoc.Default.IsRegistered<GalaSoft.MvvmLight.Views.INavigationService>()) SimpleIoc.Default.Register<GalaSoft.MvvmLight.Views.INavigationService>(() => nav); SimpleIoc.Default.Register<IViewModelLocator>(() => ViewModelLocator.GetInstance()); SimpleIoc.Default.Register<RemoteDeviceHelper>(); } JObject navigationParam = new JObject(); navigationParam["isNewLaunch"] = isNewLaunch; if (args is ProtocolActivatedEventArgs) { var protoArgs = args as ProtocolActivatedEventArgs; if (args.Kind == ActivationKind.Protocol) navigationParam["url"] = protoArgs.Uri.AbsoluteUri; } Portable.Helpers.StateHelper.SessionState["LaunchData"] = navigationParam; SimpleIoc.Default.GetInstance<GalaSoft.MvvmLight.Views.INavigationService>().NavigateTo(ViewModelLocator.SplashPageKey); }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // long-running startup tasks go here NavigationService.Navigate(typeof(Views.MainPage)); await Task.CompletedTask; }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { CoreApp.Initialize(Services.LocationServices.LocationService.Current, Services.DataServices.ProtoDataService.Current); await Task.Delay(500); NavigationService.Navigate(typeof(Views.MainPage)); await Task.CompletedTask; }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { if (args.Kind == ActivationKind.VoiceCommand) { var result = (args as VoiceCommandActivatedEventArgs).Result; var properties = result.SemanticInterpretation.Properties .ToDictionary(x => x.Key, x => x.Value); var command = result.RulePath.First(); if (command.Equals("FreeTextCommand")) { // get spoken text var text = properties.First(x => x.Key.Equals("textPhrase")).Value[0]; // remember to handle response appropriately var mode = properties.First(x => x.Key.Equals("commandMode")).Value; if (mode.Equals("voice")) { /* okay to speak */ } else { /* not okay to speak */ } // update value ViewModels.MainPageViewModel.Instance.Value = text; } else { /* unexpected command */ } } else { NavigationService.Navigate(typeof(Views.MainPage)); } return Task.CompletedTask; }
// runs only when not restored from state public async override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // Handle toast activation if (args is ToastNotificationActivatedEventArgs) { var toastActivationArgs = args as ToastNotificationActivatedEventArgs; // Parse the query string QueryString arguments = QueryString.Parse(toastActivationArgs.Argument); // See what action is being requested switch (arguments["action"]) { case "openurl": var url = arguments["url"]; await Launcher.LaunchUriAsync(new Uri(url)); break; case "showtemperature": var temperature = arguments["temperature"]; NavigationService.Navigate(typeof(Views.NotificationsPage), temperature); break; case "gettingfar": var distance = arguments["distance"]; NavigationService.Navigate(typeof(Views.NotificationsPage), distance); break; } } if (NavigationService.CurrentPageType != typeof(Views.MainPage)) NavigationService.Navigate(typeof(Views.MainPage)); }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { await ViewModelController.RefreshLibrary(); await ViewModelController.RefreshCollections(); NavigationService.Navigate(typeof(Views.MainPage)); await Task.CompletedTask; }
/// <summary> /// The OnStartAsync implementation. /// </summary> /// <remarks> /// Runs only when not restored from a state. /// </remarks> /// <param name="startKind">The kind of App start.</param> /// <param name="args">The arguments from the activation.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // Perform any long-running load await Task.Delay(0); // Navigate to the first page inside the shell this.NavigationService.Navigate(Pages.Main); }
// runs only when not restored from state public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // perform long-running load await Task.Delay(0); // navigate to first page NavigationService.Navigate(typeof(Views.MainPage)); }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { string arguments = string.Empty; if (DetermineStartCause(args) == AdditionalKinds.JumpListItem) { arguments = (args as LaunchActivatedEventArgs).Arguments; FileReceived?.Invoke(this, arguments); } NavigationService.Navigate(typeof(Views.MainPage), arguments); }
// runs only when not restored from state public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // perform long-running load await Task.Delay(0); // navigate to first page if (SettingsService.Instance.UserInteractionMode == false) NavigationService.Navigate(typeof(Views.MainPageHandleld)); else NavigationService.Navigate(typeof(Views.MainPageTeam)); }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { if ((args.Kind == ActivationKind.Launch) && ((args as LaunchActivatedEventArgs)?.PrelaunchActivated ?? false)) { // update pre-launch live tile } // start the user experience NavigationService.Navigate(typeof(Views.MainPage)); return Task.FromResult<object>(null); }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // long-running startup tasks go here //await Task.Delay(5000); //自定义代码段 SetTitleColor(); PlaybackService.Instance.StartBackgroundAudioTask(); NavigationService.Navigate(typeof(Views.DiscoveryPage)); await Task.CompletedTask; }
// runs only when not restored from state //public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) //{ // await Task.Delay(50); // NavigationService.Navigate(typeof(Views.MainPage)); //} //[TW] 1/16/2016 - Better fix for returning for suspending before release of 1.0.9 of template 10 public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // navigate to first page var nav = WindowWrapper.ActiveWrappers.FirstOrDefault(wrapper => object.ReferenceEquals(wrapper.Window, Window.Current)).NavigationServices; if (nav.Count > 1) { nav.Remove(nav[0]); } NavigationService.Navigate(typeof(Views.MainPage)); await Task.CompletedTask; }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { if (startKind == StartKind.Launch) { this.NavigationService.Navigate(typeof(Views.MainPage)); } else { // this.NavigationService.Navigate(typeof(Views.SecondPage)); } return Task.FromResult<object>(null); }
// runs only when not restored from state public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { await Task.Delay(3500); var param = string.Empty; var protocolArgs = args as ProtocolActivatedEventArgs; if (protocolArgs != null) { var uri = protocolArgs.Uri; var decoder = new Windows.Foundation.WwwFormUrlDecoder(uri.Query); param = decoder.GetFirstValueByName("filter"); } NavigationService.Navigate(typeof(Views.MainPage), param); }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // Init HockeySDK if (!string.IsNullOrEmpty(ApplicationKeys.HockeyAppToken)) HockeyClient.Current.Configure(ApplicationKeys.HockeyAppToken); await NavigationService.NavigateAsync(typeof(MainPage)); if (!string.IsNullOrEmpty(SettingsService.Instance.PtcAuthToken)) { // We have a stored token, let's go to game page NavigationService.Navigate(typeof(GameMapPage)); await ViewModelLocator.GameManagerViewModel.InitGame(true); } await Task.CompletedTask; }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { var shareArgs = args as ShareTargetActivatedEventArgs; if (shareArgs != null) { var key = SessionState.Add(typeof(ShareOperation), string.Empty, shareArgs.ShareOperation); NavigationService.Navigate(typeof(Views.MainPage), key.Key); } else { NavigationService.Navigate(typeof(Views.MainPage)); } return Task.CompletedTask; }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { var fileArgs = args as FileActivatedEventArgs; if (fileArgs != null && fileArgs.Files.Any()) { var file = fileArgs.Files.First() as StorageFile; var content = await FileIO.ReadTextAsync(file); NavigationService.Navigate(typeof(Views.MainPage), content); } else { NavigationService.Navigate(typeof(Views.MainPage), "Not activated by a file"); } }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { var authorization = GetParamsSetting(AuthorizationKey); if (authorization == null) authorization = false; var boolAuth = Convert.ToBoolean(authorization); if (boolAuth) { NavigationService.Navigate(typeof(NewsPage)); } else { NavigationService.Navigate(typeof(MainPage)); } await Task.CompletedTask; }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { switch (DetermineStartCause(args)) { case AdditionalKinds.SecondaryTile: var e = args as LaunchActivatedEventArgs; NavigationService.Navigate(typeof(Views.DetailPage), e.Arguments); break; case AdditionalKinds.Primary: case AdditionalKinds.Toast: case AdditionalKinds.Other: NavigationService.Navigate(typeof(Views.MainPage)); break; } return Task.FromResult<object>(null); }
// runs unless restored from state public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { Window.Current.Content = new Views.Shell(NavigationService); var largs = args as ILaunchActivatedEventArgs; if (largs?.TileId != null && largs?.TileId != "App") { // launched via a secondary tile NavigationService.Navigate(typeof(Views.DetailPage), largs.Arguments); } else { // launched via other/primary method NavigationService.Navigate(typeof(Views.MainPage)); } return Task.FromResult<object>(null); }
// runs only when not restored from state public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { await Task.Delay(1); switch (DecipherStartCause(args)) { case AdditionalKinds.Toast: case AdditionalKinds.SecondaryTile: var e = (args as ILaunchActivatedEventArgs); NavigationService.Navigate(typeof(Views.DetailPage), e.Arguments); break; default: NavigationService.Navigate(typeof(Views.MainPage)); break; } //return Task.FromResult<object>(null); }
// runs only when not restored from state public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs e) { // perform long-running load await Task.Delay(0); // Determine if the app was already open or not (by checking the state) // Already logged in: Check for toasts // Not logged in: Login, check for toasts, then do default action (navigation) // Authenticate in all cases, then perform navigation options // authenticated = true (either already logged in, or true login) Boolean authenticated = await state.loginViaSavedToken(); if (authenticated) { // Got a toast, determine type and navigate accordingly if (e is ToastNotificationActivatedEventArgs) { var toastActivationArgs = e as ToastNotificationActivatedEventArgs; dynamic args = JsonConvert.DeserializeObject<JObject>(toastActivationArgs.Argument); // New message // Navigate to that toast after login if (args.source == typeof(NewMessageToast).ToString()) { // args.args = conversation_id NavigationService.Navigate(typeof(Views.ConversationsPage), args.args); } else if (args.source == typeof(NewMatchToast).ToString()) { NavigationService.Navigate(typeof(Views.ConversationsPage), args.args); } } else { // Standard login, go to superficial page NavigationService.Navigate(typeof(Views.SuperficialPage)); } } else { // Todo: Invalid XAuth TOAST NavigationService.Navigate(typeof(Views.LoginPage)); } }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { if (args.Kind == ActivationKind.Launch) { var launchArgs = args as LaunchActivatedEventArgs; if (launchArgs.TileId != "My2Tile") { // start the user experience NavigationService.Navigate(typeof(Views.MainPage), launchArgs.Arguments); return Task.FromResult<object>(null); } } // start the user experience NavigationService.Navigate(typeof(Views.MainPage)); return Task.FromResult<object>(null); }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { switch (DetermineStartCause(args)) { case AdditionalKinds.SecondaryTile: var tileargs = args as LaunchActivatedEventArgs; NavigationService.Navigate(typeof(Views.DetailPage), tileargs.Arguments); break; case AdditionalKinds.Toast: var toastargs = args as ToastNotificationActivatedEventArgs; NavigationService.Navigate(typeof(Views.DetailPage), toastargs.Argument); break; case AdditionalKinds.Primary: case AdditionalKinds.Other: NavigationService.Navigate(typeof(Views.MainPage)); break; } return Task.CompletedTask; }
// runs only when not restored from state public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { await Task.Delay(50); if (args.Kind == ActivationKind.ProtocolForResults) { var protocolForResultsArgs = args as ProtocolForResultsActivatedEventArgs; NavigationService.Navigate(typeof(Views.MainPage), protocolForResultsArgs); return; } if (args.Kind == ActivationKind.Protocol) { var protocolArgs = args as ProtocolActivatedEventArgs; NavigationService.Navigate(typeof(Views.MainPage), protocolArgs); return; } NavigationService.Navigate(typeof(Views.MainPage)); }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { NavigationService.Navigate(typeof(Views.MainPage), "TheTest"); await Task.CompletedTask; }
// runs only when not restored from state public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { await Task.Delay(50); NavigationService.Navigate(typeof(Views.SearchPage)); }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // start the user experience NavigationService.Navigate(typeof(Views.MainPage), "123"); return(Task.FromResult <object>(null)); }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // init value bool IsLogin; try { int i = (int)localSettings.Values["ColorBoardSelectedIndex"]; bool b = (bool)localSettings.Values["IsStayAtSchool"]; bool bb = (bool)localSettings.Values["IsBus"]; bool bbb = (bool)localSettings.Values["IsDate"]; bool bbbb = (bool)localSettings.Values["showInactive"]; bool bbbbb = (bool)localSettings.Values["DashboardShowGradeOfTERM"]; bool bbbbbb = (bool)localSettings.Values["FirstTimeDisplayHomeDialog"]; var v = (string)localSettings.Values["dates"]; var vv = localSettings.Values["lang"].ToString(); var vvv = localSettings.Values["CalculateRule"]; IsLogin = (bool)localSettings.Values["IsFirstTimeLogin"]; } catch (System.NullReferenceException) { localSettings.Values["ColorBoardSelectedIndex"] = 0; localSettings.Values["FirstTimeDisplayHomeDialog"] = true; localSettings.Values["IsStayAtSchool"] = true; localSettings.Values["IsBus"] = false; localSettings.Values["IsDate"] = false; localSettings.Values["IsFirstTimeLogin"] = true; localSettings.Values["showInactive"] = false; localSettings.Values["DashboardShowGradeOfTERM"] = true; localSettings.Values["dates"] = ""; localSettings.Values["lang"] = 0; localSettings.Values["CalculateRule"] = 0; } // init themes /* * // init all colors * themes.Add(new Theme("Default", Windows.UI.Color.FromArgb(255, 0, 99, 177))); * var colors = GetStaticPropertyBag(typeof(Colors)); * foreach (KeyValuePair<string, object> colorPair in colors) { * themes.Add(new Theme(colorPair.Key, (Color)colorPair.Value)); * } */ themes.Add(new Theme("Liberty", Windows.UI.Color.FromArgb(255, 0, 99, 177))); themes.Add(new Theme("Despair", Windows.UI.Colors.SteelBlue)); themes.Add(new Theme("Miku", Windows.UI.Colors.DarkCyan)); themes.Add(new Theme("Monika", Windows.UI.Colors.CadetBlue)); themes.Add(new Theme("Soviet", Windows.UI.Colors.Red)); themes.Add(new Theme("Krunch", Windows.UI.Color.FromArgb(255, 255, 117, 117))); // themes.Add(new Theme("Doki", Windows.UI.Color.FromArgb(255, 255, 170, 213))); // themes.Add(new Theme("Doki", Windows.UI.Color.FromArgb(255, 217, 179, 179))); if ((bool)localSettings.Values["IsFirstTimeLogin"]) { await NavigationService.NavigateAsync(typeof(Views.LoginPage)); } else { Task <string> getHistoryJSON = StudentData.GetStudentData(StudentData.NewOrOld.New); string studataOld = await getHistoryJSON; StudentData studentData = new StudentData(StudentData.ParseJSON(studataOld), StudentData.ParseJSON(studataOld)); SetTitleBarUI(Windows.UI.Color.FromArgb(255, 0, 99, 177), Windows.UI.Color.FromArgb(0, 25, 114, 184)); await NavigationService.NavigateAsync(typeof(Views.SubjectsAssignmentsPage)); } // SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { NavigationService.Navigate(typeof(NewsPage)); return(Task.FromResult <object>(null)); }
/// <summary> /// Select start type /// </summary> /// <param name="startKind">Start kind</param> /// <param name="args">Arguments</param> /// <returns></returns> public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // long-running startup tasks go here //await Task.Delay(500000); // overit, zda je obrazek dobre nastaven var _settings = SettingsService.Instance; if (!await(new SettingsPartViewModel()).GetAddOnLicenseInfo()) { _settings.ActivateActionCenterControl = false; _settings.ActivateAdBlocker = false; _settings.ActivateBackupItems = false; _settings.ActivateBackupItemsInterval = false; _settings.ActivateBackupItemsType = false; _settings.ActivateShareItems = false; _settings.ActivateCustomSecuredNotificationInfo = false; _settings.ActivateSecondaryItemTiles = false; } CustomSettings.ShowAds = _settings.ActivateAdBlocker; if (args != null) { switch (args.Kind) { case ActivationKind.Protocol: NavigationService.Navigate(typeof(Views.MainPage)); break; #region Switch bullshit case ActivationKind.Search: case ActivationKind.ShareTarget: case ActivationKind.FileOpenPicker: case ActivationKind.FileSavePicker: case ActivationKind.CachedFileUpdater: case ActivationKind.ContactPicker: case ActivationKind.Device: case ActivationKind.PrintTaskSettings: case ActivationKind.CameraSettings: case ActivationKind.RestrictedLaunch: case ActivationKind.AppointmentsProvider: case ActivationKind.Contact: case ActivationKind.LockScreenCall: case ActivationKind.VoiceCommand: case ActivationKind.LockScreen: case ActivationKind.PickerReturned: case ActivationKind.WalletAction: case ActivationKind.PickFileContinuation: case ActivationKind.PickSaveFileContinuation: case ActivationKind.PickFolderContinuation: case ActivationKind.WebAuthenticationBrokerContinuation: case ActivationKind.WebAccountProvider: case ActivationKind.ComponentUI: case ActivationKind.ProtocolForResults: case ActivationKind.ToastNotification: case ActivationKind.Print3DWorkflow: case ActivationKind.DialReceiver: case ActivationKind.DevicePairing: case ActivationKind.UserDataAccountsProvider: case ActivationKind.FilePickerExperience: case ActivationKind.LockScreenComponent: case ActivationKind.ContactPanel: case ActivationKind.PrintWorkflowForegroundTask: case ActivationKind.GameUIProvider: case ActivationKind.StartupTask: case ActivationKind.CommandLineLaunch: #endregion case ActivationKind.Launch: switch (((LaunchActivatedEventArgs)args).Arguments) { case "Activities": NavigationService.Navigate(typeof(Activities)); break; case "Notes": NavigationService.Navigate(typeof(Notes)); break; default: var state = ApplicationData.Current.LocalSettings.Values["NavState"]; Debug.WriteLine(CurrentState); if (CurrentState == BootstrapperStates.Initialized || (state == null && string.IsNullOrWhiteSpace(state?.ToString()))) { NavigationService.Navigate(typeof(Views.MainPage)); } else { NavigationService.FrameFacade.SetNavigationState(state.ToString()); ApplicationData.Current.LocalSettings.Values["NavState"] = null; } break; } break; case ActivationKind.File: if (!NavigationService.FrameFacade.GetNavigationState().Contains("MainPage")) { NavigationService.Navigate(typeof(Views.MainPage)); } (Application.Current.Resources["VMLocator"] as VMLocator).SendMessage(new ShowModalActivationMsg() { Files = ((FileActivatedEventArgs)args).Files }); break; default: break; } } else { NavigationService.Navigate(typeof(Views.MainPage)); } await Task.CompletedTask; }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { NavigationService.Navigate(typeof(Views.PlayersView), "Runtime value"); return(Task.CompletedTask); }
private async void StartupOrchestratorAsync(IActivatedEventArgs e, StartKind kind) { DebugWrite($"kind:{kind} previous:{e.PreviousExecutionState}"); if (OriginalActivatedArgs == null) { OriginalActivatedArgs = e; // if resume tries to launch, don't continue on // StartupOrchestratorAsync will be called twice if (OriginalActivatedArgs == null) { OnResuming(this, null, AppExecutionState.Terminated); return; } } // is the kind really right? if (kind == StartKind.Launch && CurrentStateHistory.ContainsValue(BootstrapperStates.Launched)) { kind = StartKind.Activate; } else if (kind == StartKind.Launch && e.PreviousExecutionState == ApplicationExecutionState.Running) { kind = StartKind.Activate; } else if (kind == StartKind.Activate && e.PreviousExecutionState != ApplicationExecutionState.Running) { kind = StartKind.Launch; } // handle activate if (kind == StartKind.Activate) { // never activate until launch has completed while (!CurrentStateHistory.ContainsValue(BootstrapperStates.Launched)) { await Task.Delay(10); } await OnStartAsync(kind, e); CurrentState = BootstrapperStates.Started; WindowLogic.ActivateWindow(ActivateWindowSources.Activating, SplashLogic); CurrentState = BootstrapperStates.Activated; } // handle first-time launch else if (kind == StartKind.Launch) { SplashLogic.Show(e.SplashScreen, this); SetupKeyboardListeners(); SetupLifecycleListeners(); SetupSystemListeners(); SetupCustomTitleBar(); SetupExtendedSession(); await OnInitializeAsync(e); CurrentState = BootstrapperStates.Initialized; // if there no pre-existing root then generate root if (SplashLogic.Splashing || Window.Current.Content == null) { Window.Current.Content = CreateRootElement(e); } var IsPrelaunch = (e as LaunchActivatedEventArgs)?.PrelaunchActivated ?? false; // okay, now handle launch bool restored = false; switch (e.PreviousExecutionState) { case ApplicationExecutionState.Suspended: case ApplicationExecutionState.Terminated: OnResuming(this, null, IsPrelaunch ? AppExecutionState.Prelaunch : AppExecutionState.Terminated); if (AutoRestoreAfterTerminated) { restored = await LifecycleLogic.AutoRestoreAsync(e as ILaunchActivatedEventArgs, NavigationService); CurrentState = BootstrapperStates.Restored; } break; } // handle if pre-launch (no UI) if (IsPrelaunch) { var runOnStartAsync = false; await OnPrelaunchAsync(e, out runOnStartAsync); CurrentState = BootstrapperStates.Prelaunched; if (!runOnStartAsync) { return; } } // handle if not restored (new launch) if (!restored) { await OnStartAsync(StartKind.Launch, e); CurrentState = BootstrapperStates.Started; } // this will also hide any showing splashscreen WindowLogic.ActivateWindow(ActivateWindowSources.Launching, SplashLogic); CurrentState = BootstrapperStates.Launched; } }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { //NavigationService.Navigate(typeof(PlaygroundPage2)); //return; //return Task.CompletedTask; //PhoneCallPage newPlayer = null; //CoreApplicationView newView = CoreApplication.CreateNewView(); //var newViewId = 0; //await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => //{ // newPlayer = new PhoneCallPage(); // Window.Current.Content = newPlayer; // Window.Current.Activate(); // newViewId = ApplicationView.GetForCurrentView().Id; //}); //await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => //{ // var overlay = ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay); // if (overlay) // { // var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay); // preferences.CustomSize = new Size(340, 200); // var viewShown = await ApplicationViewSwitcher.TryShowAsViewModeAsync(newViewId, ApplicationViewMode.CompactOverlay, preferences); // } // else // { // //await ApplicationViewSwitcher.SwitchAsync(newViewId); // await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId); // } //}); //return; if (SettingsHelper.IsAuthorized) { if (args is ShareTargetActivatedEventArgs share) { ShareOperation = share.ShareOperation; NavigationService.Navigate(typeof(ShareTargetPage)); } else if (args is VoiceCommandActivatedEventArgs voice) { SpeechRecognitionResult speechResult = voice.Result; string command = speechResult.RulePath[0]; if (command == "ShowAllDialogs") { NavigationService.Navigate(typeof(MainPage)); } if (command == "ShowSpecificDialog") { //#TODO: Fix that this'll open a specific dialog NavigationService.Navigate(typeof(MainPage)); } else { NavigationService.Navigate(typeof(MainPage)); } } else if (args is ContactPanelActivatedEventArgs contact) { var backgroundBrush = Application.Current.Resources["TelegramBackgroundTitlebarBrush"] as SolidColorBrush; contact.ContactPanel.HeaderColor = backgroundBrush.Color; var store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite); var annotationStore = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite); var full = await store.GetContactAsync(contact.Contact.Id); var annotations = await annotationStore.FindAnnotationsForContactAsync(full); var remote = annotations[0].RemoteId; //var user = InMemoryCacheService.Current.GetUser(int.Parse(remote.Substring(1))); //if (user != null) //{ // NavigationService.Navigate(typeof(DialogPage), user.ToPeer()); //} //NavigationService.Navigate(typeof(MainPage), $"from_id={remote.Substring(1)}"); NavigationService.Navigate(typeof(DialogPage), new TLPeerUser { UserId = int.Parse(remote.Substring(1)) }); } else if (args is ProtocolActivatedEventArgs protocol) { NavigationService.Navigate(typeof(MainPage), protocol.Uri.ToString()); } else { var activate = args as ToastNotificationActivatedEventArgs; var launch = activate?.Argument ?? null; NavigationService.Navigate(typeof(MainPage), launch); } } else { NavigationService.Navigate(typeof(SignInWelcomePage)); } // NO! Many tv models have borders! //// Remove borders on Xbox //var device = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().QualifierValues; //bool isXbox = (device.ContainsKey("DeviceFamily") && device["DeviceFamily"] == "Xbox"); //if (isXbox == true) //{ // Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow); //} Window.Current.Activated -= Window_Activated; Window.Current.Activated += Window_Activated; Window.Current.VisibilityChanged -= Window_VisibilityChanged; Window.Current.VisibilityChanged += Window_VisibilityChanged; ShowStatusBar(); ColourTitleBar(); ApplicationView.GetForCurrentView().SetPreferredMinSize(new Windows.Foundation.Size(320, 500)); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; Task.Run(() => OnStartSync()); //return Task.CompletedTask; }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { await NavigationService.NavigateAsync(typeof(Views.MainPage)); }
/// <summary> /// /// </summary> /// <param name="startKind"></param> /// <param name="args"></param> /// <returns></returns> public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { bool forceToMainPage = false; // Check for updates (ignore resume) if (startKind == StartKind.Launch) { var latestUpdateInfo = await UpdateManager.IsUpdateAvailable(); while (latestUpdateInfo == null || latestUpdateInfo.Status == UpdateManager.UpdateStatus.NoInternet) { var dialog = new MessageDialog("Do you want try to connect again?", "No internet connection"); dialog.Commands.Add(new UICommand(Utils.Resources.CodeResources.GetString("YesText")) { Id = 0 }); dialog.Commands.Add(new UICommand(Utils.Resources.CodeResources.GetString("NoText")) { Id = 1 }); dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 1; var result = await dialog.ShowAsyncQueue(); if ((int)result.Id != 0) { App.Current.Exit(); } else { latestUpdateInfo = await UpdateManager.IsUpdateAvailable(); } } if (latestUpdateInfo.Status == UpdateManager.UpdateStatus.UpdateAvailable) { var dialog = new MessageDialog(string.Format(Utils.Resources.CodeResources.GetString("UpdatedVersion"), latestUpdateInfo.Version, latestUpdateInfo.Description)); dialog.Commands.Add(new UICommand(Utils.Resources.CodeResources.GetString("YesText")) { Id = 0 }); dialog.Commands.Add(new UICommand(Utils.Resources.CodeResources.GetString("NoText")) { Id = 1 }); dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 1; var result = await dialog.ShowAsyncQueue(); if ((int)result.Id != 0) { return; } var t1 = UpdateManager.InstallUpdate(); forceToMainPage = true; } else if (latestUpdateInfo.Status == UpdateManager.UpdateStatus.UpdateForced) { //start forced update var t1 = UpdateManager.InstallUpdate(); forceToMainPage = true; } else if (latestUpdateInfo.Status == UpdateManager.UpdateStatus.NextVersionNotReady) { var dialog = new MessageDialog("Please wait on next update", "This version is obsolete"); dialog.Commands.Add(new UICommand("OK")); dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 1; var result = await dialog.ShowAsyncQueue(); App.Current.Exit(); } } AsyncSynchronizationContext.Register(); var currentAccessToken = GameClient.LoadAccessToken(); if (currentAccessToken == null || forceToMainPage) { await NavigationService.NavigateAsync(typeof(MainPage)); } else { await GameClient.InitializeClient(); NavigationService.Navigate(typeof(GameMapPage), GameMapNavigationModes.AppStart); } await Task.CompletedTask; }
public override void OnStart(StartKind startKind, IActivatedEventArgs args) { var launchArgs = ExtractArgumentsString(args); if (launchArgs != null) { Logger.Info("Launch args: " + launchArgs); LaunchArgs = launchArgs.ParseQueryString(); } DispatcherHelper.Initialize(); LicenseHelper.Instance.Initialize(); if (!string.IsNullOrEmpty(ApplicationLanguages.PrimaryLanguageOverride)) { ServiceLocator.Vkontakte.Language = ApplicationLanguages.PrimaryLanguageOverride; } if (startKind == StartKind.Activate && args.PreviousExecutionState == ApplicationExecutionState.Running) { Window.Current.Activate(); if (LaunchArgs != null && LaunchArgs.ContainsKey("uid")) { long uid = long.Parse(LaunchArgs["uid"]); Messenger.Default.Send(new GoToDialogMessage() { UserId = uid }); } } else { Logger.AppStart(); var appView = ApplicationView.GetForCurrentView(); //appView.TitleBar.BackgroundColor = ((SolidColorBrush)Resources["ConversationOutboxMessageForegroundBrush"]).Color; //appView.TitleBar.InactiveBackgroundColor = Colors.Transparent;//appView.TitleBar.BackgroundColor; var c = this.RequestedTheme == ApplicationTheme.Light ? Colors.White : Colors.Black; var cf = this.RequestedTheme == ApplicationTheme.Light ? Colors.Black : Colors.White; appView.TitleBar.ButtonBackgroundColor = Color.FromArgb(0, c.R, c.G, c.B); //appView.TitleBar.BackgroundColor; appView.TitleBar.ButtonInactiveBackgroundColor = appView.TitleBar.ButtonBackgroundColor; appView.TitleBar.ButtonForegroundColor = cf; //appView.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;//appView.TitleBar.BackgroundColor; //appView.TitleBar.ForegroundColor = Colors.White; CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; if (AppSettings.AccessToken == null || AppSettings.AccessToken.HasExpired) { NavigationService.Navigate(typeof(LoginView)); } else { ServiceLocator.Vkontakte.AccessToken = AppSettings.AccessToken; NavigationService.Navigate(typeof(MainPage)); } } TileHelper.ClearTile(); }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { RegisterExceptionHandlingSynchronizationContext(); //throw new Exception("Test Exception."); //setTitleBar(); //Window.Current.CoreWindow.Activated += (s, a) => //{ // if (a.WindowActivationState != CoreWindowActivationState.Deactivated) // setTitleBar(); // //Debug.WriteLine("Activated. Theme = {0}", Application.Current.RequestedTheme); //}; if (startKind == StartKind.Launch) { await RegisterLiveTileTask(); //注册从开发人员中心接收通知 var engagementManager = StoreServicesEngagementManager.GetDefault(); await engagementManager.RegisterNotificationChannelAsync(); } if (args.Kind == ActivationKind.VoiceCommand) { //小娜激活 var commandArgs = args as VoiceCommandActivatedEventArgs; var speechRecognitionResult = commandArgs.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; switch (voiceCommandName) { case "fuli": await NavigationService.NavigateAsync(typeof(Views.PhotosPage), true); break; case "category": await NavigationService.NavigateAsync(typeof(Views.CategorysPage), true); break; default: return; } //var color = speechRecognitionResult.SemanticInterpretation.Properties["color"][0]; return; } if (args.Kind == ActivationKind.ToastNotification) { var toastActivationArgs = args as ToastNotificationActivatedEventArgs; var engagementManager = StoreServicesEngagementManager.GetDefault(); string originalArgs = engagementManager.ParseArgumentsAndTrackAppLaunch(toastActivationArgs.Argument); // 使用通知传递来的参数进行下一步 } await NavigationService.NavigateAsync(typeof(Views.MainPage)); //await NavigationService.NavigateAsync(typeof(Views.SettingsPage)); }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs e) { this.NavigationService.Navigate(typeof(Views.MainPage)); return(Task.FromResult <object>(null)); }
/// <summary> /// /// </summary> /// <param name="startKind"></param> /// <param name="args"></param> /// <returns></returns> public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { bool forceToMainPage = false; // Check for updates (ignore resume) if (startKind == StartKind.Launch) { var latestUpdateInfo = await UpdateManager.IsUpdateAvailable(); while (latestUpdateInfo == null || latestUpdateInfo.Status == UpdateManager.UpdateStatus.NoInternet) { var dialog = new MessageDialog("Do you want try to connect again?", "No internet connection"); dialog.Commands.Add(new UICommand(Utils.Resources.CodeResources.GetString("YesText")) { Id = 0 }); dialog.Commands.Add(new UICommand(Utils.Resources.CodeResources.GetString("NoText")) { Id = 1 }); dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 1; var result = await dialog.ShowAsyncQueue(); if ((int)result.Id != 0) { App.Current.Exit(); } else { latestUpdateInfo = await UpdateManager.IsUpdateAvailable(); } } if (latestUpdateInfo.Status == UpdateManager.UpdateStatus.UpdateAvailable) { var dialog = new MessageDialog(string.Format(Utils.Resources.CodeResources.GetString("UpdatedVersion"), latestUpdateInfo.Version, latestUpdateInfo.Description)); dialog.Commands.Add(new UICommand(Utils.Resources.CodeResources.GetString("YesText")) { Id = 0 }); dialog.Commands.Add(new UICommand(Utils.Resources.CodeResources.GetString("NoText")) { Id = 1 }); dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 1; var result = await dialog.ShowAsyncQueue(); if ((int)result.Id != 0) { return; } var t1 = UpdateManager.InstallUpdate(); forceToMainPage = true; } else if (latestUpdateInfo.Status == UpdateManager.UpdateStatus.UpdateForced) { //start forced update var t1 = UpdateManager.InstallUpdate(); forceToMainPage = true; } else if (latestUpdateInfo.Status == UpdateManager.UpdateStatus.NextVersionNotReady) { var twoLines = Environment.NewLine + Environment.NewLine; var dialog = new MessageDialog("Niantic has raised the minimum API level above what we have access to, so we've temporarily disabled the app to protect your account." + twoLines + "DO NOT attempt to bypass this check. Accounts that access lower APIs than the minimum WILL BE BANNED by Niantic." + twoLines + "An update will be ready soon. Please DO NOT open an issue on GitHub, you are seeing this message because we already know about it, and this is how we're telling you. " + "Thank you for your patience." + twoLines + "- The PoGo-UWP Team"); dialog.Commands.Add(new UICommand("OK")); dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 1; var result = await dialog.ShowAsyncQueue(); App.Current.Exit(); } } AsyncSynchronizationContext.Register(); var currentAccessToken = GameClient.LoadAccessToken(); if (currentAccessToken == null || forceToMainPage) { await NavigationService.NavigateAsync(typeof(MainPage)); } else { await GameClient.InitializeClient(); NavigationService.Navigate(typeof(GameMapPage), GameMapNavigationModes.AppStart); } await Task.CompletedTask; }
/// <summary> /// OnStartAsync is the one-stop-show override to handle when your app starts /// Template 10 will not call OnStartAsync if the app is restored from state. /// An app restores from state when the app was suspended and then terminated (PreviousExecutionState terminated). /// </summary> public abstract Task OnStartAsync(StartKind startKind, IActivatedEventArgs args);
private async void StartupOrchestratorAsync(IActivatedEventArgs e, StartKind kind) { DebugWrite($"kind:{kind} previous:{e.PreviousExecutionState}"); // check if this is the first activation at all, when we can save PreviousExecutionState and PrelaunchActivated if (!_firstActivationExecuted) { _firstActivationExecuted = true; PreviousExecutionState = e.PreviousExecutionState; PrelaunchActivated = (e as LaunchActivatedEventArgs)?.PrelaunchActivated ?? false; } // is the kind really right? if (kind == StartKind.Launch && CurrentStateHistory.ContainsValue(BootstrapperStates.Launching)) { kind = StartKind.Activate; } else if (kind == StartKind.Launch && e.PreviousExecutionState == ApplicationExecutionState.Running) { kind = StartKind.Activate; } else if (kind == StartKind.Activate && e.PreviousExecutionState != ApplicationExecutionState.Running) { kind = StartKind.Launch; } // handle activate if (kind == StartKind.Activate) { CurrentState = BootstrapperStates.Activating; // never activate until launch has completed while (!CurrentStateHistory.ContainsValue(BootstrapperStates.Launched)) { await Task.Delay(10); } while (CurrentStateHistory.Count(x => x.Value == BootstrapperStates.Starting) != CurrentStateHistory.Count(x => x.Value == BootstrapperStates.Started)) { await Task.Delay(10); } CurrentState = BootstrapperStates.Starting; await OnStartAsync(kind, e); CurrentState = BootstrapperStates.Started; WindowLogic.ActivateWindow(ActivateWindowSources.Activating, SplashLogic); CurrentState = BootstrapperStates.Activated; } // handle first-time launch else if (kind == StartKind.Launch) { CurrentState = BootstrapperStates.Launching; SplashLogic.Show(e.SplashScreen, this); // do some one-time things SetupKeyboardListeners(); SetupLifecycleListeners(); SetupSystemListeners(); SetupCustomTitleBar(); // default Unspecified extended session if (AutoExtendExecutionSession) { await ExtendedSessionService.StartUnspecifiedAsync(); } CurrentState = BootstrapperStates.Initializing; // OnInitializeAsync await OnInitializeAsync(e); CurrentState = BootstrapperStates.Initialized; // if there no pre-existing root then generate root if (SplashLogic.Splashing || Window.Current.Content == null) { Window.Current.Content = CreateRootElement(e); } // okay, now handle launch bool restored = false; var IsPrelaunch = (e as LaunchActivatedEventArgs)?.PrelaunchActivated ?? false; switch (e.PreviousExecutionState) { case ApplicationExecutionState.Suspended: case ApplicationExecutionState.Terminated: OnResuming(this, null, IsPrelaunch ? AppExecutionState.Prelaunch : AppExecutionState.Terminated); var launchedEventArgs = e as ILaunchActivatedEventArgs; if (AutoRestoreAfterTerminated && DetermineStartCause(e) == AdditionalKinds.Primary || launchedEventArgs?.TileId == string.Empty) { CurrentState = BootstrapperStates.Restoring; restored = await NavigationService.LoadAsync(); CurrentState = BootstrapperStates.Restored; } break; } // handle if pre-launch (no UI) if (IsPrelaunch) { CurrentState = BootstrapperStates.Prelaunching; var runOnStartAsync = false; await OnPrelaunchAsync(e, out runOnStartAsync); CurrentState = BootstrapperStates.Prelaunched; if (!runOnStartAsync) { return; } } // handle if not restored (new launch) if (!restored) { CurrentState = BootstrapperStates.Starting; await OnStartAsync(StartKind.Launch, e); CurrentState = BootstrapperStates.Started; } // this will also hide any showing splashscreen WindowLogic.ActivateWindow(ActivateWindowSources.Launching, SplashLogic); CurrentState = BootstrapperStates.Launched; } }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { NavigationService.Navigate(typeof(MainPage)); await Task.Yield(); }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { if (SettingsHelper.IsAuthorized) { if (args is ShareTargetActivatedEventArgs share) { ShareOperation = share.ShareOperation; NavigationService.Navigate(typeof(ShareTargetPage)); } else if (args is VoiceCommandActivatedEventArgs voice) { SpeechRecognitionResult speechResult = voice.Result; string command = speechResult.RulePath[0]; if (command == "ShowAllDialogs") { NavigationService.Navigate(typeof(MainPage)); } if (command == "ShowSpecificDialog") { //#TODO: Fix that this'll open a specific dialog NavigationService.Navigate(typeof(MainPage)); } else { NavigationService.Navigate(typeof(MainPage)); } } else if (args is ContactPanelActivatedEventArgs contact) { var backgroundBrush = Application.Current.Resources["TelegramBackgroundTitlebarBrush"] as SolidColorBrush; contact.ContactPanel.HeaderColor = backgroundBrush.Color; var annotationStore = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite); var store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite); if (store != null && annotationStore != null) { var full = await store.GetContactAsync(contact.Contact.Id); if (full == null) { goto Navigate; } var annotations = await annotationStore.FindAnnotationsForContactAsync(full); var first = annotations.FirstOrDefault(); if (first == null) { goto Navigate; } var remote = first.RemoteId; if (int.TryParse(remote.Substring(1), out int userId)) { NavigationService.Navigate(typeof(DialogPage), new TLPeerUser { UserId = userId }); } else { goto Navigate; } } else { NavigationService.Navigate(typeof(MainPage)); } Navigate: NavigationService.Navigate(typeof(MainPage)); } else if (args is ProtocolActivatedEventArgs protocol) { NavigationService.Navigate(typeof(MainPage), protocol.Uri.ToString()); } else { var activate = args as ToastNotificationActivatedEventArgs; var launch = activate?.Argument ?? null; NavigationService.Navigate(typeof(MainPage), launch); } } else { NavigationService.Navigate(typeof(SignInWelcomePage)); } Window.Current.Activated -= Window_Activated; Window.Current.Activated += Window_Activated; Window.Current.VisibilityChanged -= Window_VisibilityChanged; Window.Current.VisibilityChanged += Window_VisibilityChanged; Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -= Dispatcher_AcceleratorKeyActivated; Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated; UpdateBars(); ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(320, 500)); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; Theme.Current.Update(); App.RaiseThemeChanged(); Task.Run(() => OnStartSync()); //return Task.CompletedTask; }
/// <summary> /// OnStartAsync is the one-stop-show override to handle when your app starts /// Template 10 will not call OnStartAsync if the app is restored from state. /// An app restores from state when the app was suspended and then terminated (PreviousExecutionState terminated). /// </summary> public abstract void OnStart(StartKind startKind, IActivatedEventArgs args);
public override async void OnStart(StartKind startKind, IActivatedEventArgs args) { Logger.AppStart(); // TimeBombHelper.Initialize(); DispatcherHelper.Initialize(); CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) { var appView = ApplicationView.GetForCurrentView(); appView.TitleBar.ButtonBackgroundColor = Colors.Transparent; appView.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; appView.SetPreferredMinSize(new Windows.Foundation.Size(360, 500)); } await AudioService.Instance.LoadState(); var vk = SimpleIoc.Default.GetInstance <Vk>(); vk.Language = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; var lastFm = Ioc.Resolve <LastFm>(); lastFm.SessionKey = AppState.LastFmSession?.Key; if (AppState.VkToken == null || AppState.VkToken.HasExpired) { NavigationService.Navigate(typeof(LoginView)); } else { vk.AccessToken = AppState.VkToken; Messenger.Default.Send(new MessageUserAuthChanged { IsLoggedIn = true }); if (AppState.StartPage == StartPage.Mymusic) { NavigationService.Navigate(typeof(MyMusicView)); } else { NavigationService.Navigate(typeof(ExploreView)); } } //if (TimeBombHelper.HasExpired()) //{ // var dialog = new MessageDialog(Utils.Helpers.Resources.GetStringByKey("TimeBomb_ExpiredContent"), Utils.Helpers.Resources.GetStringByKey("TimeBomb_ExpiredTitle")); // dialog.Commands.Add(new UICommand(Utils.Helpers.Resources.GetStringByKey("TimeBomb_Install"), async command => // { // await Launcher.LaunchUriAsync(new Uri("https://www.microsoft.com/store/apps/9wzdncrdmsq3")); // })); // dialog.Commands.Add(new UICommand(Utils.Helpers.Resources.GetStringByKey("Close"))); // await dialog.ShowAsync(); // Application.Current.Exit(); //} }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { await Task.Delay(TimeSpan.FromSeconds(6)); NavigationService.Navigate(typeof(Views.MainPage)); }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { NavigationService.Navigate(typeof(Views.MainPage)); return(Task.CompletedTask); }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // TODO: add your long-running task here await NavigationService.NavigateAsync(typeof(Views.MainPage)); }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // Log OnStart. LifecycleLog.AppOnStart(startKind, args); // CoreApplication.EnablePrelaunch was introduced in Windows 10 version 1607 var canEnablePrelaunch = Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.ApplicationModel.Core.CoreApplication", "EnablePrelaunch"); if (startKind == StartKind.Activate) { if (args.Kind == ActivationKind.Protocol) { // Opens the URI for "navigation" (handling) on the GalleryPage. TODO: Open Auth completed page here. await NavigationService.NavigateAsync(typeof(Views.GalleryPage), SettingsService.Instance.FolderPath); Window.Current.Activate(); } } if (startKind == StartKind.Launch) { // Enable prelaunch. if (canEnablePrelaunch) { TryEnablePrelaunch(); } // End the Extended Execution Session. ClearExtendedExecution(); using (session = new ExtendedExecutionSession { Reason = ExtendedExecutionReason.Unspecified, Description = "Loading Memes from database" }) { // Register Revoked listener. session.Revoked += SessionRevoked; var accessStatus = BackgroundExecutionManager.GetAccessStatus(); if (accessStatus != BackgroundAccessStatus.AlwaysAllowed) { // Request background access. var accessGranted = await BackgroundExecutionManager.RequestAccessAsync(); // TODO: This line below prompts the user, which is better but it requires Windows Version 1803 which is too new, so uncomment this in a few versions. //var accessGranted = await BackgroundExecutionManager.RequestAccessKindAsync(BackgroundAccessRequestKind.AlwaysAllowed, "To allow faster launch performance"); } // Request extension. This is done so that if the application can finish loading data // from database when prelaunched or minimized (suspended prematurely). var result = await session.RequestExtensionAsync(); LifecycleLog.ExtensionRequestResult(result); if (result == ExtendedExecutionResult.Denied) { session.Dispose(); // TODO: Notify user of extension result denied. } // Set up database. using (new DisposableLogger(DatabaseLog.LoadBegin, DatabaseLog.LoadEnd)) { if (!(args.PreviousExecutionState == ApplicationExecutionState.Suspended && MediaDatas.Count > 0)) { await SetUpAndLoadFromDatabase(); } } // If MediaDatas have been loaded from database then open GalleryPage using those. if (MediaDatas.Count > 0) { await NavigationService.NavigateAsync(typeof(Views.GalleryPage), nameof(MediaDatas)); return; } // If no folder path has been set, have the user select one. if (string.IsNullOrEmpty(SettingsService.Instance.FolderPath)) { await NavigationService.NavigateAsync(typeof(Views.FolderSelectPage)); } else { await NavigationService.NavigateAsync(typeof(Views.GalleryPage)); } } } }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { NavigationService.Navigate(Pages.Master); return(Task.CompletedTask); }