예제 #1
0
        public void SetActiveChatContact(VATRPContact contact, IntPtr callPtr)
        {
            if (contact == null)
            {
                return;
            }

            if (Chat != null && Chat.Contact == contact)
            {
                Chat.Contact.UnreadMsgCount = 0;
                Chat.UnreadMsgCount         = 0;
                ChangeUnreadCounter();
                _chatsManager.ActivateChat(Chat);
                return;
            }

            this._chat = _chatsManager.GetChat(contact, false);

            var contactVM = FindContactViewModel(contact);

            if (contactVM == null)
            {
                contactVM = new ContactViewModel(contact);
                this.Contacts.Add(contactVM);
            }

            if (ChatViewContact != null && ChatViewContact.Contact != contactVM.Contact)
            {
                ChatViewContact.IsSelected = false;
            }

            ChatViewContact = contactVM;

            if (Chat != null)
            {
                Chat.CallPtr = callPtr;

                if (Chat.Contact != null)
                {
                    Chat.Contact.UnreadMsgCount        = 0;
                    this.Chat.Contact.PropertyChanged += this.Contact_PropertyChanged;
                }

                Chat.CharsCountInBubble = 0;
                Chat.UnreadMsgCount     = 0;
                ChangeUnreadCounter();
                _chatsManager.ActivateChat(Chat);
                if (App.CurrentAccount != null)
                {
                    Chat.MessageFont = App.CurrentAccount.RTTFontFamily;
                }
            }

            ChatViewContact.IsSelected = true;
            IsMessagesLoaded           = false;

            this.MessagesListView = CollectionViewSource.GetDefaultView(this.Messages);
            this.MessagesListView.SortDescriptions.Add(new SortDescription("MessageTime",
                                                                           ListSortDirection.Ascending));

            OnPropertyChanged("Chat");
            try
            {
                if (MessagesListView != null && this.Messages != null)
                {
                    MessagesListView.Refresh();
                }
            }
            catch (Exception)
            {
            }
            if (ConversationUpdated != null)
            {
                ConversationUpdated(this, EventArgs.Empty);
            }
        }
예제 #2
0
        public void CreateRttConversation(VATRPChat chatRoom)
        {
            if (chatRoom == null)
            {
                return;
            }

            if (this.Chat != null)
            {
                _chatsManager.CloseChat(this.Chat);
            }

            this.Chat = chatRoom;

            var contactVM = FindContactViewModel(chatRoom.Contact);

            if (contactVM == null)
            {
                contactVM = new ContactViewModel(chatRoom.Contact);
                this.Contacts.Add(contactVM);
            }

            this.ChatViewContact = contactVM;

            Chat.CharsCountInBubble = 0;
            Chat.UnreadMsgCount     = 0;
            if (App.CurrentAccount != null)
            {
                Chat.MessageFont = App.CurrentAccount.RTTFontFamily;
            }

            if (App.CurrentAccount != null)
            {
                Chat.MessageFontSize = App.CurrentAccount.RTTFontSize;
            }
            ChatViewContact.IsSelected = true;

            this.MessagesListView = CollectionViewSource.GetDefaultView(this.Messages);
            this.MessagesListView.SortDescriptions.Add(new SortDescription("MessageTime",
                                                                           ListSortDirection.Ascending));

            OnPropertyChanged("Chat");
            try
            {
                if (MessagesListView != null && MessagesListView.SourceCollection != null)
                {
                    MessagesListView.Refresh();
                }
            }
            catch (Exception)
            {
            }

            UpdateMessagingView();
#if false
            if (Chat != null)
            {
                Chat.InsertRttWrapupMarkers(callPtr);
            }
#endif
        }