Пример #1
0
 void Chatting_eChatEvent(ChatRoom cr, Chatting.ChatEvent e, User u, object data)
 {
     if (e != Chatting.ChatEvent.ChatMessage)
     {
         RefreshList();
     }
 }
Пример #2
0
 public GroupChatListItem(ChatRoom room)
 {
     ThisRoom = room;
     this.HorizontalAlignment = HorizontalAlignment.Stretch;
     InitializeComponent();
     this.GotFocus += OnGotFocus;
     this.LostFocus += OnLostFocus;
 }
Пример #3
0
        /// <summary>
        /// When a Lobby creates a chat room.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="createdroom">
        /// The created room.
        /// </param>
        private void Chatting_OnCreateRoom(object sender, ChatRoom createdroom)
        {
            if (createdroom.GroupUser == null || createdroom.GroupUser.UserName != "lobby" || this.Room != null)
            {
                return;
            }

            this.SetRoom(createdroom);
        }
Пример #4
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();
            }
        }
Пример #5
0
 public ChatWindow(ChatRoom room)
 {
     Room = room;
     this.Activated += OnActivated;
     this.Closing += OnClosing;
     InitializeComponent();
     this.Title = Room.IsGroupChat
          ? Room.GroupUser.UserName
          : Room.Users.First(x => x != Program.LobbyClient.Me).UserName;
     Room.OnUserListChange += RoomOnOnUserListChange;
     ChatControl.SetRoom(Room);
 }
Пример #6
0
 public void AddChat(ChatRoom room)
 {
     var r = room;
     this.Dispatcher.Invoke(new Action(() =>
     {
         var chatBarItem = new ChatBarItem(r) { Height = this.barHeight.Value };
         chatBarItem.HeaderMouseUp += ChatBarItemOnPreviewMouseUp;
         this.Items.Add(chatBarItem);
         if (room.GroupUser != null && room.GroupUser.UserName.ToLowerInvariant() == "lobby")
         {
             return;
         }
         this.SelectedItem = chatBarItem;
     }));
 }
Пример #7
0
        private void ChattingOnOnCreateRoom(object sender, ChatRoom room)
        {
            if (room.GroupUser == null || room.GroupUser.UserName != "lobby")
            {
                return;
            }

            _room = room;
        }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChatBarItem"/> class.
 /// </summary>
 /// <param name="chatRoom">
 /// The chat Room.
 /// </param>
 public ChatBarItem(ChatRoom chatRoom = null)
 {
     this.Room = chatRoom;
     this.ConstructControl();
 }
Пример #9
0
 /// <summary>
 /// Set the room for this chat control.
 /// </summary>
 /// <param name="theRoom">
 /// The room.
 /// </param>
 public void SetRoom(ChatRoom theRoom)
 {
     this.room = theRoom;
     this.room.OnMessageReceived += this.RoomOnMessageReceived;
     this.room.OnUserListChange += RoomOnOnUserListChange;
     this.userRefreshTimer = new Timer(this.OnRefreshTimerTick, this, 100, 5000);
 }
Пример #10
0
 /// <summary>
 /// Removes a room from the room list only. Doesn't do anything else.
 /// </summary>
 /// <param name="room">
 /// Room to remove
 /// </param>
 public void RemoveRoom(ChatRoom room)
 {
     // TODO This piece should be replaced with an event that lives inside the chat room object.
     this.Rooms.Remove(room);
 }
Пример #11
0
 /// <summary>
 /// Removes a chat room from the list.
 /// </summary>
 /// <param name="room">Chat room to remove</param>
 public static void RemoveRoom(ChatRoom room)
 {
     Logger.TL(System.Reflection.MethodInfo.GetCurrentMethod().Name, "Rooms");
     lock (Rooms)
     {
         Rooms.Remove(room);
         Logger.UL(System.Reflection.MethodInfo.GetCurrentMethod().Name, "Rooms");
     }
 }
Пример #12
0
 public void ChatEvent(ChatRoom cr, Chatting.ChatEvent e, User user, object data)
 {
     Chatting_eChatEvent(cr,  e,user,data);
 }
Пример #13
0
        void Chatting_eChatEvent(ChatRoom cr, Chatting.ChatEvent e, User user, object data)
        {
            if (cr.ID == ID)
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    switch (e)
                    {
                        case Chatting.ChatEvent.ChatMessage:
                            {
                                Brush b = Brushes.Black;
                                if (user.Uid == Program.lobbyClient.Me.Uid)
                                    b = Brushes.Blue;

                                Run r = getUserRun(user.DisplayName, "[" + user.DisplayName + "] : ");
                                r.Foreground = b;
                                String mess = data as string;
                                AddChatText(r, mess);
                                break;
                            }
                        case Chatting.ChatEvent.MeJoinedChat:
                            {
                                ResetUserList();
                                break;
                            }
                        case Chatting.ChatEvent.UserJoinedChat:
                            {
                                string reg = Registry.ReadValue("Options_HideLoginNotifications");
                                if (reg == "false" || reg == null)
                                {
                                    Run r = new Run("#" + user.DisplayName + ": ");
                                    Brush b = Brushes.DarkGray;
                                    r.ToolTip = DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToLongDateString();
                                    r.Foreground = b;
                                    AddChatText(r, "Joined the chat.", b);
                                    ResetUserList();
                                }
                                break;
                            }
                        case Chatting.ChatEvent.UserLeftChat:
                            {
                                string reg = Registry.ReadValue("Options_HideLoginNotifications");
                                if (reg == "false" || reg == null)
                                {
                                    Run r = new Run("#" + user.DisplayName + ": ");
                                    Brush b = Brushes.LightGray;
                                    r.ToolTip = DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToLongDateString();
                                    r.Foreground = b;
                                    AddChatText(r, "Left the chat.", b);
                                    ResetUserList();
                                }
                                    break;
                            }
                    }
                }));
            }
        }
