Inheritance: INotifyPropertyChanged
Exemple #1
0
 public void ShowChatWindow(Room room)
 {
     var control = HostedControls.GetControl<ChatFrameViewModel>();
     EnvWindowsManager.ShowNestedWindow(control);
     var context = HostedControls.GetContext<ChatFrameViewModel>();
     context.AttachEntity(room);
 }
Exemple #2
0
        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;
        }
Exemple #3
0
 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;
 }
Exemple #4
0
        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;
        }
Exemple #5
0
 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);
     };
 }
Exemple #6
0
        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();
        }
Exemple #7
0
 public Client GetClientByRoom(Room room)
 {
     return _account.XmppClients.FirstOrDefault(client => client.Rooms.Contains(room));
 }
Exemple #8
0
 public static Jid Jid(Room room)
 {
     return new Jid(room.Name, room.Server, null);
 }
 public RoomResourceViewModel(Room room)
 {
     _room = room;
     SetCommands();
 }
Exemple #10
0
 public void SendMessage(Room to, Message outMessage)
 {
     outMessage.To = XmppIdConverter.Jid(to);
     outMessage.Type = MessageType.groupchat;
     Connection.Send(outMessage);
 }
Exemple #11
0
 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;
 }
Exemple #12
0
 private static IRoomContext GetContext(Room target)
 {
     return AppServices.Get<ISessionModel>().GetRoomContext(target);
 }
Exemple #13
0
 public static IMessageBuilder Create(Room room)
 {
     return new TextMessageBuilder();
 }