示例#1
0
        internal static void ChatClient_OnMessage(object sender, jabber.protocol.client.Message msg)
        {
            MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                if (OnMessage != null)
                {
                    OnMessage(sender, msg);
                }

                if (msg.Subject != null)
                {
                    ChatSubjects subject = (ChatSubjects)Enum.Parse(typeof(ChatSubjects), msg.Subject, true);

                    if (subject == ChatSubjects.PRACTICE_GAME_INVITE ||
                        subject == ChatSubjects.GAME_INVITE)
                    {
                        MainWin.FlashWindow();
                        NotificationPopup pop   = new NotificationPopup(subject, msg);
                        pop.Height              = 230;
                        pop.HorizontalAlignment = HorizontalAlignment.Right;
                        pop.VerticalAlignment   = VerticalAlignment.Bottom;
                        NotificationGrid.Children.Add(pop);
                    }
                    else if (subject == ChatSubjects.GAME_MSG_OUT_OF_SYNC)
                    {
                        MessageOverlay messageOver         = new MessageOverlay();
                        messageOver.MessageTitle.Content   = "Game no longer exists";
                        messageOver.MessageTextBox.Text    = "The game you are looking for no longer exists.";
                        Client.OverlayContainer.Content    = messageOver.Content;
                        Client.OverlayContainer.Visibility = Visibility.Visible;
                    }
                }
            }));

            //On core thread
            if (msg.Subject != null)
            {
                return;
            }

            if (AllPlayers.ContainsKey(msg.From.User) && !String.IsNullOrWhiteSpace(msg.Body))
            {
                ChatPlayerItem chatItem = AllPlayers[msg.From.User];
                chatItem.Messages.Add(chatItem.Username + "|" + msg.Body);
                MainWin.FlashWindow();
            }
        }
示例#2
0
        internal static void ChatClient_OnMessage(object sender, jabber.protocol.client.Message msg)
        {
            if (msg.Subject != null)
            {
                MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    ChatSubjects subject = (ChatSubjects)Enum.Parse(typeof(ChatSubjects), msg.Subject, true);
                    //NotificationPopup pop = new NotificationPopup(subject, msg);
                    //pop.Height = 230;
                    //pop.HorizontalAlignment = HorizontalAlignment.Right;
                    //pop.VerticalAlignment = VerticalAlignment.Bottom;
                    //Client.NotificationGrid.Children.Add(pop);
                }));

                return;
            }

            if (AllPlayers.ContainsKey(msg.From.User) && !String.IsNullOrWhiteSpace(msg.Body))
            {
                ChatPlayerItem chatItem = AllPlayers[msg.From.User];
                chatItem.Messages.Add(chatItem.Username + "|" + msg.Body);
                MainWin.FlashWindow();
            }
        }