// Start app using demo mode void StartDemoMode() { // Show loading screen whilst connecting // This loading screen is disabled in the CameraPageViewModel constructor Task.Run(() => userDialogs.ShowLoading("Loading demo mode...")); // Initialize mock general settings SettingsService.Initialize(true); CameraStore.GenerateCameras(); // Navigate to camera page NavigationParameters navigationParams = new NavigationParameters(); navigationParams.Add(Helpers.Constants.NAVIGATION_DEMO_MODE_STRING, true); Device.BeginInvokeOnMainThread(() => navigationService.NavigateAsync("CameraPage", navigationParams)); }
/// <summary> /// Callback method for starting connection /// </summary> async void OnConnectionStarted() { try { // Connect to IP bool success = connection.Connect(IPAddress); if (!success) { if (!QTMNetworkConnection.QTMVersionSupported) { // QTM is not supported userDialogs.Alert("Please make sure that you are connecting to a Windows PC with " + "a Qualisys Track Manager software version of at least 2.16", "Attention", "Dismiss"); } else { // There was an error with the connection notificationService.Show("Attention", "There was a connection error, please check IP address"); } return; } else if (connection.HasPassword()) { // NOTE: A new propmt configuration has to be created everytime we run it // if we do not do this the acr library will add an action to it and since // it is async it does not expect that and will thus throw an error PromptResult result = await userDialogs .PromptAsync( new PromptConfig() .SetTitle("Please enter password (blank for slave mode)") .SetOkText("Connect")); if (!result.Ok) { return; } // Connect to host connection.Connect(IPAddress, result.Text); if (!connection.TakeControl() && result.Text != "") { ToastAction toastAction = new ToastAction().SetText("Retry").SetAction(() => OnConnectionStarted()); ToastConfig toastConfig = new ToastConfig("Incorrect Password") .SetAction(toastAction); userDialogs.Toast(toastConfig); return; } } // Send connection instance to settings service if (!SettingsService.Initialize()) { // There was a problem when attempting to establish the connection userDialogs.Alert("There was a communication mismatch with QTM, please make sure you are running the" + " latest version of this application and that you have the QTM version specified in" + " the requirements", "Error", "Dismiss"); connection.Disconnect(); return; } // Show loading screen whilst connecting // This loading screen is disabled in the CameraPageViewModel constructor Task.Run(() => userDialogs.ShowLoading("Establishing connection...")); // Fetch information from system and fill structures accordingly CameraStore.GenerateCameras(); // Connection was successfull // Navigate to camera page NavigationParameters navigationParams = new NavigationParameters(); navigationParams.Add(Helpers.Constants.NAVIGATION_DEMO_MODE_STRING, false); Device.BeginInvokeOnMainThread(() => navigationService.NavigateAsync("CameraPage", navigationParams)); } catch (Exception e) { Debug.WriteLine(e); notificationService.Show("Attention", "Please make sure that QTM is up and running and that the cameras are plugged in"); Task.Run(() => userDialogs.HideLoading()); return; } }