public void ShowChatWindow(Room room) { var control = HostedControls.GetControl<ChatFrameViewModel>(); EnvWindowsManager.ShowNestedWindow(control); var context = HostedControls.GetContext<ChatFrameViewModel>(); context.AttachEntity(room); }
private Room InitRoom(IRoomInfo roomInfo) { Room room = new Room(); room.Id = Guid.NewGuid(); room.Name = roomInfo.RoomName; room.Server = roomInfo.Server; room.Nickname = roomInfo.Nickname; return room; }
public IRoomContext GetRoomContext(Room room) { if (_rooms.ContainsKey(room)) { return _rooms[room]; } var context = new RoomContext(room); _rooms.Add(room, context); context.StartListen(); return context; }
public RoomContext(Room room) { Bare = new Jid(room.Name, room.Server, null); Room = room; Members = new ObservableCollection<IRoomMember>(); _client = AppServices.Get<IModelContext>().GetClientByRoom(room); _connection = AppServices.Get<IConnectionManager>() .GetOrCreateConnection(_client) .Connection; }
public static Predicate<IMessage> To(Room room) { return message => { var client = AppServices.Get<IModelContext>().GetClientByRoom(room); if (client == null) return false; if (message.XmppMessage.To == null) return false; return message.ClientId == client.Id && string.Equals(message.XmppMessage.To.Bare, XmppIdConverter.Jid(room).Bare); }; }
public RoomChatViewModel(IFrameViewModel frame, Room room) { _frame = frame; _room = room; var chatDocument = new FlowDocument(); ChatTextBox = new RichTextBox(chatDocument); ChatTextBox.IsDocumentEnabled = true; ChatTextBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; ChatTextBox.Background = System.Windows.Media.Brushes.Transparent; ChatTextBox.IsReadOnly = true; _conversationThread = CreateThread(chatDocument); MessageTextBox = new RichTextBox(new FlowDocument()); MessageTextBox.IsDocumentEnabled = true; MessageTextBox.Background = System.Windows.Media.Brushes.Transparent; MessageTextBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; ParseCurrentHistory(); SetTheme(ThemeManager.ActiveTheme); _historyLoader = CreateHistoryLoader(); }
public Client GetClientByRoom(Room room) { return _account.XmppClients.FirstOrDefault(client => client.Rooms.Contains(room)); }
public static Jid Jid(Room room) { return new Jid(room.Name, room.Server, null); }
public RoomResourceViewModel(Room room) { _room = room; SetCommands(); }
public void SendMessage(Room to, Message outMessage) { outMessage.To = XmppIdConverter.Jid(to); outMessage.Type = MessageType.groupchat; Connection.Send(outMessage); }
public void AttachEntity(Room room) { var activeChat = ActiveChats.FirstOrDefault(contact => contact.Model == room); if (activeChat == null) { activeChat = new RoomChatViewModel(this, room); MessageFeed.Subscribe(activeChat); activeChat.StartListen(); ActiveChats.Add(activeChat); } CurrentChat = activeChat; }
private static IRoomContext GetContext(Room target) { return AppServices.Get<ISessionModel>().GetRoomContext(target); }
public static IMessageBuilder Create(Room room) { return new TextMessageBuilder(); }