/// <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) { DebugTools.PrintOutException(e, "Lockscreen: Set Image"); return(false); } return(true); }
private void ViewModel_FolderBrowserClosed(object sender, EventArgs e) { try { addDirectoryButton.Flyout.ShowAt(addDirectoryButton); } catch (Exception ex) { DebugTools.PrintOutException(ex, nameof(ViewModel_FolderBrowserClosed)); } }
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) { DebugTools.PrintOutException(ex, $"Product Purchase Error ({appProduct.ProductID})"); } }); return(appProduct); }
public async Task <ListingInformation> GetListingInformationAsync() { try { if (DebugTools.DebugMode) { return(await CurrentAppSimulator.LoadListingInformationAsync()); } return(await CurrentApp.LoadListingInformationAsync()); } catch (Exception ex) { DebugTools.PrintOutException(ex, "License Load failed"); return(null); } }
/// <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) { DebugTools.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 (DebugTools.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 (DebugTools.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) { DebugTools.PrintOutException(ex, $"Product Purchase Error ({id})"); } return(product, null); }