Пример #1
0
        //Blink and add to notification list if messaged
        void ChatClient_OnMessage(object sender, jabber.protocol.client.Message msg)
        {
            //If is special message, don't show popup
            if (msg.Subject != null)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    ChatSubjects subject = (ChatSubjects)Enum.Parse(typeof(ChatSubjects), msg.Subject, true);

                    if ((subject == ChatSubjects.PRACTICE_GAME_INVITE ||
                        subject == ChatSubjects.GAME_INVITE) &&
                        Client.NotificationContainer.Visibility != System.Windows.Visibility.Visible)
                    {
                        NotificationButton.Content = ".";
                    }
                }));
                return;
            }

            if (Client.AllPlayers.ContainsKey(msg.From.User) && !String.IsNullOrWhiteSpace(msg.Body))
            {
                ChatPlayerItem chatItem = Client.AllPlayers[msg.From.User];
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    NotificationChatPlayer player = null;
                    foreach (NotificationChatPlayer x in ChatListView.Items)
                    {
                        if (x.PlayerName == chatItem.Username)
                        {
                            player = x;
                            break;
                        }
                    }

                    if (player == null)
                    {
                        player = new NotificationChatPlayer();
                        player.Tag = chatItem;
                        player.PlayerName = chatItem.Username;
                        player.Margin = new Thickness(1, 0, 1, 0);
                        player.PlayerLabelName.Content = chatItem.Username;
                        Client.ChatListView.Items.Add(player);
                    }

                    if (Client.ChatItem != null)
                    {
                        if ((string)Client.ChatItem.PlayerLabelName.Content != chatItem.Username)
                        {
                            player.BlinkRectangle.Visibility = System.Windows.Visibility.Visible;
                        }
                    }
                    else
                    {
                        player.BlinkRectangle.Visibility = System.Windows.Visibility.Visible;
                    }
                }));
            }
        }
Пример #2
0
        //Blink and add to notification list if messaged
        private void XmppConnection_OnMessage(object sender, Message msg)
        {
            //If is special message, don't show popup
            if (msg.Subject != null)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    var subject = (ChatSubjects)Enum.Parse(typeof(ChatSubjects), msg.Subject, true);

                    if ((subject == ChatSubjects.PRACTICE_GAME_INVITE ||
                         subject == ChatSubjects.GAME_INVITE) &&
                        Client.NotificationContainer.Visibility != Visibility.Visible)
                    {
                        NotificationButton.Content = ".";
                    }
                }));
                return;
            }

            if (!Client.AllPlayers.ContainsKey(msg.From.User) || string.IsNullOrWhiteSpace(msg.Body))
                return;
            if (msg.Body.ToLower().Contains("elo") && msg.Body.ToLower().Contains("boost"))
                return;

            ChatPlayerItem chatItem = Client.AllPlayers[msg.From.User];
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                NotificationChatPlayer player =
                    ChatListView.Items.Cast<object>()
                        .Where(i => i.GetType() == typeof(NotificationChatPlayer))
                        .Cast<NotificationChatPlayer>()
                        .FirstOrDefault(x => x.PlayerName == chatItem.Username);

                if (player == null)
                {
                    player = new NotificationChatPlayer
                    {
                        Tag = chatItem,
                        PlayerName = chatItem.Username,
                        Margin = new Thickness(1, 0, 1, 0),
                        PlayerLabelName = { Content = chatItem.Username }
                    };
                    Client.ChatListView.Items.Add(player);
                }

                if (Client.ChatItem != null)
                {
                    if ((string)Client.ChatItem.PlayerLabelName.Content != chatItem.Username)
                    {
                        player.BlinkRectangle.Visibility = Visibility.Visible;
                    }
                }
                else
                    player.BlinkRectangle.Visibility = Visibility.Visible;
            }));
        }
Пример #3
0
        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            NotificationChatPlayer tempPlayer =
                Client.ChatListView.Items.Cast <object>()
                .Where(i => i.GetType() == typeof(NotificationChatPlayer))
                .Cast <NotificationChatPlayer>()
                .FirstOrDefault(x => x.PlayerLabelName.Content == Client.ChatItem.PlayerLabelName.Content);

            Client.MainGrid.Children.Remove(Client.ChatItem);
            Client.ChatClient.OnMessage -= Client.ChatItem.ChatClient_OnMessage;
            Client.ChatItem              = null;

            if (tempPlayer != null)
            {
                Client.ChatListView.Items.Remove(tempPlayer);
            }
        }
        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            NotificationChatPlayer tempPlayer = null;

            foreach (NotificationChatPlayer x in Client.ChatListView.Items)
            {
                if (x.PlayerLabelName.Content == Client.ChatItem.PlayerLabelName.Content)
                {
                    tempPlayer = x;
                    break;
                }
            }

            Client.MainGrid.Children.Remove(Client.ChatItem);
            Client.ChatClient.OnMessage -= Client.ChatItem.ChatClient_OnMessage;
            Client.ChatItem              = null;

            Client.ChatListView.Items.Remove(tempPlayer);
        }
Пример #5
0
 private void ChatListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count > 0)
     {
         ChatPlayer player = (ChatPlayer)e.AddedItems[0];
         ChatListView.SelectedIndex = -1;
         ChatPlayerItem playerItem = (ChatPlayerItem)player.Tag;
         LastPlayerItem = playerItem;
         foreach (NotificationChatPlayer x in Client.ChatListView.Items)
         {
             if ((string)x.PlayerLabelName.Content == playerItem.Username)
                 return;
         }
         NotificationChatPlayer ChatPlayer = new NotificationChatPlayer();
         ChatPlayer.Tag = playerItem;
         ChatPlayer.PlayerName = playerItem.Username;
         ChatPlayer.Margin = new Thickness(1, 0, 1, 0);
         ChatPlayer.PlayerLabelName.Content = playerItem.Username;
         Client.ChatListView.Items.Add(ChatPlayer);
     }
 }
Пример #6
0
        private void PlayersListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (selection.AddedItems.Count <= 0)
                return;

            var player = (ChatPlayer)selection.AddedItems[0];
            ((ListView)e.Source).SelectedIndex = -1;
            var playerItem = (ChatPlayerItem)player.Tag;
            List<NotificationChatPlayer> items = new List<NotificationChatPlayer>();
            foreach (object x in Client.ChatListView.Items)
            {
                if (x.GetType() == typeof(NotificationChatPlayer))
                    items.Add((NotificationChatPlayer)x);
            }
            if (items.Any(x => (string)x.PlayerLabelName.Content == playerItem.Username))
                return;

            var chatPlayer = new NotificationChatPlayer
            {
                Tag = playerItem,
                PlayerName = playerItem.Username,
                Margin = new Thickness(1, 0, 1, 0),
                PlayerLabelName = { Content = playerItem.Username }
            };
            Client.ChatListView.Items.Add(chatPlayer);
        }