Пример #1
0
        /// <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
            };
        }
Пример #2
0
        /// <summary>
        /// 接收服务器推送的聊天信息
        /// </summary>
        /// <param name="p_letter"></param>
        internal static async void ReceiveLetter(LetterInfo p_letter)
        {
            if (p_letter == null || string.IsNullOrEmpty(p_letter.ID))
            {
                return;
            }

            // 撤回消息
            if (p_letter.LetterType == LetterType.Undo)
            {
                var letter = AtState.First <Letter>("select * from Letter where MsgID=@msgid and LoginID=@loginid and IsReceived=1", new Dict {
                    { "msgid", p_letter.ID }, { "loginid", Kit.UserID }
                });
                if (letter != null)
                {
                    // 删除
                    AtState.Exec($"delete from Letter where ID={letter.ID}");
                    UndoLetter?.Invoke(letter);
                }
                return;
            }

            // 新消息
            Letter l = new Letter(
                LoginID: Kit.UserID,
                MsgID: p_letter.ID,
                OtherID: p_letter.SenderID,
                OtherName: p_letter.SenderName,
                LetterType: p_letter.LetterType,
                Content: p_letter.Content,
                STime: p_letter.SendTime,
                IsReceived: true,
                Unread: true);

            // 自增主键插入后自动赋值
            await AtState.Save(l, false);

            // 外部可修改 Unread 状态
            NewLetter?.Invoke(l);

            if (l.Unread)
            {
                // 外部未读提示
                StateChanged?.Invoke(l.OtherID);
                ShowUnreadNotify(l);
            }
            else
            {
                // Unread状态被修改
                await AtState.Save(l, false);
            }
        }
Пример #3
0
        public async Task ShowDlg(long p_fromUserID)
        {
            if (Kit.IsPhoneUI)
            {
                HideTitleBar = true;
            }
            else
            {
                IsPinned = true;
                SetSize(600, -60);
            }

            _other       = AtState.First <ChatMember>($"select * from ChatMember where id={p_fromUserID}");
            _tbInfo.Text = $"[{_other.Name}] 邀请您视频通话...";
            await ShowAsync();
        }
Пример #4
0
        //**************************************************************************
        // 响应式设计:三种布局方式对应三种界面宽度
        // 1. 界面宽度 <= 640px,PhoneUI模式,4"到6"设备 或 缩小的窗口,只一列面板
        // 2. 界面宽度在 641px ~ 1007px,7"到12"设备 或 缩小的窗口,最多两列面板
        // 3. 界面宽度 >= 1008px,13"及更大设备,最多三列面板
        //**************************************************************************

        /// <summary>
        /// Win宽度变化时自动调整
        /// </summary>
        /// <param name="p_width"></param>
        public void OnWidthChanged(double p_width)
        {
            double width = 0;
            int    index = -1;

            for (int i = 0; i < _colsWidth.Count; i++)
            {
                width += _colsWidth[i];
                if (width > p_width)
                {
                    index = i;
                    break;
                }
            }
            if (_fitCols == index)
            {
                return;
            }

            _fitCols = index;
            if (_fitCols == -1)
            {
                // 宽度足够,加载历史布局或默认布局
                DockLayout cookie;
                if (AllowSaveLayout() &&
                    (cookie = AtState.First <DockLayout>($"select * from DockLayout where BaseUri=\"{_owner.BaseUri.AbsolutePath}\"")) != null &&
                    ApplyLayout(cookie.Layout))
                {
                    _owner.AllowResetLayout = true;
                }
                else
                {
                    ApplyLayout(_default);
                    _owner.AllowResetLayout = false;
                }
            }
            else
            {
                // 自动隐藏两侧
                ApplyAutoHide();
                _owner.AllowResetLayout = false;
            }
        }
Пример #5
0
 /// <summary>
 /// 初始化布局环境
 /// 1. 记录默认布局
 /// 2. 加载状态库中的历史布局
 /// 3. 无历史布局则加载默认布局
 /// </summary>
 void Init()
 {
     // 记录默认布局
     SaveDefaultXml();
     if (AllowSaveLayout())
     {
         DockLayout cookie = AtState.First <DockLayout>($"select * from DockLayout where BaseUri=\"{_owner.BaseUri.AbsolutePath}\"");
         if (cookie != null)
         {
             // 加载历史布局
             if (ApplyLayout(cookie.Layout))
             {
                 _owner.AllowResetLayout = true;
             }
             else
             {
                 // 历史布局加载失败,重载默认布局
                 ApplyLayout(_default);
                 _owner.AllowResetLayout = false;
             }
         }
     }
 }
Пример #6
0
        void OnOpenedFile(object sender, FileItem e)
        {
            if (!_fileMgr.Setting.SaveHistory)
            {
                return;
            }

            Kit.RunAsync(async() =>
            {
                // 记录到本地已读文件目录
                var row = ((LvItem)e.DataContext).Row;
                var his = AtState.First <ReadFileHistory>("select * from ReadFileHistory where ID=@id", new { id = row.ID });
                if (his == null)
                {
                    his = new ReadFileHistory(ID: row.ID, Info: row.Str("info"));
                }
                his.LastReadTime = Kit.Now;
                if (await AtState.Save(his, false))
                {
                    _fileMgr.Setting.OnOpenedFile?.Invoke();
                }
            });
        }