private async void ImportGameButton_Click(object sender, RoutedEventArgs e) { // open file picker // select the file // get display name and extension of file // find platform by file type // search in launch box by displayname (name, platform, notes, picture) // for each search result check if item.platform is equal to platform by file type // if true return the item try { var picker = new Windows.Storage.Pickers.FileOpenPicker(); picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.List; picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop; picker.FileTypeFilter.Add(".nes"); Windows.Storage.StorageFile file = await picker.PickSingleFileAsync(); if (file != null) { string extension = StorageService.GetFileExtension(file); Game game = new Game() { Title = file.DisplayName, Platform = "", Notes = file.Path }; ObservableCollection <Game> a = await LaunchBoxScraper.SearchGame(file.DisplayName); foreach (var item in a) { if (item.Platform == "Nintendo Entertainment System") { await NotificationService.DisplaySimpleMessageDialog(item.Title, item.Platform); } } await DatabaseService.AddGame(game); GamesList.Add(game); } else { await NotificationService.DisplaySimpleMessageDialog("", "Operation cancelled."); } } catch (Exception error) { await NotificationService.DisplaySimpleMessageDialog("", error.Message); throw; } // *************** delete ************************ FutureAccessListTextBlock.Text = ""; IEnumerable <AccessListEntry> accessListEntries = StorageService.GetFutureAccessListEntries(); FutureAccessListEntries = new ObservableCollection <AccessListEntry>(accessListEntries); // *********************************************** }
private async void Page_Loaded(object sender, RoutedEventArgs e) { // ******** Getting platforms from LaunchBox and put them in a public ************ // ******** observable collection property that binds to a list view control ***** AllPlatformsList = await LaunchBoxScraper.GetAllPlatforms(); SelectedPlatform = new Platform(); // ******************************************************************************* }
private async void SavePlatformButton_Click(object sender, RoutedEventArgs e) { if (SelectedPlatform != null) { await DatabaseService.AddPlatform(await LaunchBoxScraper.GetPlatformDetails(SelectedPlatform)); } Frame frame = this.Frame; frame.Navigate(typeof(MainPage)); }