Esempio n. 1
0
        public void OnNotifyMsgNtf(String strNotifyMsg)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new DlgtVoidInputString(OnNotifyMsgNtf), strNotifyMsg);
            }
            else
            {
                string[] msgs = strNotifyMsg.Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string msg in msgs)
                {
                    string jsonMsg = GlobalMgr.TrimStartString(msg, "#", "");

                    if (jsonMsg.ToLower() == "{ping}")
                    {
                        //if(HeartBeatLostTime >= MAX_HEARTBEAT_LOST)
                        //SetStatus("服务器已连接");

                        // We get feedback, reset the heart beat lost count to 0.
                        HeartBeatLostTime = 0;
                        continue;
                    }

                    try
                    {
                        JObject jo = JObject.Parse(jsonMsg);
                        if (jo == null)
                        {
                            return;
                        }

                        NtfMsgInfo ntfMsgInfo = new NtfMsgInfo();

                        ntfMsgInfo.TitleInfo = jo["title"].ToString();
                        ntfMsgInfo.LinkInfo  = jo["link"].ToString();
                        ntfMsgInfo.TimeInfo  = DateTime.Now.ToString(TimeConverter.Format, TimeConverter.CultureInfo);

                        InsertNewMsg(ntfMsgInfo);

                        TrayMsgControl.AddToTrayMsgQueue(ntfMsgInfo);
                        //   notifyIcon1.ShowBalloonTip(5000, ntfMsgInfo.TimeInfo, ntfMsgInfo.TitleInfo, ToolTipIcon.Info);

                        if (this.WindowState == FormWindowState.Minimized)
                        {
                            // Enable icon flash on Tray.
                            TrayIconFlash(true);
                        }
                    }
                    catch
                    {
                        continue;
                    }
                }
            }
        }
Esempio n. 2
0
 private void Timer_ShowTrayMsg_Tick(object sender, EventArgs e)
 {
     TrayMsgControl.ShowTrayMsg();
 }