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