/// <summary> /// 加载信息 /// </summary> async void LoadMsg() { if (OtherID < 0) { return; } string sql = $"select * from ChatMember where id={OtherID}"; _other = AtState.First <ChatMember>(sql); if (_other == null) { // 初次打开,还未下载好友列表 await FriendMemberList.Refresh(); _other = AtState.First <ChatMember>(sql); // 不在好友列表时,创建虚拟 if (_other == null) { _other = new ChatMember( ID: OtherID, Name: OtherID.ToString(), Photo: "photo/profilephoto.jpg"); } } // 不是好友时无法发送 //_inputBar.Visibility = (_other == null) ? Visibility.Collapsed : Visibility.Visible; LetterManager.ClearUnreadFlag(OtherID); _lv.PageData = new PageData { NextPage = OnNextPage, InsertTop = true }; }
async void OnUndoMsg(object sender, Mi e) { var l = (Letter)e.DataContext; if ((Kit.Now - l.STime).TotalMinutes > 2) { Kit.Warn("超过2分钟无法撤回"); } else if (await LetterManager.SendUndoLetter(l)) { _lv.Data.Remove(l); } }
/// <summary> /// 发送文件 /// </summary> /// <param name="p_files"></param> public async void SendFiles(List <FileData> p_files) { Letter l = new Letter { OtherID = OtherID, OtherName = _other.Name, IsReceived = false, Unread = false, LetterType = GetLetterType(p_files), STime = Kit.Now, Photo = Kit.UserPhoto, }; _lv.Data.Add(l); FileList fl; var elem = _lv.GetRowUI(_lv.Data.Count - 1); if (elem == null || (fl = elem.FindChildByType <FileList>()) == null) { _lv.Data.Remove(l); return; } bool suc = await fl.UploadFiles(p_files); if (suc) { var nl = await LetterManager.SendLetter(OtherID, _other.Name, fl.Data, l.LetterType); l.ID = nl.ID; l.MsgID = nl.MsgID; l.Content = nl.Content; } else { _lv.Data.Remove(l); } }
/// <summary> /// 发送普通消息 /// </summary> /// <param name="p_msg"></param> public async void SendMsg(string p_msg) { await LetterManager.SendLetter(OtherID, _other.Name, p_msg, LetterType.Text); }