/// <summary> /// 分享按钮点击事件函数,实现分享 /// </summary> private void ShareButton_Click(object sender, RoutedEventArgs e) { if (SelectedItem == null) { NotifyPopup notifyPopup = new NotifyPopup("还没选择要分享的内容呢!"); notifyPopup.Show(); } else { DataTransferManager.ShowShareUI(); } }
/// <summary> /// 删除收藏并提示 /// </summary> private void DeleteFavoriteButton_Click(object sender, RoutedEventArgs e) { if (SelectedItem != null) { UserDB.DeleteFavorite(SelectedItem); // 从数据库删除 F_ViewModel.RemoveMessageItem(SelectedItem.guid); // 从ViewModel删除 SelectedItem = null; NotifyPopup notifyPopup = new NotifyPopup("删除收藏成功!"); notifyPopup.Show(); } }
/// <summary> /// 收藏,若已收藏过,提示错误 /// </summary> private void FavoriteButton_Click(object sender, RoutedEventArgs e) { if (SelectedItem != null) { if (UserDB.AddFavorite(SelectedItem)) { NotifyPopup notifyPopup = new NotifyPopup("收藏成功!"); notifyPopup.Show(); } else { NotifyPopup notifyPopup = new NotifyPopup("收藏已存在!"); notifyPopup.Show(); } } }
/// <summary> /// 登录。若登录成功,跳转至个人信息页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void LoginButton_Click(object sender, RoutedEventArgs e) { if (Services.UserService.Signin(LoginUsername.Text, LoginPassword.Password)) { Services.UserDatabase.SetUser(LoginUsername.Text); NotifyPopup notifyPopup = new NotifyPopup("登录成功"); notifyPopup.Show(); // 从服务器获取个人存档 // 并同步至本地 Models.UserInfo userInfo = await Services.UserService.GetProfile(); UserDB.UpdateFavorite(userInfo.favorite); UserDB.UpdateSubscription(userInfo.subscription); Frame.Navigate(typeof(UserInfo), UserDB.GetUser()); } }