public void NewBroadcastList() { CacheService.CheckDisabledFeature(Constants.FeatureBroadcastCreate, () => { StateService.RemoveBackEntry = true; NavigationService.UriFor <CreateBroadcastViewModel>().Navigate(); }, disabledFeature => { Execute.BeginOnUIThread(() => MessageBox.Show(disabledFeature.Description.ToString(), AppResources.AppName, MessageBoxButton.OK)); }); }
public void NewChannel() { CacheService.CheckDisabledFeature(Constants.FeatureBroadcastCreate, () => ChannelIntroViewModel.CheckIntroEnabledAsync( enabled => BeginOnUIThread(() => { if (enabled) { StateService.RemoveBackEntry = true; NavigationService.UriFor <ChannelIntroViewModel>().Navigate(); } else { StateService.RemoveBackEntry = true; NavigationService.UriFor <CreateChannelStep1ViewModel>().Navigate(); } })), disabledFeature => { Execute.BeginOnUIThread(() => MessageBox.Show(disabledFeature.Description.ToString(), AppResources.AppName, MessageBoxButton.OK)); }); }
public void SendAudio(AudioEventArgs args) { if (string.IsNullOrEmpty(args.OggFileName)) { return; } CacheService.CheckDisabledFeature(With, Constants.FeaturePMUploadAudio, Constants.FeatureChatUploadAudio, Constants.FeatureBigChatUploadAudio, () => { var id = TLLong.Random(); var accessHash = TLLong.Random(); var oggFileName = string.Format("audio{0}_{1}.mp3", id, accessHash); var wavFileName = Path.GetFileNameWithoutExtension(oggFileName) + ".wav"; long size = 0; using (var storage = IsolatedStorageFile.GetUserStoreForApplication()) { storage.MoveFile(args.OggFileName, oggFileName); using (var file = storage.OpenFile(oggFileName, FileMode.Open, FileAccess.Read)) { size = file.Length; } var wavStream = args.PcmStream.GetWavAsMemoryStream(16000, 1, 16); using (var file = new IsolatedStorageFileStream(wavFileName, FileMode.OpenOrCreate, storage)) { wavStream.Seek(0, SeekOrigin.Begin); wavStream.CopyTo(file); file.Flush(); } } var audio = new TLAudio { Id = id, AccessHash = accessHash, Date = TLUtils.DateToUniversalTimeTLInt(MTProtoService.ClientTicksDelta, DateTime.Now), UserId = new TLInt(StateService.CurrentUserId), Duration = new TLInt((int)args.Duration), MimeType = new TLString("audio/ogg"), Size = new TLInt((int)size), DCId = new TLInt(0), }; var media = new TLMessageMediaAudio { Audio = audio, IsoFileName = oggFileName, NotListened = true }; var message = TLUtils.GetMessage( new TLInt(StateService.CurrentUserId), TLUtils.InputPeerToPeer(Peer, StateService.CurrentUserId), With is TLBroadcastChat ? MessageStatus.Broadcast : MessageStatus.Sending, TLBool.True, TLBool.True, TLUtils.DateToUniversalTimeTLInt(MTProtoService.ClientTicksDelta, DateTime.Now), TLString.Empty, media, TLLong.Random(), new TLInt(0) ); message.NotListened = true; BeginOnUIThread(() => { var previousMessage = InsertSendingMessage(message); message.NotifyOfPropertyChange(() => message.Media); IsEmptyDialog = Items.Count == 0 && LazyItems.Count == 0; BeginOnThreadPool(() => CacheService.SyncSendingMessage( message, previousMessage, TLUtils.InputPeerToPeer(Peer, StateService.CurrentUserId), m => SendAudioInternal(message, args))); }); }, disabledFeature => Execute.BeginOnUIThread(() => MessageBox.Show(disabledFeature.Description.ToString(), AppResources.AppName, MessageBoxButton.OK))); }