Exemplo n.º 1
0
 private void _outboundMessage_MessageSent(object sender, EventArgs e)
 {
     if (this._outboundMessage.OutboundMessageStatus == OutboundMessageStatus.Delivered)
     {
         this._message.date = Extensions.DateTimeToUnixTimestamp(this._outboundMessage.DeliveryDateTime, true);
         this._message.mid  = (int)this._outboundMessage.DeliveredMessageId;
         int index = 0;
         foreach (IOutboundAttachment outboundAttachment1 in this._outboundMessage.Attachments.Where <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => !a.IsGeo)))
         {
             if (outboundAttachment1.IsUploadAttachment && outboundAttachment1 is OutboundPhotoAttachment && index < this._message.attachments.Count)
             {
                 Attachment          attachment          = this._message.attachments[index];
                 IOutboundAttachment outboundAttachment2 = outboundAttachment1;
                 if (attachment.photo != null && outboundAttachment2.GetAttachment().photo != null)
                 {
                     Photo photo = outboundAttachment2.GetAttachment().photo;
                     attachment.photo.aid      = photo.aid;
                     attachment.photo.pid      = photo.id;
                     attachment.photo.src      = photo.photo_130;
                     attachment.photo.src_big  = photo.photo_604;
                     attachment.photo.owner_id = photo.owner_id;
                 }
             }
             ++index;
         }
         if (this.GraffitiAttachment != null)
         {
             OutboundMessageViewModel outboundMessage = this._outboundMessage;
             Doc doc1;
             if (outboundMessage == null)
             {
                 doc1 = (Doc)null;
             }
             else
             {
                 GraffitiAttachmentItem graffitiAttachmentItem = outboundMessage.GraffitiAttachmentItem;
                 if (graffitiAttachmentItem == null)
                 {
                     doc1 = (Doc)null;
                 }
                 else
                 {
                     Attachment attachment = graffitiAttachmentItem.CreateAttachment();
                     doc1 = attachment != null ? attachment.doc : (Doc)null;
                 }
             }
             Doc doc2 = doc1;
             if (doc2 != null && this._message.attachments.Count > 0)
             {
                 Attachment attachment = this._message.attachments[0];
                 if (attachment.doc != null)
                 {
                     attachment.doc = doc2;
                 }
             }
         }
         this.EnsureCorrectOrderAfterDelivery();
     }
     this.RefreshUIProperties();
 }
Exemplo n.º 2
0
        public MessageViewModel(OutboundMessageViewModel outboundMessage)
        {
            this._outboundMessage = outboundMessage;
            Message message = new Message();

            message.@out = 1;
            if (outboundMessage.IsChat)
            {
                message.chat_id = (int)outboundMessage.UserOrChatId;
            }
            else
            {
                message.uid = (int)outboundMessage.UserOrChatId;
            }
            message.date        = Extensions.DateTimeToUnixTimestamp(DateTime.UtcNow, true);
            message.sticker_id  = outboundMessage.StickerItem == null ? 0 : outboundMessage.StickerItem.StickerId;
            message.body        = message.sticker_id != 0 || outboundMessage.GraffitiAttachmentItem != null ? "" : outboundMessage.MessageText;
            message.attachments = new List <Attachment>();
            if (message.sticker_id == 0)
            {
                foreach (IOutboundAttachment outboundAttachment in outboundMessage.Attachments.Where <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => !a.IsGeo)))
                {
                    Attachment attachment = outboundAttachment.GetAttachment();
                    if (attachment != null)
                    {
                        message.attachments.Add(attachment);
                    }
                }
            }
            if (outboundMessage.StickerItem != null)
            {
                message.attachments.Add(outboundMessage.StickerItem.CreateAttachment());
            }
            if (outboundMessage.GraffitiAttachmentItem != null)
            {
                message.attachments.Add(outboundMessage.GraffitiAttachmentItem.CreateAttachment());
            }
            if (message.sticker_id == 0)
            {
                OutboundGeoAttachment outboundGeoAttachment = outboundMessage.Attachments.FirstOrDefault <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => a.IsGeo)) as OutboundGeoAttachment;
                if (outboundGeoAttachment != null)
                {
                    message.geo = new Geo()
                    {
                        coordinates = string.Format("{0} {1}", (object)outboundGeoAttachment.Latitude.ToString((IFormatProvider)CultureInfo.InvariantCulture), (object)outboundGeoAttachment.Longitude.ToString((IFormatProvider)CultureInfo.InvariantCulture))
                    }
                }
                ;
                OutboundForwardedMessages forwardedMessages = outboundMessage.Attachments.FirstOrDefault <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => a is OutboundForwardedMessages)) as OutboundForwardedMessages;
                message.fwd_messages = forwardedMessages != null ? new List <Message>((IEnumerable <Message>)forwardedMessages.Messages) : new List <Message>();
            }
            else
            {
                message.fwd_messages = new List <Message>();
            }
            this.InitializeWithMessage(message);
        }
Exemplo n.º 3
0
        public void Read(BinaryReader reader)
        {
            int num1 = reader.ReadInt32();

            this._message           = reader.ReadGeneric <Message>();
            this._associatedUser    = reader.ReadGeneric <User>();
            this._forwardedMessages = new ObservableCollection <MessageViewModel>(reader.ReadList <MessageViewModel>());
            this._isForwarded       = reader.ReadBoolean();
            this._outboundMessage   = reader.ReadGeneric <OutboundMessageViewModel>();
            this._attachments       = new ObservableCollection <AttachmentViewModel>(reader.ReadList <AttachmentViewModel>());
            this.IsInSelectionMode  = reader.ReadBoolean();
            int num2 = 2;

            if (num1 >= num2)
            {
                this._associatedUser2 = reader.ReadGeneric <User>();
            }
            this.RefreshUIProperties();
        }