Example #1
0
 private void refreshTimer_Tick(object sender, EventArgs e)
 {
     RefreshList();
     if (Statics.MessageQueue.Count > 0)
     {
         if (Statics.MessageWindows.Count > 0)
         {
             List<string> tags = (from MessageWindow mw in Statics.MessageWindows select mw.Tag.ToString()).ToList<string>();
             foreach (Commons.Message msg in Statics.MessageQueue)
             {
                 if (!tags.Contains(msg.Sender.UserName))
                 {
                     MessageWindow msgWindow = new MessageWindow(msg.Sender.UserName);
                     msgWindow.Show();
                     Statics.MessageWindows.Add(msgWindow);
                 }
             }
         }
     }
 }
Example #2
0
 private void ShowWindow(MessageWindow window)
 {
     if (window.InvokeRequired)
     {
         window.Invoke(new ShowWindowCallback(ShowWindow), window);
     }
     else
     {
         window.Show();
     }
 }
Example #3
0
        void ProcessMessage(Commons.Message msg, NetworkStream ns)
        {
            Commons.Message response = new Commons.Message();

            switch (msg.Command)
            {
                case Commons.Statics.Commands.LISTUSERS:
                    // List all the users.
                    Statics.CurrentUsers = Commons.UserInfo.Deserialize(msg.Text);
                    break;
                case Commons.Statics.Commands.SENDMSG:
                    //Statics.MessageQueue.Add(msg);
                    if (Statics.MessageWindows.Count > 0)
                    {
                        List<string> tags = (from MessageWindow mw in Statics.MessageWindows select mw.Tag.ToString()).ToList<string>();
                        if (!tags.Contains(msg.Sender.UserName))
                        {
                            MessageWindow msgWindow = new MessageWindow(msg.Sender.UserName);
                            msgWindow.Show();
                            Statics.MessageWindows.Add(msgWindow);
                        }
                        else
                        {
                            MessageWindow msw = (MessageWindow)(from MessageWindow mw in Statics.MessageWindows where mw.Tag.ToString().Equals(msg.Sender.UserName) select mw).ToList<MessageWindow>().First<MessageWindow>();
                            SetMessage(msw, msg);
                        }
                    }
                    else
                    {
                        OpenNewWindow(msg);
                    }
                    break;
                case Commons.Statics.Commands.USERONLINE:
                    if (!Statics.CurrentUsers.Contains(msg.Sender))
                        Statics.CurrentUsers.Add(msg.Sender);
                    break;
                case Commons.Statics.Commands.USEROFFLINE:
                    if (Statics.CurrentUsers.Contains(msg.Sender))
                        Statics.CurrentUsers.Remove(msg.Sender);
                    break;
            }
        }