Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_session"></param>
        /// <param name="_lstParams">
        /// </param>
        public IMMainPage(SessionInfo _session)
        {
            InitializeComponent();
            try
            {
                session         = _session;
                InitApp.Session = session;
                OperationReturn optReturn = InitApp.InitLanguageInfos();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            Loaded += IMMainPage_Loaded;
        }
Beispiel #2
0
 private void InitLanguage()
 {
     btnClose.Content = InitApp.GetLanguage("1600004", "Close");
     btnSend.Content  = InitApp.GetLanguage("1600005", "Send");
 }
Beispiel #3
0
 private void InitLanguage()
 {
     lblContact.Text = InitApp.GetLanguage("1600006", "My contact");
 }
Beispiel #4
0
        void IService16001Callback.SendSysMessage(S1600MessageType msgType, List <string> lstSysMsg)
        {
            string strMsg  = string.Empty;
            long   lUserID = 0;

            switch (msgType)
            {
            case S1600MessageType.ConnServerFailed:

                break;

            case S1600MessageType.FriendOffline:
                //好友上线 更新名字颜色和图标
                long.TryParse(lstSysMsg[0], out lUserID);
                List <ContacterInListBox> lstFriend = lstContacters.Where(p => p.UserID == lUserID).ToList();
                if (lstFriend.Count > 0)
                {
                    lstFriend.First().Status      = "1";
                    lstFriend.First().ForegGround = Brushes.Gray;
                    string strType         = lstFriend.First().UserID.ToString().Substring(0, 3);
                    lstFriend.First().Icon = strType == ConstValue.RESOURCE_AGENT.ToString() ?
                                             "Themes/Default/UMP1600/Images/AgentOffline.png" : "Themes/Default/UMP1600/Images/UserOffline.png";
                }
                ListSorter.SortList <ObservableCollection <ContacterInListBox>, ContacterInListBox>(ref lstContacters, "Status", SortDirection.Descending);
                break;

            case S1600MessageType.FriendOnline:
                //好友上线 更新名字颜色和图标
                long.TryParse(lstSysMsg[0], out lUserID);
                lstFriend = lstContacters.Where(p => p.UserID == lUserID).ToList();
                if (lstFriend.Count > 0)
                {
                    lstFriend.First().Status      = "1";
                    lstFriend.First().ForegGround = Brushes.Red;
                    string strType         = lstFriend.First().UserID.ToString().Substring(0, 3);
                    lstFriend.First().Icon = strType == ConstValue.RESOURCE_AGENT.ToString() ?
                                             "Themes/Default/UMP1600/Images/AgentOnline.png" : "Themes/Default/UMP1600/Images/UserOnline.png";
                    //lstFriend.First().Icon = "Themes/Default/UMP1600/Images/OnLine.ico";
                }
                ListSorter.SortList <ObservableCollection <ContacterInListBox>, ContacterInListBox>(ref lstContacters, "Status", SortDirection.Descending);
                break;

            case S1600MessageType.GetFriendFailed:
                MessageBox.Show(InitApp.GetLanguage("1600007", "Failed to get a buddy list"));
                break;

            case S1600MessageType.Logined:
                //MessageBox.Show(InitApp.GetLanguage("1600001", "Your account has been logged in at another place, you have been forced offline"));

                //lblCurrStatus.Content = session.UserInfo.UserName +"("+ InitApp.GetLanguage("1600009", "Offline")+")";
                //lblCurrStatus.Foreground = Brushes.LightGray;

                StatusChangeEvent((int)UserStatusChangeType.LogOff, "");
                SetIMStatus(false);
                if (iClient.State == CommunicationState.Opened)
                {
                    try
                    {
                        iClient.Close();
                    }
                    catch
                    {
                    }
                }

                break;

            case S1600MessageType.LoginFailed:
                MessageBox.Show(lstSysMsg[0]);
                break;

            case S1600MessageType.LoginSuceess:
                //lblCurrStatus.Content = session.UserInfo.UserName +"("+ InitApp.GetLanguage("1600009", "Offline")+")";
                //lblCurrStatus.Foreground = Brushes.LightGreen;
                StatusChangeEvent((int)UserStatusChangeType.Login, "");

                #region 发送心跳的计时器
                HeartTimer           = new Timer();
                HeartTimer.AutoReset = true;
                HeartTimer.Interval  = 180 * 1000;           //时间间隔30秒
                HeartTimer.Elapsed  += HeartTimer_Elapsed;
                HeartTimer.Start();
                #endregion
                if (StatusChangeEvent != null)
                {
                    StatusChangeEvent((int)UserStatusChangeType.Login, "");
                }
                break;

            case S1600MessageType.HeartMsg:
                //MessageBox.Show("心跳消息"+DateTime.Now);
                break;

            case S1600MessageType.TestMsg:
                //MessageBox.Show(lstSysMsg[0]);
                break;

            case S1600MessageType.SendMsgError:
                strMsg = InitApp.GetLanguage("1600002", "Your message '{0}' failed to send the other party may have been offline, has been sent as an offline message");
                strMsg = string.Format(strMsg, lstSysMsg[0]);
                //找到对应的窗口 显示此消息
                string strFriendName = lstSysMsg[1];
                if (dicChatWins.Keys.Contains(strFriendName))
                {
                    ChartWindow win = dicChatWins[strFriendName].Content as ChartWindow;
                    win.txtRecord.Text += strMsg;
                }
                else
                {
                    //还没想好该咋处理 先空着
                }
                break;

            case S1600MessageType.EndCookie:
                //结束会话
                string strContacterName = lstSysMsg[0];
                long   lContacterID     = long.Parse(lstSysMsg[1]);
                if (dicCookies.Keys.Contains(lContacterID))
                {
                    if (dicCookies[lContacterID].CookieTimer != null)
                    {
                        dicCookies[lContacterID].CookieTimer.Stop();
                        dicCookies[lContacterID].CookieTimer = null;
                        //MessageBox.Show("cookie closed");
                    }
                }
                break;

            case S1600MessageType.CookieID:
                lContacterID = long.Parse(lstSysMsg[0]);
                long cookieID = long.Parse(lstSysMsg[1]);
                if (dicCookies.Keys.Contains(lContacterID))
                {
                    dicCookies[lContacterID].CookieID      = cookieID;
                    dicCookies[lContacterID].CookieCreated = 1;
                    dicCookies[lContacterID].CookieTimer.Start();
                }
                break;
            }
        }