private async void importEdit_Click(object sender, RoutedEventArgs e) { //open up windows dialog to pick file FileOpenPicker picker = new FileOpenPicker(); picker.FileTypeFilter.Add(".json"); picker.FileTypeFilter.Add(".agf"); picker.ViewMode = PickerViewMode.List; StorageFile file = await picker.PickSingleFileAsync(); if (file == null) { return; } string contents = ""; try { contents = await UWPIO.storageFileToString(file); game = new ActiveGame(AdventureGame.loadFromString(contents)); } catch (Exception x) { await new MessageDialog("Invalid Adventuregame Selected", "Error").ShowAsync(); return; } refresh(); }
private async void ImportButton_Click(object sender, RoutedEventArgs e) { //open up windows dialog to pick file FileOpenPicker picker = new FileOpenPicker(); picker.FileTypeFilter.Add(".json"); picker.FileTypeFilter.Add(".agf"); picker.ViewMode = PickerViewMode.List; StorageFile file = await picker.PickSingleFileAsync(); if (file == null) { return; } string contents = ""; try { contents = await UWPIO.storageFileToString(file); loadedGame = AdventureGame.loadFromString(contents); } catch (Exception x) { await new MessageDialog("Invalid Adventuregame Selected", "Error").ShowAsync(); return; } title = loadedGame.title; author = loadedGame.author; gamevars = loadedGame.gamevars.ToString(); start_state = loadedGame.start_state; fileContents = contents; currentPath = file.Path; curFile = file; updateDisplay(); }