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 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 void InitializeCommentVM() { this._commentVM = WallPostViewModel.CreateNewDiscussionCommentVM(); this._commentVM.PropertyChanged += new PropertyChangedEventHandler(this._commentVM_PropertyChanged); ((FrameworkElement)this.newCommentUC).DataContext = ((object)this._commentVM); }
private void InitializeCommentVM() { this._commentVM = WallPostViewModel.CreateNewPhotoCommentVM(this._ownerId, this._pid); this._commentVM.PropertyChanged += new PropertyChangedEventHandler(this._commentVM_PropertyChanged); ((FrameworkElement)this.ucNewMessage).DataContext = this._commentVM; }
protected override void HandleOnNavigatedTo(NavigationEventArgs e) { base.HandleOnNavigatedTo(e); this._fromPhotoPicker = false; this._isForwardNav = e.NavigationMode == 0; if (ParametersRepository.Contains("FromPhotoPicker")) { this._fromPhotoPicker = (bool)ParametersRepository.GetParameterForIdAndReset("FromPhotoPicker"); } if (!this._isInitialized) { this._adminLevel = int.Parse(((Page)this).NavigationContext.QueryString["AdminLevel"]); bool isPublicPage = ((Page)this).NavigationContext.QueryString["IsPublicPage"] == bool.TrueString; bool isNewTopicMode = ((Page)this).NavigationContext.QueryString["IsNewTopicMode"] == bool.TrueString; this._isFromWallPostPage = ((Page)this).NavigationContext.QueryString["FromWallPostPage"] == bool.TrueString; WallPostViewModel.Mode mode; // ISSUE: explicit reference operation // ISSUE: cast to a reference type Enum.TryParse <WallPostViewModel.Mode>(((Page)this).NavigationContext.QueryString["Mode"], out mode); WallPost parameterForIdAndReset1 = ParametersRepository.GetParameterForIdAndReset("PublishWallPost") as WallPost; WallPost parameterForIdAndReset2 = ParametersRepository.GetParameterForIdAndReset("EditWallPost") as WallPost; Comment parameterForIdAndReset3 = ParametersRepository.GetParameterForIdAndReset("EditWallComment") as Comment; Comment parameterForIdAndReset4 = ParametersRepository.GetParameterForIdAndReset("EditPhotoComment") as Comment; Comment parameterForIdAndReset5 = ParametersRepository.GetParameterForIdAndReset("EditVideoComment") as Comment; Comment parameterForIdAndReset6 = ParametersRepository.GetParameterForIdAndReset("EditProductComment") as Comment; Comment parameterForIdAndReset7 = ParametersRepository.GetParameterForIdAndReset("EditDiscussionComment") as Comment; Dictionary <long, long> parameterForIdAndReset8 = ParametersRepository.GetParameterForIdAndReset("CidToAuthorIdDict") as Dictionary <long, long>; WallRepostInfo parameterForIdAndReset9 = ParametersRepository.GetParameterForIdAndReset("WallRepostInfo") as WallRepostInfo; WallPostViewModel parameterForIdAndReset10 = ParametersRepository.GetParameterForIdAndReset("NewCommentVM") as WallPostViewModel; this._shareContentDataProvider = ShareContentDataProviderManager.RetrieveDataProvider(); if (this._shareContentDataProvider is ShareExternalContentDataProvider) { ((Page)this).NavigationService.ClearBackStack(); this.ucHeader.HideSandwitchButton = true; this.SuppressMenu = true; } WallPostViewModel vm; if (parameterForIdAndReset1 != null) { vm = new WallPostViewModel(parameterForIdAndReset1, this._adminLevel, null) { WMMode = WallPostViewModel.Mode.PublishWallPost } } ; else if (parameterForIdAndReset2 != null) { vm = new WallPostViewModel(parameterForIdAndReset2, this._adminLevel, parameterForIdAndReset9) { WMMode = WallPostViewModel.Mode.EditWallPost }; if (vm.WallRepostInfo != null) { RepostHeaderUC repostHeaderUc1 = new RepostHeaderUC(); Thickness thickness = new Thickness(0.0, 14.0, 0.0, 14.0); ((FrameworkElement)repostHeaderUc1).Margin = thickness; RepostHeaderUC repostHeaderUc2 = repostHeaderUc1; repostHeaderUc2.Configure(vm.WallRepostInfo, null); this.wallRepostContainer.Child = ((UIElement)repostHeaderUc2); } } else { vm = parameterForIdAndReset3 == null ? (parameterForIdAndReset4 == null ? (parameterForIdAndReset5 == null ? (parameterForIdAndReset6 == null ? (parameterForIdAndReset7 == null ? (parameterForIdAndReset10 == null ? new WallPostViewModel(this.CommonParameters.UserOrGroupId, this.CommonParameters.IsGroup, this._adminLevel, isPublicPage, isNewTopicMode) : parameterForIdAndReset10) : WallPostViewModel.CreateEditDiscussionCommentVM(parameterForIdAndReset7, parameterForIdAndReset8)) : WallPostViewModel.CreateEditProductCommentVM(parameterForIdAndReset6)) : WallPostViewModel.CreateEditVideoCommentVM(parameterForIdAndReset5)) : WallPostViewModel.CreateEditPhotoCommentVM(parameterForIdAndReset4)) : WallPostViewModel.CreateEditWallCommentVM(parameterForIdAndReset3); } vm.IsOnPostPage = true; vm.WMMode = mode; if (!this._fromPhotoPicker && (!e.IsNavigationInitiator || e.NavigationMode != NavigationMode.New || (mode == WallPostViewModel.Mode.NewTopic || mode == WallPostViewModel.Mode.NewWallPost))) { WallPostVMCacheManager.TryDeserializeVM(vm); } vm.PropertyChanged += new PropertyChangedEventHandler(this.vm_PropertyChanged); base.DataContext = vm; this._isInitialized = true; } if (this.HandleInputParams(e)) { return; } this.UpdateViewState(); ListExtensions.ForEach <IOutboundAttachment>(this.WallPostVM.OutboundAttachments, (Action <IOutboundAttachment>)(a => a.SetRetryFlag())); if (!e.IsNavigationInitiator || e.NavigationMode != NavigationMode.New) { return; } if (this.WallPostVM.IsInNewWallPostMode || this.WallPostVM.EditWallRepost) { this.FocusTextBox(); } else { if (!this.WallPostVM.IsInNewTopicMode) { return; } this.FocusTitleTextBox(); } }
public static void RegisterForDelayedSerialization(WallPostViewModel vm) { WallPostVMCacheManager._instance = vm; }
public static void TryDeserializeInstance(WallPostViewModel vm) { CacheManager.TryDeserialize((IBinarySerializable)vm, WallPostVMCacheManager._wallPostKey, CacheManager.DataType.CachedData); }
public static void ResetInstance() { WallPostVMCacheManager._instance = (WallPostViewModel)null; CacheManager.TryDelete(WallPostVMCacheManager._wallPostKey, CacheManager.DataType.CachedData); }
public static void ResetVM(WallPostViewModel vm) { CacheManager.TryDelete(WallPostVMCacheManager.GetKey(vm), CacheManager.DataType.CachedData); }
private static string GetKey(WallPostViewModel vm) { return("WallPost_" + (object)AppGlobalStateManager.Current.GlobalState.LoggedInUserId + "_" + vm.UniqueId); }
public static void TryDeserializeVM(WallPostViewModel vm) { string key = WallPostVMCacheManager.GetKey(vm); CacheManager.TryDeserialize((IBinarySerializable)vm, key, CacheManager.DataType.CachedData); }
private void InitializeCommentVM() { this._commentVM = WallPostViewModel.CreateNewProductCommentVM(this._ownerId, this._productId); this._commentVM.PropertyChanged += new PropertyChangedEventHandler(this.CommentsVM_OnPropertyChanged); this.ucNewMessage.DataContext = (object)this._commentVM; }
public static void HandleInputParams(WallPostViewModel wallPostVM) { GeoCoordinate parameterForIdAndReset1 = ParametersRepository.GetParameterForIdAndReset("NewPositionToBeAttached") as GeoCoordinate; if (parameterForIdAndReset1 != null) { OutboundGeoAttachment outboundGeoAttachment = new OutboundGeoAttachment(parameterForIdAndReset1.Latitude, parameterForIdAndReset1.Longitude); wallPostVM.AddAttachment((IOutboundAttachment)outboundGeoAttachment); } List <Stream> parameterForIdAndReset2 = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotos") as List <Stream>; List <Stream> parameterForIdAndReset3 = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotosPreviews") as List <Stream>; if (parameterForIdAndReset2 != null) { for (int index = 0; index < parameterForIdAndReset2.Count; ++index) { Stream stream1 = parameterForIdAndReset2[index]; Stream stream2 = parameterForIdAndReset3[index]; long userOrGroupId = wallPostVM.UserOrGroupId; int num1 = wallPostVM.IsGroup ? 1 : 0; Stream previewStream = stream2; int num2 = 0; OutboundPhotoAttachment forUploadNewPhoto = OutboundPhotoAttachment.CreateForUploadNewPhoto(stream1, userOrGroupId, num1 != 0, previewStream, (PostType)num2); wallPostVM.AddAttachment((IOutboundAttachment)forUploadNewPhoto); } wallPostVM.UploadAttachments(); } Photo parameterForIdAndReset4 = ParametersRepository.GetParameterForIdAndReset("PickedPhoto") as Photo; if (parameterForIdAndReset4 != null) { OutboundPhotoAttachment choosingExistingPhoto = OutboundPhotoAttachment.CreateForChoosingExistingPhoto(parameterForIdAndReset4, wallPostVM.UserOrGroupId, wallPostVM.IsGroup, PostType.WallPost); wallPostVM.AddAttachment((IOutboundAttachment)choosingExistingPhoto); } VKClient.Common.Backend.DataObjects.Video parameterForIdAndReset5 = ParametersRepository.GetParameterForIdAndReset("PickedVideo") as VKClient.Common.Backend.DataObjects.Video; if (parameterForIdAndReset5 != null) { OutboundVideoAttachment outboundVideoAttachment = new OutboundVideoAttachment(parameterForIdAndReset5); wallPostVM.AddAttachment((IOutboundAttachment)outboundVideoAttachment); } AudioObj parameterForIdAndReset6 = ParametersRepository.GetParameterForIdAndReset("PickedAudio") as AudioObj; if (parameterForIdAndReset6 != null) { OutboundAudioAttachment outboundAudioAttachment = new OutboundAudioAttachment(parameterForIdAndReset6); wallPostVM.AddAttachment((IOutboundAttachment)outboundAudioAttachment); } Doc parameterForIdAndReset7 = ParametersRepository.GetParameterForIdAndReset("PickedDocument") as Doc; if (parameterForIdAndReset7 != null) { OutboundDocumentAttachment documentAttachment = new OutboundDocumentAttachment(parameterForIdAndReset7); wallPostVM.AddAttachment((IOutboundAttachment)documentAttachment); } FileOpenPickerContinuationEventArgs parameterForIdAndReset8 = ParametersRepository.GetParameterForIdAndReset("FilePicked") as FileOpenPickerContinuationEventArgs; if ((parameterForIdAndReset8 == null || !Enumerable.Any <StorageFile>(parameterForIdAndReset8.Files)) && !ParametersRepository.Contains("PickedPhotoDocuments")) { return; } object parameterForIdAndReset9 = ParametersRepository.GetParameterForIdAndReset("FilePickedType"); IReadOnlyList <StorageFile> storageFileList = parameterForIdAndReset8 != null ? parameterForIdAndReset8.Files : (IReadOnlyList <StorageFile>)ParametersRepository.GetParameterForIdAndReset("PickedPhotoDocuments"); AttachmentType attachmentType; // ISSUE: explicit reference operation // ISSUE: cast to a reference type if (parameterForIdAndReset9 == null || !Enum.TryParse <AttachmentType>((parameterForIdAndReset9).ToString(), out attachmentType)) { return; } IEnumerator <StorageFile> enumerator = ((IEnumerable <StorageFile>)storageFileList).GetEnumerator(); try { while (enumerator.MoveNext()) { StorageFile current = enumerator.Current; if (attachmentType != AttachmentType.VideoFromPhone) { if (attachmentType == AttachmentType.DocumentFromPhone || attachmentType == AttachmentType.DocumentPhoto) { OutboundUploadDocumentAttachment documentAttachment = new OutboundUploadDocumentAttachment(current); wallPostVM.AddAttachment((IOutboundAttachment)documentAttachment); wallPostVM.UploadAttachments(); } } else { OutboundUploadVideoAttachment uploadVideoAttachment = new OutboundUploadVideoAttachment(current, true, 0L); wallPostVM.AddAttachment((IOutboundAttachment)uploadVideoAttachment); wallPostVM.UploadAttachments(); } } } finally { if (enumerator != null) { enumerator.Dispose(); } } }