private void TextBlock_Tap_7(object sender, System.Windows.Input.GestureEventArgs e) { if (buyAllCount == 9) { PayList pl = new PayList(); foreach (PayFace l in pl) { if (!l.Name.ToString().Contains("Buy All")) { listBox1.ItemsSource = null; library.justAdd(l.Name.ToString(), l.Img.ToString(), l.Wide.ToString()); } } library.justSave(); listBox1.ItemsSource = library.getList(); MessageBox.Show("Purchase Restored"); } buyAllCount++; }
//selection events async private void listBox3_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { PayFace selectedBook = (listBox3.SelectedItems[0]) as PayFace; if (selectedBook.Price.Contains("Rate")) { listBox1.ItemsSource = null; library.add(selectedBook.Name, selectedBook.Img, selectedBook.Wide); listBox1.ItemsSource = library.getList(); MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask(); marketplaceReviewTask.Show(); } else if (selectedBook.Name.Contains("Buy")) { MessageBoxResult m = MessageBox.Show("Would you like to add all premium faces to library?", "Purchase all Clock Faces", MessageBoxButton.OKCancel); if (m == MessageBoxResult.OK) { var listing = await CurrentApp.LoadListingInformationAsync(); var superweapon = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == selectedBook.Buycode && p.Value.ProductType == ProductType.Durable); try { if (CurrentApp.LicenseInformation.ProductLicenses[superweapon.Value.ProductId].IsActive) { PayList pl = new PayList(); foreach (PayFace l in pl) { if (!l.Name.ToString().Contains("Buy All")) { listBox1.ItemsSource = null; library.justAdd(l.Name.ToString(), l.Img.ToString(), l.Wide.ToString()); } } library.justSave(); listBox1.ItemsSource = library.getList(); MessageBox.Show("Library has been updated", "Restored", MessageBoxButton.OK); } else { var receipt = await CurrentApp.RequestProductPurchaseAsync(superweapon.Value.ProductId, true); PayList pl = new PayList(); foreach (PayFace l in pl) { if (!l.Name.ToString().Contains("Buy All")) { listBox1.ItemsSource = null; library.justAdd(l.Name.ToString(), l.Img.ToString(), l.Wide.ToString()); } } library.justSave(); listBox1.ItemsSource = library.getList(); MessageBox.Show("Thank you for purchasing the premium clock faces. It has been added to your library. You can restore / update your purchase library by clicking on the 'Buy All' button.", "Awesome", MessageBoxButton.OK); } } catch (Exception ex) { MessageBox.Show("Cannot purchase at the moment."); } } } else { MessageBoxResult m = MessageBox.Show("Would you like to add this to your library?", "Purchase " + selectedBook.Name.ToString() + " Clock Face", MessageBoxButton.OKCancel); if (m == MessageBoxResult.OK) { var listing = await CurrentApp.LoadListingInformationAsync(); var superweapon = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == selectedBook.Buycode && p.Value.ProductType == ProductType.Durable); try { if (CurrentApp.LicenseInformation.ProductLicenses[superweapon.Value.ProductId].IsActive) { listBox1.ItemsSource = null; library.add(selectedBook.Name, selectedBook.Img, selectedBook.Wide); listBox1.ItemsSource = library.getList(); MessageBox.Show("You already own this clock face, the purchase has been restored to your library", "Restored", MessageBoxButton.OK); } else { string receipt = await CurrentApp.RequestProductPurchaseAsync(superweapon.Value.ProductId, true); listBox1.ItemsSource = null; library.add(selectedBook.Name, selectedBook.Img, selectedBook.Wide); listBox1.ItemsSource = library.getList(); MessageBox.Show("Thank you for purchasing the clock face. It has been added to your library.", "Awesome", MessageBoxButton.OK); } } catch (Exception ex) { MessageBox.Show("Cannot purchase at the moment."); } } } listBox3.SelectedIndex = -1; } catch { } }