Inheritance: INotifyPropertyChanged
コード例 #1
0
ファイル: DialogModel.cs プロジェクト: Grief-Code/kilogram
        public void ProcessNewMessage(MessageModel messageModel) {
            logger.info("processing message and adding to observable collection");
            if (messageModel is MessageModelDelivered) {
                MessageModelDelivered newMessage = (MessageModelDelivered) messageModel;
                var selectedMessages = from message in messages
                    where message is MessageModelDelivered && ((MessageModelDelivered) message).Id == messageModel.Id
                    select message;
                if (selectedMessages.Any()) {
                    logger.info("message with this ID already in list");
                    return;
                }

            }

            messages.Add(messageModel);
            Peer peer = Peer;
            if (peer.Constructor == Constructor.peerUser) {
                if (userTyping != null) {
                    userTyping = null;
                }
            } else if (peer.Constructor == Constructor.peerChat) {
                if (chatTyping.Count != 0) {
                    chatTyping.Clear();
                }
            }

            OnPropertyChanged("PreviewOrAction");
            OnPropertyChanged("StatusOrAction");
            OnPropertyChanged("MessageDeliveryStateProperty");
        }
コード例 #2
0
 private async Task DelayedDestroyMessage(MessageModel message) {
     await Task.Delay(TimeSpan.FromSeconds(ttl));
     if(messages.Contains(message)) {
         messages.Remove(message);
     }
 }
コード例 #3
0
        private async Task DoDeleteMessage(MessageModel message) {
            List<int> idsDeleted = await TelegramSession.Instance.Api.messages_deleteMessages(new List<int>(message.Id));

            if (idsDeleted.Count > 0) {
                model.Messages.Remove(message);
            }
        }