/// <summary> /// Sets the Lockscreen Image using a file within the Application Storage /// </summary> /// <param name="localStorageFile">A file within the Application Storage</param> /// <returns>If the Lockscreen Image was successfully Set</returns> public override async Task <bool> SetImage(StorageFile localStorageFile) { if (localStorageFile == null) { return(false); } if (!IsSupported) { return(false); } try { if (!await UserProfilePersonalizationSettings.Current.TrySetLockScreenImageAsync(localStorageFile)) { await LockScreen.SetImageFileAsync(localStorageFile); } } catch (Exception e) { ExceptionHelpers.PrintOutException(e, "Lockscreen: Set Image"); return(false); } return(true); }
public async override Task <AppProduct> PurchaseProduct(AppProduct appProduct) { if (appProduct == null) { Debug.WriteLine($"{nameof(appProduct)} is Null"); throw new ArgumentNullException(nameof(appProduct)); //return null; } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { try { StorePurchaseProperties properties = new StorePurchaseProperties(appProduct.Name); var purchaseResult = await Context.RequestPurchaseAsync(appProduct.StoreID); switch (purchaseResult.Status) { case StorePurchaseStatus.Succeeded: Debug.WriteLine("User now owns this product"); MarkProductPurchased(appProduct); break; case StorePurchaseStatus.AlreadyPurchased: Debug.WriteLine("User already owns this product"); MarkProductPurchased(appProduct); break; case StorePurchaseStatus.NotPurchased: Debug.WriteLine("User chose to not purchase the product"); break; case StorePurchaseStatus.NetworkError: Debug.WriteLine("A network error occurred. Please try again later"); break; case StorePurchaseStatus.ServerError: Debug.WriteLine("A server error occurred. Please try again later"); break; default: Debug.WriteLine("An unknown response occurred. Please try again later"); break; } } catch (Exception ex) { ExceptionHelpers.PrintOutException(ex, $"Product Purchase Error ({appProduct.ProductID})"); } }); return(appProduct); }
public async Task <ListingInformation> GetListingInformationAsync() { try { if (DebugHelpers.DebugMode) { return(await CurrentAppSimulator.LoadListingInformationAsync()); } return(await CurrentApp.LoadListingInformationAsync()); } catch (Exception ex) { ExceptionHelpers.PrintOutException(ex, "License Load failed"); return(null); } }
public async void StartListening(IProgress <APIProgressReport> progress, string exampleText, bool readBackEnabled = false, bool showConfirmation = false) { m_progress = progress; SpeechRecognitionResult speechRecognitionResult = null; // Create the Recognizer VoiceRecognizer = new SpeechRecognizer(); VoiceRecognizer.StateChanged += speechRecognizer_StateChanged; VoiceRecognizer.HypothesisGenerated += VoiceRecognizer_HypothesisGenerated; VoiceRecognizer.RecognitionQualityDegrading += speechRecognizer_RecognitionQualityDegrading; // Set special commands VoiceRecognizer.UIOptions.ExampleText = "Ex. " + exampleText; VoiceRecognizer.UIOptions.IsReadBackEnabled = readBackEnabled; VoiceRecognizer.UIOptions.ShowConfirmation = showConfirmation; // Set Timeouts VoiceRecognizer.Timeouts.InitialSilenceTimeout = TimeSpan.FromSeconds(6.0); VoiceRecognizer.Timeouts.BabbleTimeout = TimeSpan.FromSeconds(4.0); VoiceRecognizer.Timeouts.EndSilenceTimeout = TimeSpan.FromSeconds(1.2); try { SpeechRecognitionCompilationResult compilationResult = await VoiceRecognizer.CompileConstraintsAsync(); speechRecognitionResult = await VoiceRecognizer.RecognizeWithUIAsync(); // RecognizeAsync(); } catch (Exception e) { ExceptionHelpers.PrintOutException(e, "Speech Recognition Exception"); } VoiceRecognizer = null; if (speechRecognitionResult != null) { if (progress != null) { progress.Report(new APIProgressReport(100.0, "Successfully Received Voice Recognition", APIResponse.Successful, speechRecognitionResult)); } else if (progress != null) { progress.Report(new APIProgressReport(100.0, "Failed to Retrieve Voice Recognition", APIResponse.Failed)); } } }
/// <summary> /// Sets the Wallpaper Image using a file within the Application Storage /// </summary> /// <param name="localStorageFile">A file within the Application Storage</param> /// <returns>If the Wallpaper Image was successfully Set</returns> public override async Task <bool> SetImage(StorageFile localStorageFile) { if (!IsSupported) { return(false); } if (localStorageFile == null) { return(false); } try { bool success = await UserProfilePersonalizationSettings.Current.TrySetWallpaperImageAsync(localStorageFile); return(success); } catch (Exception e) { ExceptionHelpers.PrintOutException(e, "Wallpaper: Set Image"); return(false); } }
public async Task <(AppProduct, PurchaseResults)> Purchase(string id) { var license = GetLicense(id); // If the product does not exist, exit with null if (license == null) { Debug.WriteLine("This product does not exist"); throw new ArgumentException($"A product by ProductID of {id} does not exist", nameof(AppProduct.ProductID)); //return (null, null); } // If the license is valid, but we don't have the product, create the product var product = GetAppProductByProductID(id); if (product == null) { product = new AppProduct(id, id, false); AppProducts.Add(product); } // If the license is already active, simply return the product if (license.IsActive) { Debug.WriteLine("User already owns this product"); return(product, null); } try { PurchaseResults purchaseResults; if (DebugHelpers.DebugMode) { Debug.WriteLine("Debug mode active, Simulating product purchase"); purchaseResults = await CurrentAppSimulator.RequestProductPurchaseAsync(id); Debug.WriteLine("Finished Simulating"); } else { Debug.WriteLine("Requesting Product Purchase"); purchaseResults = await CurrentApp.RequestProductPurchaseAsync(id); Debug.WriteLine("User finished interacting with purchase screen"); } switch (purchaseResults.Status) { case ProductPurchaseStatus.AlreadyPurchased: Debug.WriteLine("User already owns this product"); MarkProductPurchased(product); break; case ProductPurchaseStatus.Succeeded: Debug.WriteLine("User now owns this product"); MarkProductPurchased(product); break; case ProductPurchaseStatus.NotPurchased: Debug.WriteLine("User chose to not purchase the product"); product.Purchased = false; if (DebugHelpers.DebugMode) { Debug.WriteLine("Simulating Purchase"); MarkProductPurchased(product); } break; case ProductPurchaseStatus.NotFulfilled: Debug.WriteLine("A previous purchase was not fulfilled"); MarkProductPurchased(product); break; default: Debug.WriteLine("An unknown response occurred. Please try again later"); break; } return(product, purchaseResults); } catch (Exception ex) { ExceptionHelpers.PrintOutException(ex, $"Product Purchase Error ({id})"); } return(product, null); }