Пример #14
0
 public ChatBarItem(ChatControl control)
 {
     Room = control.Room;
     chatControl = control;
     this.ConstructControl();
 }
Пример #15
0
 public GroupChatListItem()
 {
     InitializeComponent();
     ThisRoom = new ChatRoom(0);
 }
Пример #16
0
 void LobbyClient_OnDisconnect(object sender, EventArgs e)
 {
     lock (timer)
     {
         Log.Info("Disconnected");
         isConnected = false;
         _room = null;
         Dispatcher.Invoke(new Action(()=>this.HostedGameList.Clear()));
     }
 }
Пример #17
0
        /// <summary>
        /// Get an existing user, or if it doesn't exist, create it.
        /// </summary>
        /// <param name="otherUser">
        /// The other user(or group user if a group chat)
        /// </param>
        /// <param name="group">
        /// Is it a group chat?
        /// </param>
        /// <returns>
        /// The <see cref="ChatRoom"/>.
        /// </returns>
        public ChatRoom GetRoom(User otherUser, bool group = false)
        {
            if (group)
            {
                ChatRoom ret = this.Rooms.FirstOrDefault(x => x.IsGroupChat && x.GroupUser.Equals(otherUser));
                if (ret == null)
                {
                    ret = new ChatRoom(this.NextRid, this.client, otherUser);
                    this.Rooms.Add(ret);
                }

                if(ret != null)
                    this.FireOnCreateRoom(this,ret);
                return ret;
            }
            else
            {
                ChatRoom ret = this.Rooms.FirstOrDefault(x => x.Users.Contains(otherUser) && !x.IsGroupChat);
                if (ret == null)
                {
                    ret = new ChatRoom(this.NextRid, this.client, otherUser);
                    this.Rooms.Add(ret);
                }
                if(ret != null)
                    this.FireOnCreateRoom(this,ret);
                return ret;
            }
        }
Пример #18
0
 private void ChattingOnOnCreateRoom(object sender , ChatRoom room)
 {
     LazyAsync.Invoke(RefreshList);
 }
Пример #19
0
 /// <summary>
 /// Fire OnCreateRoom event.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="room">
 /// The room.
 /// </param>
 private void FireOnCreateRoom(object sender, ChatRoom room)
 {
     if (this.OnCreateRoom != null)
     {
         this.OnCreateRoom(sender, room);
     }
 }
Пример #20
0
        void Chatting_eChatEvent(ChatRoom cr, Chatting.ChatEvent e, User user,object data)
        {
            Dispatcher.Invoke(new Action(() =>
            {

                    ChatWindow cw = Program.ChatWindows.FirstOrDefault(cww => cww.ID == cr.ID);
                    if (cw == null)
                    {
                        ChatWindow c = new ChatWindow(cr.ID);
                        c.Loaded += delegate
                        {
                            c.ChatEvent(cr, e, user, data);
                        };
                        Program.ChatWindows.Add(c);
                        if(cr.ID != 0)
                            c.Show();
                    }
                    else
                    {
                        if (cw.ID != 0)
                        {
                            cw.Show();
                        }
                    }
            }));
        }
Пример #21
0
 /// <summary>
 /// This happens when a new room is created.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="room">
 /// The room.
 /// </param>
 private void LobbyCreateRoom(object sender, ChatRoom room)
 {
     var r = room;
     this.Dispatcher.Invoke(new Action(() =>
         {
             if (Items.OfType<ChatBarItem>().Any(x => x.Room.Rid == room.Rid)) return;
             var chatBarItem = new ChatBarItem(r) { Height = this.barHeight.Value };
             chatBarItem.HeaderMouseUp += ChatBarItemOnPreviewMouseUp;
             this.Items.Add(chatBarItem);
             if (room.GroupUser != null && room.GroupUser.UserName.ToLowerInvariant() == "lobby")
             {
                 return;
             }
             Sounds.PlayMessageSound();
             this.SelectedItem = chatBarItem;
         }));
 }
Пример #22
0
 public void LeaveRoom(ChatRoom room)
 {
     if (room.IsGroupChat && room.GroupUser.JidUser == "lobby") return;
     lock (Rooms)
     {
         if (room.IsGroupChat)
         {
             this.client.MucManager.LeaveRoom(room.GroupUser.UserName, this.client.Me.UserName);
             this.client.RosterManager.RemoveRosterItem(room.GroupUser.FullUserName);
         }
         this.Rooms.Remove(room);
         room.Dispose();
     }
 }