public NewChatRoom GetRoom(NewUser otherUser, bool group=false) { if(group) { var ret = Rooms.SingleOrDefault(x => x.IsGroupChat && x.GroupUser.Equals(otherUser) ); if(ret == null) { ret = new NewChatRoom(NextRid , _client , otherUser); Rooms.Add(ret); if (OnCreateRoom != null) OnCreateRoom(this , ret); } return ret; } else { var ret = Rooms.SingleOrDefault(x => x.Users.Contains(otherUser) && !x.IsGroupChat); if(ret == null) { ret = new NewChatRoom(NextRid,_client,otherUser); Rooms.Add(ret); if (OnCreateRoom != null) OnCreateRoom(this , ret); } return ret; } }
static void Chatting_OnCreateRoom(object sender, NewChatRoom room) { if (ChatWindows.All(x => x.Room.RID != room.RID)) { if(MainWindow != null) MainWindow.Dispatcher.Invoke(new Action(() => ChatWindows.Add(new ChatWindow(room)))); else if(LauncherWindow != null) LauncherWindow.Dispatcher.Invoke(new Action(() => ChatWindows.Add(new ChatWindow(room)))); } }
/// <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, NewChatRoom createdroom) { if (createdroom.GroupUser == null || createdroom.GroupUser.UserName != "lobby" || this.Room != null) { return; } this.SetRoom(createdroom); }
static void Chatting_OnCreateRoom(object sender, NewChatRoom room) { if (ChatWindows.All(x => x.Room.RID != room.RID)) { if (MainWindow != null) { MainWindow.Dispatcher.Invoke(new Action(() => ChatWindows.Add(new ChatWindow(room)))); } else if (LauncherWindow != null) { LauncherWindow.Dispatcher.Invoke(new Action(() => ChatWindows.Add(new ChatWindow(room)))); } } }
public ChatWindow(NewChatRoom room) { InitializeComponent(); Room = room; var cm = new ContextMenu(); var mi = new MenuItem {Header = "Add to friends list"}; mi.Click += MiClick; cm.Items.Add(mi); listBox1.ContextMenu = cm; richTextBox1.Document.LineHeight = 2; Room.OnMessageRecieved += RoomOnOnMessageRecieved; Room.OnUserListChange += RoomOnOnUserListChange; if (!room.IsGroupChat || room.GroupUser != null && room.GroupUser.User.User == "lobby") miLeaveChat.IsEnabled = false; ResetUserList(); }
public WomanVideoFormcs(string currentID, string _friendID, string friendName, bool waitingAnswer, ChatClient.NewChatRoom _newChatRoom) { InitializeComponent(); Rectangle screen = Screen.PrimaryScreen.Bounds; Point maximizedLocation = new Point((screen.Width - 336) / 2, (screen.Height - 305) / 2); this.MaximizedBounds = new Rectangle(maximizedLocation, this.MaximumSize); this._newChatRoom = _newChatRoom; this.currentUserID = currentID; this.friendID = _friendID; this.Text = string.Format("正在和{0}视频会话", friendName); if (!waitingAnswer) //同意视频,开始连接 { this.OnAgree(); } }
public ChatWindow(NewChatRoom room) { InitializeComponent(); Room = room; var cm = new ContextMenu(); var mi = new MenuItem { Header = "Add to friends list" }; mi.Click += MiClick; cm.Items.Add(mi); listBox1.ContextMenu = cm; richTextBox1.Document.LineHeight = 2; Room.OnMessageRecieved += RoomOnOnMessageRecieved; Room.OnUserListChange += RoomOnOnUserListChange; IsLobbyChat = (room.GroupUser != null && room.GroupUser.User.User == "lobby"); if (!room.IsGroupChat) { miLeaveChat.IsEnabled = false; } ResetUserList(); }
private void ChattingOnOnCreateRoom(object sender , NewChatRoom room) { LazyAsync.Invoke(RefreshList); }
/// <summary> /// Fire OnCreateRoom event. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="room"> /// The room. /// </param> private void FireOnCreateRoom(object sender, NewChatRoom room) { if (this.OnCreateRoom != null) { this.OnCreateRoom(sender, room); } }
/// <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(NewChatRoom room) { // TODO This piece should be replaced with an event that lives inside the chat room object. this.Rooms.Remove(room); }
/// <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="NewChatRoom"/>. /// </returns> public NewChatRoom GetRoom(NewUser otherUser, bool group = false) { if (group) { NewChatRoom ret = this.Rooms.FirstOrDefault(x => x.IsGroupChat && x.GroupUser.Equals(otherUser)); if (ret == null) { ret = new NewChatRoom(this.NextRid, this.client, otherUser); this.Rooms.Add(ret); this.FireOnCreateRoom(this, ret); } return ret; } else { NewChatRoom ret = this.Rooms.FirstOrDefault(x => x.Users.Contains(otherUser) && !x.IsGroupChat); if (ret == null) { ret = new NewChatRoom(this.NextRid, this.client, otherUser); this.Rooms.Add(ret); this.FireOnCreateRoom(this, ret); } return ret; } }
private void ChattingOnOnCreateRoom(object sender, NewChatRoom room) { LazyAsync.Invoke(RefreshList); }
/// <summary> /// Initializes a new instance of the <see cref="ChatBarItem"/> class. /// </summary> /// <param name="chatRoom"> /// The chat Room. /// </param> public ChatBarItem(NewChatRoom chatRoom = null) { this.room = chatRoom; this.ConstructControl(); }
/// <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, NewChatRoom 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; })); }
/// <summary> /// Set the room for this chat control. /// </summary> /// <param name="theRoom"> /// The room. /// </param> public void SetRoom(NewChatRoom theRoom) { this.room = theRoom; this.room.OnUserListChange += this.RoomOnUserListChange; this.room.OnMessageReceived += this.RoomOnMessageReceived; this.userRefreshTimer = new Timer(this.OnRefreshTimerTick, this, 5000, 1000); }
private void ChattingOnOnCreateRoom(object sender , NewChatRoom room) { RefreshList(); }
public void RemoveRoom(NewChatRoom room) { Rooms.Remove(room); }
public ChatWindow(NewChatRoom room) { InitializeComponent(); Room = room; chatControl.SetRoom(room); }