예제 #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
파일: ChatBar.cs 프로젝트: rexperalta/OCTGN
 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
파일: ChatBarItem.cs 프로젝트: TriAdX/OCTGN
 /// <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
파일: Chat.cs 프로젝트: Cosworth32/OCTGN
 /// <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
파일: Chat.cs 프로젝트: Cosworth32/OCTGN
        /// <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
파일: Chat.cs 프로젝트: Cosworth32/OCTGN
 /// <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
파일: ChatBar.cs 프로젝트: haplo63/OCTGN
 /// <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
파일: Chat.cs 프로젝트: jonbonne/OCTGN
 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();
     }
 }