private void Grid_Tap(object sender, System.Windows.Input.GestureEventArgs e) { this.ForceFocusIfNeeded(); FrameworkElement frameworkElement = sender as FrameworkElement; if (frameworkElement == null) { return; } IOutboundAttachment dataContext1 = frameworkElement.DataContext as IOutboundAttachment; if (dataContext1 is IHandleTap) { (dataContext1 as IHandleTap).OnTap(); } else { if (dataContext1 == null) { return; } WallPostViewModel dataContext2 = base.DataContext as WallPostViewModel; if (dataContext2 == null || dataContext1 == null) { return; } dataContext2.UploadAttachment(dataContext1, null); } }
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(); }
private void publishNowMenuItem_Click(object sender, RoutedEventArgs e) { WallPostViewModel wallPostViewModel = new WallPostViewModel(this._wallPost, this.AdminLevel, (WallRepostInfo)null); wallPostViewModel.WMMode = WallPostViewModel.Mode.PublishWallPost; wallPostViewModel.IsPublishSuggestedSuppressed = true; IOutboundAttachment timerAttachment = wallPostViewModel.OutboundAttachments.FirstOrDefault <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => a.AttachmentId == "timestamp")); if (timerAttachment != null) { wallPostViewModel.OutboundAttachments.Remove(timerAttachment); } wallPostViewModel.Publish((Action <ResultCode>)(res => Execute.ExecuteOnUIThread((Action)(() => { if (res == ResultCode.Succeeded) { if (this._wallPost.IsFromGroup()) { long groupId = -this._wallPost.owner_id; Group group = this._groups.FirstOrDefault <Group>((Func <Group, bool>)(g => g.id == groupId)); if (group == null) { return; } GenericInfoUC.ShowPublishResult(GenericInfoUC.PublishedObj.WallPost, groupId, group.name); } else if (this._wallPost.owner_id >= 0L) { GenericInfoUC.ShowPublishResult(GenericInfoUC.PublishedObj.WallPost, 0L, ""); } else { long communityId = -this._wallPost.owner_id; Group group = this._groups.FirstOrDefault <Group>((Func <Group, bool>)(g => g.id == communityId)); if (group == null) { return; } GenericInfoUC.ShowPublishResult(GenericInfoUC.PublishedObj.WallPost, communityId, group.name); } } else if (res == ResultCode.PostsLimitOrAlreadyScheduled) { if (timerAttachment != null) { new GenericInfoUC(2000).ShowAndHideLater(CommonResources.ScheduledForExistingTime, null); } else { new GenericInfoUC(2000).ShowAndHideLater(CommonResources.PostsLimitReached, null); } } else { new GenericInfoUC(2000).ShowAndHideLater(CommonResources.Error, null); } })))); }
private bool HandleInputParams(NavigationEventArgs e = null) { if (ParametersRepository.GetParameterForIdAndReset("GoPickImage") != null) { this.ShowPhotoChooser(true); return(true); } string text = ParametersRepository.GetParameterForIdAndReset("NewMessageContents") as string; if (!string.IsNullOrEmpty(text)) { this.WallPostVM.Text = text; } GeoCoordinate geoCoordinate = ParametersRepository.GetParameterForIdAndReset("NewPositionToBeAttached") as GeoCoordinate; if (geoCoordinate != null) { OutboundGeoAttachment attachment = new OutboundGeoAttachment(geoCoordinate.Latitude, geoCoordinate.Longitude); this.WallPostVM.AddAttachment(attachment); } Poll poll = ParametersRepository.GetParameterForIdAndReset("UpdatedPoll") as Poll; if (poll != null) { IEnumerable <IOutboundAttachment> arg_B2_0 = this.WallPostVM.Attachments; Func <IOutboundAttachment, bool> arg_B2_1 = new Func <IOutboundAttachment, bool>((a) => { return(a is OutboundPollAttachment); }); OutboundPollAttachment outboundPollAttachment = Enumerable.FirstOrDefault <IOutboundAttachment>(arg_B2_0, arg_B2_1) as OutboundPollAttachment; if (outboundPollAttachment != null) { outboundPollAttachment.Poll = poll; } else { OutboundPollAttachment attachment2 = new OutboundPollAttachment(poll); this.WallPostVM.AddAttachment(attachment2); } } Stream stream = ParametersRepository.GetParameterForIdAndReset("ChoosenPhoto") as Stream; List <Stream> list = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotos") as List <Stream>; List <Stream> list2 = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotosPreviews") as List <Stream>; if (stream != null) { if (!this._fromPhotoPicker || this._isForwardNav) { OutboundPhotoAttachment attachment3 = OutboundPhotoAttachment.CreateForUploadNewPhoto(stream, this.WallPostVM.UserOrGroupId, this.WallPostVM.IsGroup, null, PostType.WallPost); this.WallPostVM.AddAttachment(attachment3); this.WallPostVM.UploadAttachments(); } } else if (list != null) { if (!this._fromPhotoPicker || this._isForwardNav) { for (int i = 0; i < list.Count; i++) { Stream arg_1C4_0 = list[i]; Stream previewStream = null; if (list2 != null && list2.Count > i) { previewStream = list2[i]; } OutboundPhotoAttachment attachment4 = OutboundPhotoAttachment.CreateForUploadNewPhoto(arg_1C4_0, this.WallPostVM.UserOrGroupId, this.WallPostVM.IsGroup, previewStream, PostType.WallPost); this.WallPostVM.AddAttachment(attachment4); } this.WallPostVM.UploadAttachments(); } } else if (this.WallPostVM.GoDirectlyToPhotoChooser && e != null && e.IsNavigationInitiator) { Navigator.Current.GoBack(); } Photo photo = ParametersRepository.GetParameterForIdAndReset("PickedPhoto") as Photo; if (photo != null) { OutboundPhotoAttachment attachment5 = OutboundPhotoAttachment.CreateForChoosingExistingPhoto(photo, this.WallPostVM.UserOrGroupId, this.WallPostVM.IsGroup, PostType.WallPost); this.WallPostVM.AddAttachment(attachment5); } VKClient.Common.Backend.DataObjects.Video video = ParametersRepository.GetParameterForIdAndReset("PickedVideo") as VKClient.Common.Backend.DataObjects.Video; if (video != null) { OutboundVideoAttachment attachment6 = new OutboundVideoAttachment(video); this.WallPostVM.AddAttachment(attachment6); } AudioObj audioObj = ParametersRepository.GetParameterForIdAndReset("PickedAudio") as AudioObj; if (audioObj != null) { OutboundAudioAttachment attachment7 = new OutboundAudioAttachment(audioObj); this.WallPostVM.AddAttachment(attachment7); } Doc doc = ParametersRepository.GetParameterForIdAndReset("PickedDocument") as Doc; if (doc != null) { OutboundDocumentAttachment attachment8 = new OutboundDocumentAttachment(doc); this.WallPostVM.AddAttachment(attachment8); } TimerAttachment timerAttachment = ParametersRepository.GetParameterForIdAndReset("PickedTimer") as TimerAttachment; if (timerAttachment != null) { OutboundTimerAttachment attachment9 = new OutboundTimerAttachment(timerAttachment); IEnumerable <IOutboundAttachment> arg_326_0 = this.WallPostVM.Attachments; Func <IOutboundAttachment, bool> arg_326_1 = new Func <IOutboundAttachment, bool>((a) => { return(a.AttachmentId == "timestamp"); }); IOutboundAttachment outboundAttachment = Enumerable.FirstOrDefault <IOutboundAttachment>(arg_326_0, arg_326_1); if (outboundAttachment != null) { int index = this.WallPostVM.Attachments.IndexOf(outboundAttachment); this.WallPostVM.RemoveAttachment(outboundAttachment); this.WallPostVM.InsertAttachment(index, attachment9); } else { this.WallPostVM.AddAttachment(attachment9); } this.WallPostVM.FromGroup = true; } FileOpenPickerContinuationEventArgs fileOpenPickerContinuationEventArgs = ParametersRepository.GetParameterForIdAndReset("FilePicked") as FileOpenPickerContinuationEventArgs; if ((fileOpenPickerContinuationEventArgs != null && Enumerable.Any <StorageFile>(fileOpenPickerContinuationEventArgs.Files)) || ParametersRepository.Contains("PickedPhotoDocuments")) { object parameterForIdAndReset = ParametersRepository.GetParameterForIdAndReset("FilePickedType"); IReadOnlyList <StorageFile> arg_3DA_0; if (fileOpenPickerContinuationEventArgs == null) { IReadOnlyList <StorageFile> readOnlyList = (List <StorageFile>)ParametersRepository.GetParameterForIdAndReset("PickedPhotoDocuments"); arg_3DA_0 = readOnlyList; } else { arg_3DA_0 = fileOpenPickerContinuationEventArgs.Files; } IReadOnlyList <StorageFile> readOnlyList2 = arg_3DA_0; AttachmentType attachmentType; if (parameterForIdAndReset != null && Enum.TryParse <AttachmentType>(parameterForIdAndReset.ToString(), out attachmentType)) { using (IEnumerator <StorageFile> enumerator = readOnlyList2.GetEnumerator()) { while (enumerator.MoveNext()) { StorageFile current = enumerator.Current; if (attachmentType != AttachmentType.VideoFromPhone) { if (attachmentType == AttachmentType.DocumentFromPhone || attachmentType == AttachmentType.DocumentPhoto) { OutboundUploadDocumentAttachment attachment10 = new OutboundUploadDocumentAttachment(current); this.WallPostVM.AddAttachment(attachment10); this.WallPostVM.UploadAttachments(); } } else { long groupId = this.WallPostVM.FromGroup ? this.WallPostVM.UserOrGroupId : 0L; OutboundUploadVideoAttachment attachment11 = new OutboundUploadVideoAttachment(current, true, groupId); this.WallPostVM.AddAttachment(attachment11); this.WallPostVM.UploadAttachments(); } } } } } List <StorageFile> list3 = ParametersRepository.GetParameterForIdAndReset("ChosenDocuments") as List <StorageFile>; if (list3 != null) { IEnumerable <StorageFile> arg_4D4_0 = list3; Func <StorageFile, OutboundUploadDocumentAttachment> arg_4D4_1 = new Func <StorageFile, OutboundUploadDocumentAttachment>((chosenDocument) => new OutboundUploadDocumentAttachment(chosenDocument)); using (IEnumerator <OutboundUploadDocumentAttachment> enumerator2 = Enumerable.Select <StorageFile, OutboundUploadDocumentAttachment>(arg_4D4_0, arg_4D4_1).GetEnumerator()) { while (enumerator2.MoveNext()) { OutboundUploadDocumentAttachment current2 = enumerator2.Current; this.WallPostVM.AddAttachment(current2); } } this.WallPostVM.UploadAttachments(); } List <StorageFile> list4 = ParametersRepository.GetParameterForIdAndReset("ChosenVideos") as List <StorageFile>; if (list4 != null) { IEnumerable <StorageFile> arg_550_0 = list4; Func <StorageFile, OutboundUploadVideoAttachment> arg_550_1 = new Func <StorageFile, OutboundUploadVideoAttachment>((chosenDocument) => new OutboundUploadVideoAttachment(chosenDocument, true, 0L)); using (IEnumerator <OutboundUploadVideoAttachment> enumerator3 = Enumerable.Select <StorageFile, OutboundUploadVideoAttachment>(arg_550_0, arg_550_1).GetEnumerator()) { while (enumerator3.MoveNext()) { OutboundUploadVideoAttachment current3 = enumerator3.Current; this.WallPostVM.AddAttachment(current3); } } this.WallPostVM.UploadAttachments(); } return(false); }
public OutboundAttachmentContainer(IOutboundAttachment outboundAttachment) { this._outboundAttachment = outboundAttachment; if (outboundAttachment is OutboundPhotoAttachment) { this._photoAttachment = outboundAttachment as OutboundPhotoAttachment; } else if (outboundAttachment is OutboundGeoAttachment) { this._geoAttachment = outboundAttachment as OutboundGeoAttachment; } else if (outboundAttachment is OutboundVideoAttachment) { this._videoAttachment = outboundAttachment as OutboundVideoAttachment; } else if (outboundAttachment is OutboundAudioAttachment) { this._audioAttachment = outboundAttachment as OutboundAudioAttachment; } else if (outboundAttachment is OutboundDocumentAttachment) { this._documentAttachment = outboundAttachment as OutboundDocumentAttachment; } else if (outboundAttachment is OutboundUploadVideoAttachment) { this._uploadVideoAttachment = outboundAttachment as OutboundUploadVideoAttachment; } else if (outboundAttachment is OutboundWallPostAttachment) { this._wallPostAttachment = outboundAttachment as OutboundWallPostAttachment; } else if (outboundAttachment is OutboundForwardedMessages) { this._forwardedMessages = outboundAttachment as OutboundForwardedMessages; } else if (outboundAttachment is OutboundUploadDocumentAttachment) { this._uploadDocumentAttachment = outboundAttachment as OutboundUploadDocumentAttachment; } else if (outboundAttachment is OutboundPollAttachment) { this._pollAttachment = outboundAttachment as OutboundPollAttachment; } else if (outboundAttachment is OutboundTimerAttachment) { this._timerAttachment = outboundAttachment as OutboundTimerAttachment; } else if (outboundAttachment is OutboundLinkAttachment) { this._linkAttachment = outboundAttachment as OutboundLinkAttachment; } else if (outboundAttachment is OutboundProductAttachment) { this._productAttachment = outboundAttachment as OutboundProductAttachment; } else if (outboundAttachment is OutboundNoteAttachment) { this._noteAttachment = outboundAttachment as OutboundNoteAttachment; } else if (outboundAttachment is OutboundMarketAlbumAttachment) { this._marketAlbumAttachment = outboundAttachment as OutboundMarketAlbumAttachment; } else { if (!(outboundAttachment is OutboundAlbumAttachment)) { throw new Exception("Unknown attachment type"); } this._albumAttachment = outboundAttachment as OutboundAlbumAttachment; } }
public void Read(BinaryReader reader) { int num1 = reader.ReadInt32(); this._photoAttachment = reader.ReadGeneric <OutboundPhotoAttachment>(); if (this._photoAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._photoAttachment; } this._geoAttachment = reader.ReadGeneric <OutboundGeoAttachment>(); if (this._geoAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._geoAttachment; } this._videoAttachment = reader.ReadGeneric <OutboundVideoAttachment>(); if (this._videoAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._videoAttachment; } this._audioAttachment = reader.ReadGeneric <OutboundAudioAttachment>(); if (this._audioAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._audioAttachment; } this._documentAttachment = reader.ReadGeneric <OutboundDocumentAttachment>(); if (this._documentAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._documentAttachment; } int num2 = 2; if (num1 >= num2) { this._uploadVideoAttachment = reader.ReadGeneric <OutboundUploadVideoAttachment>(); if (this._uploadVideoAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._uploadVideoAttachment; } } int num3 = 3; if (num1 >= num3) { this._wallPostAttachment = reader.ReadGeneric <OutboundWallPostAttachment>(); if (this._wallPostAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._wallPostAttachment; } this._forwardedMessages = reader.ReadGeneric <OutboundForwardedMessages>(); if (this._forwardedMessages != null) { this._outboundAttachment = (IOutboundAttachment)this._forwardedMessages; } } int num4 = 4; if (num1 >= num4) { this._uploadDocumentAttachment = reader.ReadGeneric <OutboundUploadDocumentAttachment>(); if (this._uploadDocumentAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._uploadDocumentAttachment; } this._pollAttachment = reader.ReadGeneric <OutboundPollAttachment>(); if (this._pollAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._pollAttachment; } this._timerAttachment = reader.ReadGeneric <OutboundTimerAttachment>(); if (this._timerAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._timerAttachment; } } int num5 = 5; if (num1 >= num5) { this._linkAttachment = reader.ReadGeneric <OutboundLinkAttachment>(); if (this._linkAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._linkAttachment; } } int num6 = 6; if (num1 >= num6) { this._productAttachment = reader.ReadGeneric <OutboundProductAttachment>(); if (this._productAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._productAttachment; } } int num7 = 7; if (num1 >= num7) { this._noteAttachment = reader.ReadGeneric <OutboundNoteAttachment>(); if (this._noteAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._noteAttachment; } } int num8 = 8; if (num1 >= num8) { this._marketAlbumAttachment = reader.ReadGeneric <OutboundMarketAlbumAttachment>(); if (this._marketAlbumAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._marketAlbumAttachment; } this._albumAttachment = reader.ReadGeneric <OutboundAlbumAttachment>(); if (this._albumAttachment != null) { this._outboundAttachment = (IOutboundAttachment)this._albumAttachment; } } if (this._outboundAttachment == null) { throw new Exception("Outbound Attachment is NULL"); } }
internal void RemoveAttachment(IOutboundAttachment outboundAttCont) { outboundAttCont.RemoveAndCancelUpload(); this.Attachments.Remove(outboundAttCont); }
private void StartSendingByAttachmentInd(int attachmentInd, Guid jobId) { if (jobId != this._uploadJobId) { return; } if ((attachmentInd >= this.Attachments.Count || this.StickerItem != null) && this.GraffitiAttachmentItem == null) { this.DoSend(); } else if (this.GraffitiAttachmentItem != null) { double previousProgress = 0.0; this.GraffitiAttachmentItem.Upload((Action)(() => { if (!(jobId == this._uploadJobId)) { return; } if (!this.GraffitiAttachmentItem.IsUploaded) { // ISSUE: reference to a compiler-generated field EventHandler uploadFinished = this.UploadFinished; if (uploadFinished != null) { EventArgs empty = EventArgs.Empty; uploadFinished((object)this, empty); } this.OutboundMessageStatus = OutboundMessageStatus.Failed; } else { this.DoSend(); } }), (Action <double>)(progress => { this.UploadProgressHandler(progress - previousProgress); previousProgress = progress; })); } else { IOutboundAttachment currentAttachment = this.Attachments[attachmentInd]; if (currentAttachment.IsUploadAttachment) { double previousProgress = 0.0; currentAttachment.Upload((Action)(() => { if (!(jobId == this._uploadJobId)) { return; } if (currentAttachment.UploadState != OutboundAttachmentUploadState.Completed) { // ISSUE: reference to a compiler-generated field if (this.UploadFinished != null) { // ISSUE: reference to a compiler-generated field this.UploadFinished((object)this, EventArgs.Empty); } this.OutboundMessageStatus = OutboundMessageStatus.Failed; } else { this.StartSendingByAttachmentInd(attachmentInd + 1, jobId); } }), (Action <double>)(progress => { this.UploadProgressHandler(progress - previousProgress); previousProgress = progress; })); } else { this.StartSendingByAttachmentInd(attachmentInd + 1, jobId); } } }