public async Task ClearCache(IEnumerable <string> idsForRemoving = null) { if (this._cacheChanging) { return; } this._cacheChanging = true; foreach (KeyValuePair <string, string> keyValuePair in new Dictionary <string, string>((IDictionary <string, string>) this._downloadedDict)) { KeyValuePair <string, string> kvp = keyValuePair; if (idsForRemoving == null || idsForRemoving.Contains <string>(kvp.Key)) { if (await CacheManager.TryDeleteAsync(kvp.Value)) { this._downloadedDict.Remove(kvp.Key); AudioObj audioObj = this._downloadedList.FirstOrDefault <AudioObj>((Func <AudioObj, bool>)(a => a.UniqueId == kvp.Key)); if (audioObj != null) { this._downloadedList.Remove(audioObj); } } } } //Dictionary<string, string>.Enumerator enumerator = new Dictionary<string, string>.Enumerator(); this._cacheChanging = false; }
public void Handle(AudioTrackEdited message) { AudioObj fromBackgroundAudio = this.GetCurrentTrackFromBackgroundAudio(); if (fromBackgroundAudio != null && message.OwnerId == fromBackgroundAudio.owner_id && message.Id == fromBackgroundAudio.id) { fromBackgroundAudio.artist = message.Artist; fromBackgroundAudio.title = message.Title; } AudioTrack track = BGAudioPlayerWrapper.Instance.Track; long? nullable1 = track != null ? new long?(track.GetTagOwnerId()) : new long?(); string str = track != null?track.GetTagId() : null; if (str != null && ((IEnumerable <char>)str).Contains <char>('_')) { str = str.Substring(str.IndexOf('_') + 1); } if (track != null) { long?nullable2 = nullable1; long valueOrDefault = nullable2.GetValueOrDefault(); if ((message.OwnerId == valueOrDefault ? (nullable2.HasValue ? 1 : 0) : 0) != 0 && message.Id.ToString() == str) { track.BeginEdit(); track.Artist = message.Artist; track.Title = message.Title; track.EndEdit(); } } this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.ArtistName)); this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.TrackName)); this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.CurrentTrackStr)); }
public static void createAndPlay(string name, Vector3 pos, float volume = 1, bool loop = false) { Sound sound = findSound(name); if (sound == null) { Debug.Log("can't find audio"); } AudioObj audioObj = AudioObj.createFromPool(); if (audioObj == null) { Debug.Log("no more audioObj"); return; } audioObj.transform.position = pos; AudioSource audioSrc = audioObj.transform.GetComponent <AudioSource>(); audioSrc.clip = sound.clip; audioSrc.loop = loop; audioSrc.volume = volume; audioSrc.Play(); }
private void OnTrackChanged() { Execute.ExecuteOnUIThread((Action)(() => { this.PreventPositionUpdates = true; this._current = this.GetCurrentTrackFromBackgroundAudio(); this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.TrackName)); this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.ArtistName)); this.NotifyPropertyChanged <double>((Expression <Func <double> >)(() => this.RemainingSeconds)); this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.RemainingStr)); this.NotifyPropertyChanged <double>((Expression <Func <double> >)(() => this.PositionSeconds)); this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.PositionStr)); this.NotifyPropertyChanged <bool>((Expression <Func <bool> >)(() => this.CanAddTrack)); this.NotifyPropertyChanged <Visibility>((Expression <Func <Visibility> >)(() => this.CanAddVisibility)); this.NotifyPropertyChanged <Visibility>((Expression <Func <Visibility> >)(() => this.AddedVisibility)); this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.Artwork)); this.NotifyPropertyChanged <Visibility>((Expression <Func <Visibility> >)(() => this.HaveLyricsVisibility)); this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.CurrentTrackStr)); this.NotifyPropertyChanged <Visibility>((Expression <Func <Visibility> >)(() => this.CurrentTrackVisibility)); this.NotifyPropertyChanged <double>((Expression <Func <double> >)(() => this.MiniPlayerProgressWidth)); this.FetchArtwork(); this.PreventPositionUpdates = false; //this.UpdateNextTrackInfo(); this._current = null; })); }
void clearDeath() { for (int i = 0; i < SCENE_OBJ.ALL.Count; i++) { SCENE_OBJ obj = SCENE_OBJ.ALL[i]; if (obj.canDestroy) { obj.pool.delete(obj); } } for (int i = 0; i < AudioObj.globalAudio.Count; i++) { AudioObj obj = AudioObj.globalAudio[i]; if (!obj.audioSrc.isPlaying) { obj.deleteFromScene(); } } if (Explode.pool.live != null) { for (int i = 0; i < Explode.pool.live.Count; i++) { Explode obj = Explode.pool.live[i]; if (!obj.src.isPlaying) { obj.deleteFormScene(); } } } }
public static void initSound() { Transform helicopterAudio = GameObject.Find("helicopterAudio").transform; audioObj = AudioObj.createFromPool(helicopterAudio); audioObj.attachSound(Sound.findSound("helicopter")); }
private void Play(GestureEventArgs e) { this.SetPlayPauseVisibilityManually(false); Logger.Instance.Info("AudioAttachmentUC.play_Tap, AssignedCurrentTrack = " + this.AssignedCurrentTrack.ToString()); this.NotifyPlaying(); if (!this.AssignedCurrentTrack) { AttachmentViewModel dc = this.DataContext as AttachmentViewModel; if (dc != null) { AudioTrack track = AudioTrackHelper.CreateTrack(this.AttachmentVM.Audio); Logger.Instance.Info("Starting track for uri: {0}", dc.ResourceUri); BGAudioPlayerWrapper.Instance.Track = track; if (!this._initializedUri) { Logger.Instance.Info("AudioAttachmentUC initializedUri = false, getting updated audio info"); AudioService instance = AudioService.Instance; List <string> ids = new List <string>(); ids.Add(dc.MediaOwnerId.ToString() + "_" + dc.MediaId); Action <BackendResult <List <AudioObj>, ResultCode> > callback = (Action <BackendResult <List <AudioObj>, ResultCode> >)(res => { if (res.ResultCode != ResultCode.Succeeded) { return; } this._initializedUri = true; AudioObj audio = res.ResultData.FirstOrDefault <AudioObj>(); if (audio == null) { return; } if (audio.url != dc.ResourceUri) { return; } Logger.Instance.Info("Received different uri for audio: {0}", audio.url); dc.ResourceUri = audio.url; dc.Audio = audio; this.Dispatcher.BeginInvoke(delegate { if (!this.AssignedCurrentTrack && BGAudioPlayerWrapper.Instance.Track != null || (BGAudioPlayerWrapper.Instance.PlayerState == PlayState.Paused || AudioTrackHelper.GetPositionSafe().TotalMilliseconds >= 1E-05)) { return; } BGAudioPlayerWrapper.Instance.Track = AudioTrackHelper.CreateTrack(audio); this.Play(); }); }); instance.GetAudio(ids, callback); } } } this.Play(); }
public AudioMediaListItemViewModel(AudioObj audio, List <AudioObj> audios) : base(ProfileMediaListItemType.Audio) { this._audio = audio; this._audios = audios; this._audioViewModel = new AttachmentViewModel(new Attachment { type = "audio", audio = audio } /*, null*/); }
private void TrackAction(AudioPageViewModel.Audios.AudioData2 item) { if (BGAudioPlayerWrapper.Instance.Track != null && item.UniqueId == BGAudioPlayerWrapper.Instance.Track.Tag) { BGAudioPlayerWrapper.Instance.Pause(); } else { AudioObj a = new AudioObj(); a.duration = item.duration.ToString(); a.artist = item.artist; a.title = item.title; a.url = item.url; a.id = item.id; a.owner_id = item.owner_id; BGAudioPlayerWrapper.Instance.Track = AudioTrackHelper.CreateTrack(a); BGAudioPlayerWrapper.Instance.Play(); //todo:плейлист формировать из того списка, который открыт // List <AudioObj> tracks = new List <AudioObj>(); foreach (AudioPageViewModel.Audios.AudioData2 adata in (base.DataContext as AudioPageViewModel).audios.items) { AudioObj o = new AudioObj(); //AudioHeader ah = new AudioHeader(o); o.artist = adata.artist; o.duration = adata.duration.ToString(); o.id = adata.id; o.owner_id = adata.owner_id; o.title = adata.title; o.url = adata.url; tracks.Add(o); } PlaylistManager.SetAudioAgentPlaylist(tracks, CurrentMediaSource.AudioSource); AudioHeader track = new AudioHeader(a); if (!track.TryAssignTrack()) { return; } //if (need_navigate) // Navigator.Current.NavigateToAudioPlayer(true); //else // BGAudioPlayerWrapper.Instance.Play(); // } }
public static AudioObj GetNextAudio(BackgroundAudioPlayer player, bool next, out bool startedNewCycle, PlaybackSettings settings = null, bool allowCache = false) { startedNewCycle = false; Playlist playlist = PlaylistManager.LoadTracksFromIsolatedStorage(allowCache); List <AudioObj> tracks = playlist.Tracks; if (tracks.Count == 1) { startedNewCycle = true; } if (settings == null) { settings = PlaylistManager.ReadPlaybackSettings(allowCache); } tracks.FirstOrDefault <AudioObj>(); int num1 = 0; AudioTrack track = player.Track; if (track != null) { AudioObj audioObj = tracks.FirstOrDefault <AudioObj>((Func <AudioObj, bool>)(t => t.UniqueId == track.GetTagId())); num1 = tracks.IndexOf(audioObj); if (settings.Shuffle) { num1 = playlist.ShuffledIndexes.IndexOf(num1); } } int num2 = num1; int index = !next ? num2 - 1 : num2 + 1; if (index < 0) { startedNewCycle = true; index = tracks.Count <AudioObj>() - 1; } if (index >= tracks.Count) { startedNewCycle = true; index = 0; } if (tracks.Count <= 0 || index >= tracks.Count) { return(null); } if (settings.Shuffle) { index = playlist.ShuffledIndexes[index]; } return(tracks[index]); }
public AddEditAudioViewModel(StorageFile audioForUpload, AudioObj audioForEdit) { this._storageFile = audioForUpload; this._audioForEdit = audioForEdit; if (this._audioForEdit == null) { this.PageTitle = CommonResources.AudioAdding; } else { this.PageTitle = CommonResources.AudioEditing; this.Artist = Extensions.ForUI(audioForEdit.artist); this.Title = Extensions.ForUI(audioForEdit.title); } }
public static AudioTrack CreateTrack(AudioObj audio) { if (audio == null) { return(null); } string uriString = string.IsNullOrEmpty(audio.url) ? "https://vk.com/404.mp3" : audio.url; string localFileForUniqueId = AudioCacheManager.Instance.GetLocalFileForUniqueId(audio.UniqueId); if (localFileForUniqueId != null) { uriString = CacheManager.GetFilePath(localFileForUniqueId, CacheManager.DataType.CachedData, "/"); } return(new AudioTrack(new Uri(uriString, UriKind.RelativeOrAbsolute), audio.title ?? "NOTITLE", audio.artist ?? "NOARTIST", "", null, audio.UniqueId + "|" + audio.duration, (EnabledPlayerControls)31L)); }
public void AddTrack() { if (this._addingTrack) { return; } this._addingTrack = true; this.NotifyPropertyChanged <double>((Expression <Func <double> >)(() => this.CanAddOpacity)); try { List <AudioObj> tracks = PlaylistManager.LoadTracksFromIsolatedStorage(true).Tracks; AudioTrack bTrack = BGAudioPlayerWrapper.Instance.Track; if (bTrack == null) { return; } AudioObj current = tracks.FirstOrDefault <AudioObj>((Func <AudioObj, bool>)(t => t.UniqueId == bTrack.GetTagId())); this.SetInProgress(true, ""); AudioService.Instance.AddAudio(current.owner_id, current.aid, (Action <BackendResult <long, ResultCode> >)(res => { this.SetInProgress(false, ""); this._addingTrack = false; this.NotifyPropertyChanged <double>((Expression <Func <double> >)(() => this.CanAddOpacity)); if (res.ResultCode != ResultCode.Succeeded) { return; } AudioPlayerViewModel._addedTracks.Add(current.UniqueId); AudioObj audioObj = StreamUtils.CloneThroughSerialize <AudioObj>(current); audioObj.owner_id = AppGlobalStateManager.Current.LoggedInUserId; audioObj.aid = res.ResultData; this.NotifyPropertyChanged <bool>((Expression <Func <bool> >)(() => this.CanAddTrack)); this.NotifyPropertyChanged <Visibility>((Expression <Func <Visibility> >)(() => this.AddedVisibility)); this.NotifyPropertyChanged <Visibility>((Expression <Func <Visibility> >)(() => this.CanAddVisibility)); EventAggregator.Current.Publish((object)new AudioTrackAddedRemoved() { Added = true, Audio = audioObj }); })); } catch (Exception ex) { Logger.Instance.Error("Failed to add track", ex); } }
public static void initAudioObjIntoPool(int num) { GameObject[] prefabs = new GameObject[num]; for (int i = 0; i < num; i++) { prefabs[i] = Instantiate(Resources.Load("Game/prefab/audio"), Vector3.zero, Quaternion.identity) as GameObject; prefabs[i].transform.parent = Stage.offStage; } AudioObj[] audioObjs = new AudioObj[num]; for (int i = 0; i < audioObjs.Length; i++) { audioObjs[i] = new AudioObj(); audioObjs[i].init(prefabs[i].transform, false); } AudioObj.pool.init(audioObjs, "AudioObj"); }
private void ProcessFullyDownloadedFile(InProgressDownloadInfo currentDownload) { List <string> ids = new List <string>(); ids.Add(currentDownload.RemoteFile.UniqueId); Action <BackendResult <List <AudioObj>, ResultCode> > callback = (Action <BackendResult <List <AudioObj>, ResultCode> >)(res => { if (res.ResultCode != ResultCode.Succeeded) { return; } this._downloadedDict[currentDownload.RemoteFile.UniqueId] = currentDownload.LocalFileId; AudioObj audioObj = res.ResultData[0]; audioObj.url = currentDownload.LocalFileId; this._downloadedList.Add(audioObj); }); AudioService.Instance.GetAudio(ids, callback); }
public static AudioObj createFromPool(Transform hangToSceneObj = null) { AudioObj audioObj = pool.create(); if (audioObj == null) { return(null); } if (hangToSceneObj == null) { audioObj.transform.parent = Stage.audios; audioObj.addToScene(); } else { audioObj.transform.position = hangToSceneObj.position; audioObj.transform.parent = hangToSceneObj; } return(audioObj); }
public OutboundAudioAttachment(AudioObj audio) { this._audio = audio; }
private void ProcessInputData() { Photo parameterForIdAndReset1 = ParametersRepository.GetParameterForIdAndReset("PickedPhoto") as Photo; if (parameterForIdAndReset1 != null) { this._commentVM.AddAttachment((IOutboundAttachment)OutboundPhotoAttachment.CreateForChoosingExistingPhoto(parameterForIdAndReset1, 0, false, PostType.WallPost)); } VKClient.Common.Backend.DataObjects.Video parameterForIdAndReset2 = ParametersRepository.GetParameterForIdAndReset("PickedVideo") as VKClient.Common.Backend.DataObjects.Video; if (parameterForIdAndReset2 != null) { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundVideoAttachment(parameterForIdAndReset2)); } AudioObj parameterForIdAndReset3 = ParametersRepository.GetParameterForIdAndReset("PickedAudio") as AudioObj; if (parameterForIdAndReset3 != null) { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundAudioAttachment(parameterForIdAndReset3)); } Doc parameterForIdAndReset4 = ParametersRepository.GetParameterForIdAndReset("PickedDocument") as Doc; if (parameterForIdAndReset4 != null) { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundDocumentAttachment(parameterForIdAndReset4)); } List <Stream> parameterForIdAndReset5 = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotos") as List <Stream>; List <Stream> parameterForIdAndReset6 = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotosPreviews") as List <Stream>; if (parameterForIdAndReset5 != null) { for (int index = 0; index < parameterForIdAndReset5.Count; ++index) { Stream stream1 = parameterForIdAndReset5[index]; Stream stream2 = parameterForIdAndReset6[index]; long userOrGroupId = 0; int num1 = 0; Stream previewStream = stream2; int num2 = 0; this._commentVM.AddAttachment((IOutboundAttachment)OutboundPhotoAttachment.CreateForUploadNewPhoto(stream1, userOrGroupId, num1 != 0, previewStream, (PostType)num2)); } this.GroupDiscussionVM.SetInProgress(true, CommonResources.WallPost_UploadingAttachments); this._commentVM.UploadAttachments(); } FileOpenPickerContinuationEventArgs parameterForIdAndReset7 = ParametersRepository.GetParameterForIdAndReset("FilePicked") as FileOpenPickerContinuationEventArgs; if ((parameterForIdAndReset7 == null || !parameterForIdAndReset7.Files.Any <StorageFile>()) && !ParametersRepository.Contains("PickedPhotoDocuments")) { return; } object parameterForIdAndReset8 = ParametersRepository.GetParameterForIdAndReset("FilePickedType"); IReadOnlyList <StorageFile> storageFileList = parameterForIdAndReset7 != null ? parameterForIdAndReset7.Files : (IReadOnlyList <StorageFile>)ParametersRepository.GetParameterForIdAndReset("PickedPhotoDocuments"); AttachmentType result; if (parameterForIdAndReset8 == null || !Enum.TryParse <AttachmentType>(parameterForIdAndReset8.ToString(), out result)) { return; } foreach (StorageFile file in (IEnumerable <StorageFile>)storageFileList) { if (result != AttachmentType.VideoFromPhone) { if (result == AttachmentType.DocumentFromPhone || result == AttachmentType.DocumentPhoto) { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundUploadDocumentAttachment(file)); this._commentVM.UploadAttachments(); } } else { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundUploadVideoAttachment(file, true, 0L)); this._commentVM.UploadAttachments(); } } }
private List <MediaListSectionViewModel> CreateMediaItems() { List <MediaListSectionViewModel> sectionViewModelList = new List <MediaListSectionViewModel>(); if (this._profileData == null) { return(sectionViewModelList); } Counters counters = this._profileData.counters; Photo lastPhoto = this._profileData.lastPhoto; if ((this._mainSectionType != ProfileMainSectionType.Photos || this._profileData.photos == null || this._profileData.photos.items.Count == 0) && lastPhoto != null) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Photos, counters.photos, (MediaListItemViewModelBase) new PhotoAlbumMediaListItemViewModel(lastPhoto), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.photos); Navigator.Current.NavigateToPhotoAlbums(false, this._profileData.Id, this._isGroup, this._profileData.AdminLevel); }))); } else if (this._isGroup && this._profileData.CanAddPhotos && counters.photos == 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Photos, 0, (MediaListItemViewModelBase) new EmptyDataMediaListItemViewModel("/Resources/Profile/Placeholders/ProfilePlaceholderPhotos.png"), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.photos); Navigator.Current.NavigateToPhotoAlbums(false, this._profileData.Id, this._isGroup, this._profileData.AdminLevel); }))); } List <Topic> topics = this._profileData.topics; GroupData groupData = this._profileData as GroupData; if ((groupData != null ? groupData.group : (Group)null) != null) { Group group = groupData.group; if (this._mainSectionType != ProfileMainSectionType.Discussions && !topics.IsNullOrEmpty()) { Topic topic = topics.First <Topic>(); sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Discussions, counters.topics, (MediaListItemViewModelBase) new GenericMediaListItemViewModel(topic.ToString(), topic.title, UIStringFormatterHelper.FormatNumberOfSomething(topic.comments, CommonResources.OneMessageFrm, CommonResources.TwoFourMessagesFrm, CommonResources.FiveMessagesFrm, true, null, false), "/Resources/Profile/ProfileTopic.png"), (Action)(() => Navigator.Current.NavigateToGroupDiscussions(group.id, "", group.admin_level, false, group.CanCreateTopic)))); } else if (this._profileData.CanAddTopics && counters.topics == 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Discussions, 0, (MediaListItemViewModelBase) new EmptyDataMediaListItemViewModel("/Resources/Profile/Placeholders/ProfilePlaceholderTopics.png"), (Action)(() => Navigator.Current.NavigateToGroupDiscussions(group.id, "", group.admin_level, false, group.CanCreateTopic)))); } } List <VKClient.Common.Backend.DataObjects.Video> videos = this._profileData.videos; if (this._mainSectionType != ProfileMainSectionType.Videos && !videos.IsNullOrEmpty()) { VKClient.Common.Backend.DataObjects.Video video = videos.First <VKClient.Common.Backend.DataObjects.Video>(); sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Videos, counters.videos, (MediaListItemViewModelBase) new VideoAlbumMediaListItemViewModel(video), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.videos); Navigator.Current.NavigateToVideo(false, this._profileData.Id, this._isGroup, this._profileData.AdminLevel > 1); }))); } else if (this._isGroup && this._profileData.CanAddVideos && counters.videos == 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Videos, counters.topics, (MediaListItemViewModelBase) new EmptyDataMediaListItemViewModel("/Resources/Profile/Placeholders/ProfilePlaceholderVideos.png"), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.videos); Navigator.Current.NavigateToVideo(false, this._profileData.Id, this._isGroup, this._profileData.AdminLevel > 1); }))); } List <Product> products = this._profileData.products; if (this._mainSectionType != ProfileMainSectionType.Market && !products.IsNullOrEmpty()) { Product product = products.First <Product>(); sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Products, counters.market, (MediaListItemViewModelBase) new ProductsAlbumMediaListItemViewModel(product), (Action)(() => {}))); } else if (this._isGroup && this._profileData.CanAddProducts && counters.market == 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Videos, counters.topics, (MediaListItemViewModelBase) new EmptyDataMediaListItemViewModel("/Resources/Profile/Placeholders/ProfilePlaceholderVideos.png"), (Action)(() => {}))); } List <AudioObj> audios = this._profileData.audios; if (this._mainSectionType != ProfileMainSectionType.Audios && !audios.IsNullOrEmpty()) { AudioObj audioObj = audios.First <AudioObj>(); sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Audios, counters.audios, (MediaListItemViewModelBase) new GenericMediaListItemViewModel(audioObj.ToString(), audioObj.title, audioObj.artist, "/Resources/Profile/ProfileMusic.png"), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.audios); Navigator.Current.NavigateToAudio(0, this._profileData.Id, this._isGroup, 0L, 0L, ""); }))); } else if (this._isGroup && this._profileData.CanAddAudios && counters.audios == 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Audios, 0, (MediaListItemViewModelBase) new EmptyDataMediaListItemViewModel("/Resources/Profile/Placeholders/ProfilePlaceholderAudios.png"), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.audios); Navigator.Current.NavigateToAudio(0, this._profileData.Id, this._isGroup, 0L, 0L, ""); }))); } VKList <SubscriptionObj> subscriptions = this._profileData.subscriptions; int titleCounter = counters.pages + counters.groups + counters.subscriptions; if (subscriptions != null && titleCounter > 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Subscriptions, titleCounter, (MediaListItemViewModelBase) new SubscriptionsMediaListItemViewModel(subscriptions.items.Select <SubscriptionObj, string>((Func <SubscriptionObj, string>)(item => item.photo_max)).ToList <string>()), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.subscriptions); Navigator.Current.NavigateToSubscriptions(this._profileData.Id); }))); } Doc lastDoc = this._profileData.lastDoc; if (lastDoc != null) { if (this._profileData.Id == AppGlobalStateManager.Current.LoggedInUserId || this._isGroup) { DocumentHeader documentHeader = new DocumentHeader(lastDoc, 0, false); sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Docs, counters.docs, (MediaListItemViewModelBase) new GenericMediaListItemViewModel(lastDoc.ToString(), documentHeader.Name, documentHeader.GetSizeString(), "/Resources/Profile/ProfileDocuments.png"), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.docs); Navigator.Current.NavigateToDocuments(this._isGroup ? -this._profileData.Id : this._profileData.Id, this._profileData.AdminLevel > 1); }))); } } else if (this._profileData.CanAddDocs && counters.docs == 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Docs, 0, (MediaListItemViewModelBase) new EmptyDataMediaListItemViewModel("/Resources/Profile/Placeholders/ProfilePlaceholderDocs.png"), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.docs); Navigator.Current.NavigateToDocuments(this._isGroup ? -this._profileData.Id : this._profileData.Id, this._profileData.AdminLevel > 1); }))); } return(sectionViewModelList); }
public RemoteFileInfo(AudioObj audioObj) { this.UriStr = audioObj.url; this.ownerId = audioObj.owner_id; this.audioId = audioObj.id; }
public AttachmentViewModel(Attachment attachment, string parentPostId = null) { this._attachment = attachment; if (attachment.type == "photo") { this.AttachmentType = AttachmentType.Photo; this.ResourceUri = attachment.photo.src_big; this.AccessKey = attachment.photo.access_key ?? ""; this.Photo = attachment.photo; } if (attachment.type == "video") { this.AttachmentType = AttachmentType.Video; this.ResourceUri = attachment.video.image_big; if (string.IsNullOrEmpty(this.ResourceUri)) { this.ResourceUri = attachment.video.image_medium; } this._mediaDurationSeconds = attachment.video.duration; this.MediaId = attachment.video.vid; this.MediaOwnerId = attachment.video.owner_id; this.AccessKey = attachment.video.access_key ?? ""; } if (attachment.type == "doc") { this.AttachmentType = AttachmentType.Document; if (attachment.doc != null) { this.ResourceDescription = attachment.doc.title; this.ResourceUri = attachment.doc.url; this._documentImageUri = !attachment.doc.IsGraffiti ? attachment.doc.PreviewUri : attachment.doc.GraffitiPreviewUri; } } if (attachment.type == "audio") { this.AttachmentType = AttachmentType.Audio; AudioObj audio = attachment.audio; if (audio != null) { this.ResourceUri = audio.url; this.ResourceDescription = audio.title ?? ""; this.ResourceDescription = ((string)this.ResourceDescription).Trim(); this.Artist = audio.artist ?? ""; this.Artist = ((string)this.Artist).Trim(); this.AudioContentRestricted = audio.content_restricted; this.MediaId = audio.aid; this.MediaOwnerId = audio.owner_id; this._audio = audio; } } if (attachment.type == "wall") { this.AttachmentType = AttachmentType.WallPost; if (attachment.wall != null) { this._wallPost = attachment.wall; this.ResourceUri = string.Concat(new object[4] { "https://vk.com/wall", attachment.wall.to_id, "_", attachment.wall.id }); } } if (attachment.type == "wall_reply") { this.AttachmentType = AttachmentType.WallReply; if (attachment.wall_reply != null) { this._comment = attachment.wall_reply; this.ResourceUri = string.Concat(new object[4] { "https://vk.com/wall", attachment.wall_reply.owner_id, "_", attachment.wall_reply.post_id }); } } if (attachment.type == "sticker") { this.AttachmentType = AttachmentType.Sticker; if (attachment.sticker != null) { this.TryReadStickerData(attachment.sticker.photo_64, 64); this.TryReadStickerData(attachment.sticker.photo_128, 128); this.TryReadStickerData(attachment.sticker.photo_256, 256); } } if (attachment.type == "gift") { this.AttachmentType = AttachmentType.Gift; this.Gift = attachment.gift; } this.ParentPostId = parentPostId; this.UniqueId = Guid.NewGuid().ToString(); }
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); }
private void ProcessInputData() { Group group = ParametersRepository.GetParameterForIdAndReset("PickedGroupForRepost") as Group; if (group != null) { this.Share(group.id, group.name); } Photo photo = ParametersRepository.GetParameterForIdAndReset("PickedPhoto") as Photo; if (photo != null) { this._commentVM.AddAttachment((IOutboundAttachment)OutboundPhotoAttachment.CreateForChoosingExistingPhoto(photo, 0L, false, PostType.WallPost)); } VKClient.Common.Backend.DataObjects.Video video = ParametersRepository.GetParameterForIdAndReset("PickedVideo") as VKClient.Common.Backend.DataObjects.Video; if (video != null) { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundVideoAttachment(video)); } AudioObj audio = ParametersRepository.GetParameterForIdAndReset("PickedAudio") as AudioObj; if (audio != null) { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundAudioAttachment(audio)); } Doc pickedDocument = ParametersRepository.GetParameterForIdAndReset("PickedDocument") as Doc; if (pickedDocument != null) { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundDocumentAttachment(pickedDocument)); } List <Stream> streamList1 = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotos") as List <Stream>; List <Stream> streamList2 = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotosPreviews") as List <Stream>; if (streamList1 != null && streamList2 != null) { for (int index = 0; index < streamList1.Count; ++index) { Stream stream1 = streamList1[index]; Stream stream2 = streamList2[index]; long userOrGroupId = 0; int num1 = 0; Stream previewStream = stream2; int num2 = 0; this._commentVM.AddAttachment((IOutboundAttachment)OutboundPhotoAttachment.CreateForUploadNewPhoto(stream1, userOrGroupId, num1 != 0, previewStream, (PostType)num2)); } this._viewModel.SetInProgress(true, CommonResources.WallPost_UploadingAttachments); this._commentVM.UploadAttachments(); } FileOpenPickerContinuationEventArgs continuationEventArgs = ParametersRepository.GetParameterForIdAndReset("FilePicked") as FileOpenPickerContinuationEventArgs; if ((continuationEventArgs == null || !(continuationEventArgs.Files).Any <StorageFile>()) && !ParametersRepository.Contains("PickedPhotoDocument")) { return; } object parameterForIdAndReset = ParametersRepository.GetParameterForIdAndReset("FilePickedType"); StorageFile file = continuationEventArgs != null ? (continuationEventArgs.Files).First <StorageFile>() : (StorageFile)ParametersRepository.GetParameterForIdAndReset("PickedPhotoDocument"); AttachmentType result; if (parameterForIdAndReset == null || !Enum.TryParse <AttachmentType>(parameterForIdAndReset.ToString(), out result)) { return; } if (result != AttachmentType.VideoFromPhone) { if (result != AttachmentType.DocumentFromPhone && result != AttachmentType.DocumentPhoto) { return; } this._commentVM.AddAttachment((IOutboundAttachment) new OutboundUploadDocumentAttachment(file)); this._commentVM.UploadAttachments(); } else { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundUploadVideoAttachment(file, true, 0L)); this._commentVM.UploadAttachments(); } }
private void ProcessInputData() { Group parameterForIdAndReset1 = ParametersRepository.GetParameterForIdAndReset("PickedGroupForRepost") as Group; if (parameterForIdAndReset1 != null) { this.Share(parameterForIdAndReset1.id, parameterForIdAndReset1.name); } Photo parameterForIdAndReset2 = ParametersRepository.GetParameterForIdAndReset("PickedPhoto") as Photo; if (parameterForIdAndReset2 != null) { this._commentVM.AddAttachment((IOutboundAttachment)OutboundPhotoAttachment.CreateForChoosingExistingPhoto(parameterForIdAndReset2, 0, false, PostType.WallPost)); } VKClient.Common.Backend.DataObjects.Video parameterForIdAndReset3 = ParametersRepository.GetParameterForIdAndReset("PickedVideo") as VKClient.Common.Backend.DataObjects.Video; if (parameterForIdAndReset3 != null) { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundVideoAttachment(parameterForIdAndReset3)); } AudioObj parameterForIdAndReset4 = ParametersRepository.GetParameterForIdAndReset("PickedAudio") as AudioObj; if (parameterForIdAndReset4 != null) { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundAudioAttachment(parameterForIdAndReset4)); } Doc parameterForIdAndReset5 = ParametersRepository.GetParameterForIdAndReset("PickedDocument") as Doc; if (parameterForIdAndReset5 != null) { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundDocumentAttachment(parameterForIdAndReset5)); } List <Stream> parameterForIdAndReset6 = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotos") as List <Stream>; List <Stream> parameterForIdAndReset7 = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotosPreviews") as List <Stream>; if (parameterForIdAndReset6 != null) { for (int index = 0; index < parameterForIdAndReset6.Count; ++index) { Stream stream1 = parameterForIdAndReset6[index]; Stream stream2 = parameterForIdAndReset7[index]; long userOrGroupId = 0; int num1 = 0; Stream previewStream = stream2; int num2 = 0; this._commentVM.AddAttachment((IOutboundAttachment)OutboundPhotoAttachment.CreateForUploadNewPhoto(stream1, userOrGroupId, num1 != 0, previewStream, (PostType)num2)); } this.PostCommentsVM.SetInProgress(true, CommonResources.WallPost_UploadingAttachments); this._commentVM.UploadAttachments(); } 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) { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundUploadDocumentAttachment(current)); this._commentVM.UploadAttachments(); } } else { this._commentVM.AddAttachment((IOutboundAttachment) new OutboundUploadVideoAttachment(current, true, 0L)); this._commentVM.UploadAttachments(); } } } finally { if (enumerator != null) { enumerator.Dispose(); } } }
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(); } } }
internal void AddExistingAudioAttachment(AudioObj pickedAudio) { this.Attachments.Add((IOutboundAttachment) new OutboundAudioAttachment(pickedAudio)); }
public override void Read(BinaryReader reader) { reader.ReadInt32(); this._audio = reader.ReadGeneric <AudioObj>(); }
private List <MediaListSectionViewModel> CreateMediaItems() { List <MediaListSectionViewModel> sectionViewModelList = new List <MediaListSectionViewModel>(); if (this._profileData == null) { return(sectionViewModelList); } Counters counters = this._profileData.counters; Photo lastPhoto = this._profileData.lastPhoto; if ((this._mainSectionType != ProfileMainSectionType.Photos || this._profileData.photos == null || this._profileData.photos.items.Count == 0) && lastPhoto != null) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Photos, counters.photos, (MediaListItemViewModelBase) new PhotoAlbumMediaListItemViewModel(lastPhoto), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.photos); Navigator.Current.NavigateToPhotoAlbums(false, this._profileData.Id, this._isGroup, this._profileData.AdminLevel); }))); } else if (this._isGroup && this._profileData.CanAddPhotos && counters.photos == 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Photos, 0, (MediaListItemViewModelBase) new EmptyDataMediaListItemViewModel("/Resources/Profile/Placeholders/ProfilePlaceholderPhotos.png"), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.photos); Navigator.Current.NavigateToPhotoAlbums(false, this._profileData.Id, this._isGroup, this._profileData.AdminLevel); }))); } List <Topic> topics = this._profileData.topics; Group group = this._profileData as Group; if (group != null) { //GroupData profileData = this._profileData as GroupData; //if ((profileData != null ? profileData.group : null) != null) //{ // Group group = profileData.group; if (this._mainSectionType != ProfileMainSectionType.Discussions && !topics.IsNullOrEmpty()) { Topic topic = (Topic)Enumerable.First <Topic>(topics); sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Discussions, counters.topics, (MediaListItemViewModelBase) new GenericMediaListItemViewModel(topic.ToString(), topic.title, UIStringFormatterHelper.FormatNumberOfSomething(topic.comments, CommonResources.OneMessageFrm, CommonResources.TwoFourMessagesFrm, CommonResources.FiveMessagesFrm, true, null, false), "/Resources/Profile/ProfileTopic.png", ProfileBlockType.discussions), (Action)(() => Navigator.Current.NavigateToGroupDiscussions(group.id, "", group.admin_level, false, group.CanCreateTopic)))); } else if (this._profileData.CanAddTopics && counters.topics == 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Discussions, 0, (MediaListItemViewModelBase) new EmptyDataMediaListItemViewModel("/Resources/Profile/Placeholders/ProfilePlaceholderTopics.png"), (Action)(() => Navigator.Current.NavigateToGroupDiscussions(group.id, "", group.admin_level, false, group.CanCreateTopic)))); } } List <VKClient.Common.Backend.DataObjects.Video> videos = this._profileData.videos; if (this._mainSectionType != ProfileMainSectionType.Videos && !videos.IsNullOrEmpty()) { VKClient.Common.Backend.DataObjects.Video video = Enumerable.First <VKClient.Common.Backend.DataObjects.Video>(videos); sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Videos, counters.videos, (MediaListItemViewModelBase) new VideoAlbumMediaListItemViewModel(video), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.videos); Navigator.Current.NavigateToVideo(false, this._profileData.Id, this._isGroup, this._profileData.AdminLevel > 1); }))); } else if (this._isGroup && this._profileData.CanAddVideos && counters.videos == 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Videos, counters.topics, (MediaListItemViewModelBase) new EmptyDataMediaListItemViewModel("/Resources/Profile/Placeholders/ProfilePlaceholderVideos.png"), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.videos); Navigator.Current.NavigateToVideo(false, this._profileData.Id, this._isGroup, this._profileData.AdminLevel > 1); }))); } List <Product> products = this._profileData.goods == null ? null : this._profileData.goods.items;//todo:bugfix VKLIST if (this._mainSectionType != ProfileMainSectionType.Market && !products.IsNullOrEmpty()) { Product product = (Product)Enumerable.First <Product>(products); sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Products, counters.market, (MediaListItemViewModelBase) new ProductsAlbumMediaListItemViewModel(product), (Action)(() => { }))); } else if (this._isGroup && this._profileData.CanAddProducts && counters.market == 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Videos, counters.topics, (MediaListItemViewModelBase) new EmptyDataMediaListItemViewModel("/Resources/Profile/Placeholders/ProfilePlaceholderVideos.png"), (Action)(() => { }))); } List <AudioObj> audios = this._profileData.audios; if (this._mainSectionType != ProfileMainSectionType.Audios && !audios.IsNullOrEmpty()) { AudioObj audioObj = (AudioObj)Enumerable.First <AudioObj>(audios); sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Audios, counters.audios, (MediaListItemViewModelBase) new GenericMediaListItemViewModel(audioObj.ToString(), audioObj.title, audioObj.artist, "/Resources/Profile/ProfileMusic.png", ProfileBlockType.audios), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.audios); Navigator.Current.NavigateToAudio(0, this._profileData.Id, this._isGroup, 0, 0, ""); }))); } else if (this._isGroup && this._profileData.CanAddAudios && counters.audios == 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Audios, 0, (MediaListItemViewModelBase) new EmptyDataMediaListItemViewModel("/Resources/Profile/Placeholders/ProfilePlaceholderAudios.png"), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.audios); Navigator.Current.NavigateToAudio(0, this._profileData.Id, this._isGroup, 0, 0, ""); }))); } VKList <SubscriptionObj> subscriptions = this._profileData.subscriptions; int titleCounter = counters.pages + counters.groups + counters.subscriptions; if (subscriptions != null && titleCounter > 0) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Profile_Subscriptions, titleCounter, (MediaListItemViewModelBase) new SubscriptionsMediaListItemViewModel((List <string>)Enumerable.ToList <string>(Enumerable.Select <SubscriptionObj, string>(subscriptions.items, new Func <SubscriptionObj, string>((item) => { return(item.photo_max); })))), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.subscriptions); Navigator.Current.NavigateToSubscriptions(this._profileData.Id); }))); } Doc lastDoc = this._profileData.lastDoc; if (lastDoc != null) { if (this._profileData.Id == AppGlobalStateManager.Current.LoggedInUserId || this._isGroup) { sectionViewModelList.Add(this.GetDocumentsModel(lastDoc, counters.docs)); } } else if (this._profileData.CanAddDocs && counters.docs == 0) { sectionViewModelList.Add(this.GetDocumentsEmptyModel()); } List <GiftItemData> giftItemDataList = this._profileData.gifts != null ? this._profileData.gifts.items : null; if (counters.gifts > 0 && giftItemDataList != null) { sectionViewModelList.Add(new MediaListSectionViewModel(CommonResources.Gifts, counters.gifts, new GiftsMediaListItemViewModel((List <string>)Enumerable.ToList <string>(Enumerable.Select <GiftItemData, string>(Enumerable.Where <GiftItemData>(giftItemDataList, new Func <GiftItemData, bool>((item) => { return(item != null); })), new Func <GiftItemData, string>((item) => { return(item.gift.thumb_256); })))), (Action)(() => { this.PublishProfileBlockClickEvent(ProfileBlockType.gifts); Navigator.Current.NavigateToGifts(this._profileData.Id, this._profileData.FirstName, this._profileData.NameGen); }))); } return(sectionViewModelList); }
private static string FormatAudioStr(AudioObj audioObj) { return(audioObj.artist + " — " + audioObj.title); }