示例#1
0
 public void AddToTrayMsgQueue(NtfMsgInfo msgInfo)
 {
     if (MsgQueue.Count == MaxMsgForm)
     {
         MsgQueue.Dequeue();
     }
     MsgQueue.Enqueue(msgInfo);
 }
示例#2
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;
                    }
                }
            }
        }
示例#3
0
 public void MarkMsgAsRead(NtfMsgInfo msg)
 {
     foreach (ListViewItem item in listViewMsgs.Items)
     {
         if (item.SubItems[COLUMN_TIME].Text == msg.TimeInfo)
         {
             item.ImageIndex = MSG_ICON_READ;
             return;
         }
     }
 }
示例#4
0
        //public TrayMsgForm()
        //{
        //    InitializeComponent();
        //}

        public TrayMsgForm(int maxDuration, NtfMsgInfo msgInfo, TrayMsgController controller)
        {
            InitializeComponent();

            MaxDisplayTime = maxDuration;
            Msg            = msgInfo;

            CurrentDisplayTime = 0;

            MsgController = controller;
        }
示例#5
0
        private void NotifyIcon1_BalloonTipClicked(object sender, EventArgs e)
        {
            NtfMsgInfo msg = LatestMsg;

            if (msg != null)
            {
                System.Diagnostics.Process.Start(msg.LinkInfo);
                TrayIconFlash(false);

                // Mark it as read
                MarkMsgAsRead(msg);
            }
        }
示例#6
0
        private void InsertNewMsg(NtfMsgInfo ntfMsgInfo)
        {
            if (listViewMsgs.Items.Count + 1 > MAX_MSGS)
            {
                listViewMsgs.Items.RemoveAt(listViewMsgs.Items.Count - 1);
            }

            ListViewItem listItem = new ListViewItem(ntfMsgInfo.TitleInfo, MSG_ICON_UNREAD);

            listItem.SubItems.Add(ntfMsgInfo.TimeInfo);
            listItem.SubItems.Add(ntfMsgInfo.LinkInfo);

            // Later msg always shows in the first.
            listViewMsgs.Items.Insert(0, listItem);

            // Update latest msg which will be opened when click on the ballontip.
            LatestMsg = ntfMsgInfo;
        }
示例#7
0
        public void ShowTrayMsg()
        {
            if (MsgQueue.Count == 0)
            {
                return;
            }

            NtfMsgInfo msgInfo = MsgQueue.Dequeue();

            if (TrayMsgFormList.Count == MaxMsgForm)
            {
                TrayMsgForm formToRemove = TrayMsgFormList.First();
                formToRemove.CloseForm();
            }

            TrayMsgForm newForm = new TrayMsgForm(Host.MAX_MSG_DISPLAY_TIME, msgInfo, this);

            TrayMsgFormList.Insert(0, newForm);

            UpdateFormsPosition();
            newForm.Show();

            PlaySound();
        }
示例#8
0
 public void MarkMsgAsRead(NtfMsgInfo msg)
 {
     Host.MarkMsgAsRead(msg);
 }