private async void Capture_Photo(object sender, RoutedEventArgs e) { StorageFile file = null; CameraCaptureUI captureUI = new CameraCaptureUI(); captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Png; captureUI.PhotoSettings.CroppedSizeInPixels = new Size(200, 200); file = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo); if (file == null) { return; } Uri URL = await ApiHandle <string> .Upload(file, await ApiHandle <string> .Call(APITypes.GetUpload, null), "quanganh9x", "image/png"); ImageUrl.Text = URL.AbsoluteUri; try { MyAvatar.Source = new BitmapImage(URL); isImageValid = true; avatar.Visibility = Visibility.Collapsed; } catch { ExceptionHandle.ThrowDebug("cant upload image"); MyAvatar.Source = null; isImageValid = false; avatar.Visibility = Visibility.Visible; } }
private async void BtnLogin_Click(object sender, RoutedEventArgs e) { if (CheckLogin(this.Email.Text)) { Revert(); Dictionary <String, String> LoginInfo = new Dictionary <string, string>(); LoginInfo.Add("email", this.Email.Text); LoginInfo.Add("password", this.Password.Password); string responseContent = await ApiHandle <Dictionary <string, string> > .Call(APITypes.SignIn, LoginInfo); try { Response resp = JsonConvert.DeserializeObject <Response>(responseContent); if (resp.token != null) { if (rem.IsChecked == true) { await FileHandle.Save("token.ini", resp.token); } FrameSwitcher.Switch(typeof(Views.NavigationView)); } else { Entity.Exception err = JsonConvert.DeserializeObject <Entity.Exception>(responseContent); login.Text = err.message; login.Visibility = Visibility.Visible; } } catch { ApiHandle <string> .ThrowException(responseContent); } } else { email.Visibility = Visibility.Visible; } }
private async void Handle_Signup(object sender, RoutedEventArgs e) { if (CheckRegister(this.Email.Text, this.Phone.Text)) { Revert(); this.currentMember.firstName = this.FirstName.Text; this.currentMember.lastName = this.LastName.Text; this.currentMember.email = this.Email.Text; this.currentMember.password = this.Password.Password; this.currentMember.avatar = this.ImageUrl.Text; this.currentMember.phone = this.Phone.Text; this.currentMember.address = this.Address.Text; this.currentMember.introduction = this.Introduction.Text; string responseContent = await ApiHandle <Member> .Call(APITypes.SignUp, this.currentMember); try { Member resp = JsonConvert.DeserializeObject <Member>(responseContent); if (resp.email != null && resp.email == this.currentMember.email) { await Dialog.Show("Register success!"); FrameSwitcher.Switch(typeof(Views.LoginForm)); } else { Entity.Exception err = JsonConvert.DeserializeObject <Entity.Exception>(responseContent); register.Text = err.message; register.Visibility = Visibility.Visible; } } catch { ApiHandle <string> .ThrowException(responseContent); } } }
private async void BtnSignup_Click(object sender, RoutedEventArgs e) { if (CheckSong(this.Link.Text)) { Service.ProgressBar.SetProgress(40, true); Revert(); this.currentSong.name = this.Name.Text; this.currentSong.description = this.Description.Text; this.currentSong.singer = this.Singer.Text; this.currentSong.author = this.Author.Text; this.currentSong.thumbnail = this.Thumbnail.Text; this.currentSong.link = this.Link.Text; Service.ProgressBar.SetProgress(60, true); string responseContent = await ApiHandle <Song> .Call(APITypes.CreateSong, this.currentSong); try { Song resp = JsonConvert.DeserializeObject <Song>(responseContent); if (resp.link != null && resp.link == this.currentSong.link) { await Dialog.Show("Add song success!"); } else { song.Visibility = Visibility.Visible; } } catch { ApiHandle <string> .ThrowException(responseContent); } finally { Service.ProgressBar.Hide(); } } }