Esempio n. 1
0
        /// <summary>
        /// 显示未读提示
        /// </summary>
        /// <param name="p_letter"></param>
        static void ShowUnreadNotify(Letter p_letter)
        {
            // 避免过多
            if (SysVisual.NotifyList.Count > 5)
            {
                return;
            }

            var notify = new NotifyInfo();

            // 不自动关闭
            notify.DelaySeconds = 0;
            notify.Link         = "查看内容";
            notify.LinkCallback = (e) =>
            {
                Letter l = (Letter)e.Tag;
                // 关闭所有对方为同一人的提示
                foreach (var ni in SysVisual.NotifyList)
                {
                    if (ni.Tag is Letter letter && letter.OtherID == l.OtherID)
                    {
                        Kit.CloseNotify(ni);
                    }
                }
                Kit.RunAsync(() => ChatDetail.ShowDlg(l.OtherID, l.OtherName));
            };

            switch (p_letter.LetterType)
            {
            case LetterType.Text:
                string msg;
                if (p_letter.Content.Length > 9)
                {
                    msg = p_letter.Content.Substring(0, 9) + "…";
                }
                else
                {
                    msg = p_letter.Content;
                }
                notify.Message = string.Format("💡 {0}\r\n{1}", p_letter.OtherName, msg);
                break;

            case LetterType.File:
                notify.Message = string.Format("🏬 {0}发来文件", p_letter.OtherName);
                break;

            case LetterType.Image:
                notify.Message = string.Format("🌄 {0}发来图片", p_letter.OtherName);
                break;

            case LetterType.Video:
                notify.Message = string.Format("🌉 {0}发来视频", p_letter.OtherName);
                break;

            case LetterType.Voice:
                notify.Message = string.Format("📢 {0}发来语音", p_letter.OtherName);
                break;

            case LetterType.Link:
                notify.Message = string.Format("💨 {0}发来链接", p_letter.OtherName);
                break;

            default:
                break;
            }
            notify.Tag = p_letter;
            SysVisual.NotifyList.Add(notify);
            //await SysVisual.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() => SysVisual.NotifyList.Add(notify)));
        }