Пример #1
0
 public void MoveToWindow(ChatControl chat)
 {
     lock (Locker)
     {
         var win = new ChatWindow(chat);
         WindowManager.ChatWindows.Add(win);
         win.Show();
     }
 }
Пример #2
0
        private void ChattingOnCreateRoom(object sender, ChatRoom room)
        {
            if (room.GroupUser != null && room.GroupUser.UserName.ToLowerInvariant() == "lobby") return;
            lock (Locker)
            {
                // Check if chat room is in a window
                var rw = WindowManager.ChatWindows.FirstOrDefault(x => x.Room.Rid == room.Rid);
                if (rw != null) // There is a chat window for it
                {
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            if (!rw.IsActive)
                            {
                                rw.FlashWindow();
                                Sounds.PlayMessageSound();
                            }
                            if (!rw.IsVisible)
                            {
                                rw.Visibility = Visibility.Visible;
                            }
                        }));
                    return;
                }

                // Check if chat bar has chat room
                var cbi = ChatBar.Items.OfType<ChatBarItem>().FirstOrDefault(x => x.Room.Rid == room.Rid);
                if (cbi != null)
                {
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            if((ChatBar.SelectedItem is ChatBarItem && ChatBar.SelectedItem == cbi) == false)
                                cbi.SetAlert();
                        }));
                    return;
                }

                // If no chat is already active
                if (Prefs.UseWindowsForChat)
                {
                    Application.Current.Dispatcher.Invoke(new Action(() => {
                    var win = new ChatWindow(room);
                    WindowManager.ChatWindows.Add(win);
                    win.Show();
                    }));
                }
                else
                {
                    ChatBar.AddChat(room);
                }
                Sounds.PlayMessageSound();
            }
        }