public NewTabViewModel(ChatClient client)
        {
            this.client = client;

            StartChatCommand = new RelayCommand(_ =>
                {
                    StartChat.SafeInvoke(this, new StartChatEventArgs((contactsView.CurrentItem as ContactViewModel).Contact));
                });
            AddFriendCommand = new RelayCommand(_ =>
                {
                    if (AddFriendText.Length > 0)
                        client.AddFriend(AddFriendText);
                    AddFriendText = "";
                }, _ =>
                {
                    return AddFriendText.Length > 0;
                });

            contactsView = new ListCollectionView(contactVMs);
            contactsView.CustomSort = new ContactComparer();

            client.UserDetailsChange += OnUserDetailsChange;
            client.GroupDetailsChange += OnGroupDetailsChange;

            UpdateContacts(client.Friends, Enumerable.Empty<IUser>());
            UpdateContacts(client.Groups, Enumerable.Empty<IGroup>());
        }
Example #2
0
        internal Conversation(ChatClient client, IContact who, ConversationEvents events)
        {
            this.client = client;
            this.events = events;
            Name = who.Name;
            Contact = who;

            events.UserAdded += OnUserAdded;
            events.UserChanged += OnUserChanged;
            events.UserRemoved += OnUserRemoved;
            events.UserTyping += OnUserTyping;
            events.ChatReceived += OnChatReceived;

            if (Contact is IUser)
            {
                participants.Add(new Participant(Contact as IUser));
            }
            else
            {
                foreach (var member in (Contact as IGroup).Members)
                {
                    participants.Add(new Participant(member));
                }
            }
        }
 protected ContactViewModel(ChatClient client, IContact contact)
 {
     this.client = client;
     this.contact = contact;
     Contact.Changed += OnContactChanged;
     OnContactChanged(Contact, null);
 }
 public ConversationManager(ChatClient client)
 {
     this.client = client;
     client.UserChat += client_UserChat;
     client.GroupChat += client_GroupChat;
     client.UserDetailsChange += client_UserDetailsChange;
     client.GroupDetailsChange += client_GroupDetailsChange;
 }
        public ConversationViewModel(ChatClient client, Conversation convo)
        {
            this.client = client;

            sendChatCommand = new RelayCommand(_ =>
                {
                    Conversation.SendMessage(CurrentMessage, App.Current.ClientFont);
                    CurrentMessage = "";
                }, _ => CurrentMessage.Length > 0);

            App.Current.FontChanged += OnFontChanged;
            OnFontChanged(this, null);

            SetConversation(convo);
        }
        public MainWindowViewModel(IViewController views, ChatClient client, ConnectionManager connection, Dispatcher dispatcher)
        {
            this.views = views;
            this.client = client;
            this.connection = connection;
            this.dispatcher = dispatcher;

            ChangeNameCommand = new RelayCommand(_ => ChangeName());
            ChangeFontCommand = new RelayCommand(_ => ChangeFont());
            ChangeStatusCommand = new RelayCommand(_ => ChangeStatus(_ as string), _ => CanChangeStatus(_ as string));
            CloseChatCommand = new RelayCommand(_ => CloseConversation(_ as ConversationViewModel));
            LogoutCommand = new RelayCommand(_ => LogOut());
            QuitCommand = new RelayCommand(_ => Quit());
            ViewEmotesCommand = new RelayCommand(_ => ViewEmotes());

            stateDetector = new UserStateDetector();
            stateDetector.IdleTimeThreshold = 60 * 5; // 5 minutes
            stateDetector.IsIdleEnabled = true;
            stateDetector.IsBusyEnabled = true;
            stateDetector.UserIdleChanged += OnUserIdleChanged;
            stateDetector.UserBusyChanged += OnUserBusyChanged;

            client.StreamError += OnStreamError;
            me = new UserViewModel(client, client.Me);
            conversations = new ConversationManager(client);
            conversations.NewConversation += OnNewConversation;

            openTabsView = new ListCollectionView(openTabs);
            openTabsView.CurrentChanged += OnCurrentTabChanged;

            var newTabVM = new NewTabViewModel(client);
            newTabVM.StartChat += OnStartChat;
            openTabs.Add(newTabVM);

            tabHighlightTimer.Elapsed += OnTabHighlight;

            client.ListFriends();
            client.ListGroups();
        }
Example #7
0
 public static User CreateGhost(ChatClient client, string name)
 {
     return new User(client, new UserDescription() { Name = name, DisplayName = name, Status = UserStatus.Unknown, Friend = false });
 }
Example #8
0
 public User(ChatClient client, UserDescription description)
 {
     this.client = client;
     Update(description);
     client.UserChat += client_UserChat;
 }
Example #9
0
 public Group(ChatClient client, GroupDescription description)
 {
     this.client = client;
     Update(description);
     client.GroupChat += client_GroupChat;
 }
 public static ContactViewModel Create(ChatClient client, IContact contact)
 {
     if (contact is IUser)
         return new UserViewModel(client, contact as IUser);
     else if (contact is IGroup)
         return new GroupViewModel(client, contact as IGroup);
     else
         throw new NotSupportedException();
 }
 public UserViewModel(ChatClient client, IUser entity)
     : base(client, entity)
 {
 }
        public GroupViewModel(ChatClient client, IGroup entity)
            : base(client, entity)
        {
            entity.UserAdded += OnUserAdded;
            entity.UserRemoved += OnUserRemoved;

            foreach (var member in entity.Members)
                memberModels.Add(new UserViewModel(client, member));
        }