private async void join_Click(object sender, RoutedEventArgs e) { try { var picker = new FileOpenPicker(); picker.ViewMode = PickerViewMode.Thumbnail; picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add(".png"); picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".jpeg"); var filePickerResult = await picker.PickSingleFileAsync(); if (filePickerResult != null) { var bytes = (await FileIO.ReadBufferAsync(filePickerResult)).ToArray(); var proxy = new GameServiceProxy(new Uri("http://localhost:5000")); var game = await proxy.CreateGame("Mats"); game = await proxy.GetGame(game.Id); game = (await proxy.SubmitAnswer(game.Id, bytes)).Item2; } } catch (Exception ex) { } }
private async void TakePhoto() { try { var capture = new CameraCaptureUI(); capture.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Png; var photo = await capture.CaptureFileAsync(CameraCaptureUIMode.Photo); if (photo != null) { var destinationFile = await StorageFile.GetFileFromPathAsync(Path.GetTempFileName()); await ResizeImage(photo, destinationFile); await ShowImage(destinationFile); var data = await GetImageData(destinationFile); Context.ResultText = " - Working..."; RaisePropertyChanged(() => StatusText); var newGame = await _gameProxy.SubmitAnswer(Context.CurrentGame.Id, data); if (newGame != null) { Context.CurrentGame = newGame.Item2; Context.ResultText = " - " + newGame.Item1; } else { Context.ResultText = " - Error"; } RaisePropertyChanged(() => StatusText); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }