private void ProcessInputParameters() { AudioAlbum pickedAlbum = ParametersRepository.GetParameterForIdAndReset("PickedAlbum") as AudioAlbum; if (pickedAlbum == null || !this.IsInMultiSelectMode) { return; } List <AudioHeader> headersToMove = this.GetSelectedAudioHeaders(); this.IsInMultiSelectMode = false; this.ViewModel.MoveTracksToAlbum(headersToMove, pickedAlbum, (Action <bool>)(result => Execute.ExecuteOnUIThread((Action)(() => { if (!result) { ExtendedMessageBox.ShowSafe(CommonResources.GenericErrorText); } else { if (MessageBox.Show(UIStringFormatterHelper.FormatNumberOfSomething(headersToMove.Count, AudioResources.OneAudioMovedFrm, AudioResources.TwoFourAudiosMovedFrm, AudioResources.FiveAudiosMovedFrm, true, pickedAlbum.title, false), AudioResources.MoveAudios, MessageBoxButton.OKCancel) != MessageBoxResult.OK) { return; } Navigator.Current.NavigateToAudio(0, this.CommonParameters.UserOrGroupId, this.CommonParameters.IsGroup, pickedAlbum.album_id, 0, pickedAlbum.title); } })))); }
public void Handle(StickerItemTapEvent message) { if (!this._isCurrentPage) { return; } bool fromGroupChecked = this.ucNewMessage.FromGroupChecked; if (this._addingComment) { return; } this._addingComment = true; this.PostCommentsVM.PostComment("", this._replyToCid, this._replyToUid, fromGroupChecked, new List <IOutboundAttachment>(), (Action <bool>)(result => { this._addingComment = false; Execute.ExecuteOnUIThread((Action)(() => { if (!result) { ExtendedMessageBox.ShowSafe(CommonResources.Error); } else { this.ScrollToBottom(); this.ResetReplyFields(); } })); }), message.StickerItem, message.Referrer); }
private void CreateChatAndProceed(List <long> uids) { long loggedInUserId = AppGlobalStateManager.Current.LoggedInUserId; if (this._creatingChat) { return; } this._creatingChat = true; this.ShowProgressIndicator(true, CommonResources.FriendsAndContactsSearchPage_CreatingChat); List <long> longList = new List <long>() { loggedInUserId }; if (this._initialUserId != 0L) { longList.Add(this._initialUserId); } longList.AddRange((IEnumerable <long>)uids); MessagesService.Instance.CreateChat(longList, (Action <BackendResult <VKClient.Audio.Base.ResponseWithId, ResultCode> >)(res => { this._creatingChat = false; this.ShowProgressIndicator(false, ""); if (res.ResultCode != ResultCode.Succeeded) { ExtendedMessageBox.ShowSafe(CommonResources.FriendsAndContactsSearchPage_FailedToCreateChat); } else { Navigator.Current.NavigateToConversation(res.ResultData.response, true, true, "", 0, false); } })); }
public void UploadUserPhoto(Stream stream, Rect rect) { if (this.IsSaving) { return; } this.IsSaving = true; this.SetInProgress(true, ""); ImagePreprocessor.PreprocessImage(stream, VKConstants.ResizedImageSize, true, (Action <ImagePreprocessResult>)(pres => { Stream stream1 = pres.Stream; byte[] numArray = (byte[])new byte[stream1.Length]; stream1.Read(numArray, 0, (int)stream1.Length); stream1.Close(); UsersService.Instance.SaveProfilePhoto(ImagePreprocessor.GetThumbnailRect((double)pres.Width, (double)pres.Height, rect), numArray, (Action <BackendResult <ProfilePhoto, ResultCode> >)(res => { this.IsSaving = false; this.SetInProgress(false, ""); if (res.ResultCode == ResultCode.Succeeded) { BaseDataManager.Instance.NeedRefreshBaseData = true; BaseDataManager.Instance.RefreshBaseDataIfNeeded(); } else { ExtendedMessageBox.ShowSafe(CommonResources.Error); } })); })); }
private void _appBarButtonAddComment_Click(object sender, EventArgs e) { if (this._isAddingComment) { return; } string text = this.newCommentUC.TextBoxNewComment.Text; if (text.Length < 2 && this._commentVM.OutboundAttachments.Count <= 0) { return; } this._isAddingComment = true; this.GroupDiscussionVM.AddComment(text.Replace("\r\n", "\r").Replace("\r", "\r\n"), this._commentVM.OutboundAttachments.ToList <IOutboundAttachment>(), (Action <bool>)(res => { this._isAddingComment = false; Execute.ExecuteOnUIThread((Action)(() => { if (res) { this.newCommentUC.TextBoxNewComment.Text = (string.Empty); this.InitializeCommentVM(); this.UpdateAppBar(); } else { ExtendedMessageBox.ShowSafe(CommonResources.Error); } })); }), (StickerItemData)null, this.newCommentUC.FromGroupChecked, ""); }
public void UploadDocuments(List <StorageFile> files) { base.SetInProgress(true, ""); int i0 = 0; Action <BackendResult <Doc, ResultCode> > callback = null; callback = delegate(BackendResult <Doc, ResultCode> result) { if (result.ResultCode == ResultCode.Succeeded) { int i; if (i0 == files.Count - 1) { this.SetInProgress(false, ""); } Execute.ExecuteOnUIThread(delegate { DocumentUploadedEvent message = new DocumentUploadedEvent { OwnerId = this.OwnerId, Document = result.ResultData }; EventAggregator.Current.Publish(message); }); i = i0; i0++; this.UploadFile(files[i], callback); return; } this.SetInProgress(false, ""); ExtendedMessageBox.ShowSafe(CommonResources.Error_Generic, CommonResources.Error); }; this.UploadFile(files[i0], callback); }
private void MenuItemTap(object sender, System.Windows.Input.GestureEventArgs e) { FrameworkElement frameworkElement = sender as FrameworkElement; DependencyObject dependencyObject = (DependencyObject)frameworkElement; while (!(dependencyObject is ContextMenu)) { dependencyObject = VisualTreeHelper.GetParent(dependencyObject); } ContextMenu contextMenu = dependencyObject as ContextMenu; int num = 0; contextMenu.IsOpen = num != 0; ConversationHeader dataContext1 = ((FrameworkElement)contextMenu).DataContext as ConversationHeader; if (!(frameworkElement.DataContext is MenuItemData)) { return; } MenuItemData dataContext2 = frameworkElement.DataContext as MenuItemData; if (dataContext2.Tag == "delete" && MessageBox.Show(CommonResources.Conversation_ConfirmDeletion, CommonResources.Conversation_DeleteDialog, MessageBoxButton.OKCancel) == MessageBoxResult.OK) { ConversationsViewModel.Instance.DeleteConversation(dataContext1); } if (dataContext2.Tag == "disableEnable") { ConversationsViewModel.Instance.SetInProgressMain(true, ""); dataContext1.DisableEnableNotifications((Action <bool>)(res => Execute.ExecuteOnUIThread((Action)(() => { ConversationsViewModel.Instance.SetInProgressMain(false, ""); if (res) { return; } ExtendedMessageBox.ShowSafe(CommonResources.Error); })))); } if (!(dataContext2.Tag == "messagesFromGroup") || dataContext1 == null) { return; } ConversationsViewModel.Instance.SetInProgressMain(true, ""); dataContext1.AllowDenyMessagesFromGroup((Action <bool>)(res => Execute.ExecuteOnUIThread((Action)(() => { ConversationsViewModel.Instance.SetInProgressMain(false, ""); if (res) { return; } ExtendedMessageBox.ShowSafe(CommonResources.Error); })))); }
public void Save() { if (this._isBusy) { return; } this._isBusy = true; this.SetInProgressMain(true, ""); Album album = this._album.Copy(); album.title = this.Name; album.description = UIStringFormatterHelper.CorrectNewLineCharacters(this.Description); album.privacy_view = this.PrivacyViewVM.GetAsPrivacyInfo().ToStringList(); album.comment_privacy = this.AccessTypeComments != null ? this.AccessTypeComments.Id : 0; PhotosService photosService = new PhotosService(); if (this._isNewMode) { photosService.CreateAlbum(album, (Action <BackendResult <Album, ResultCode> >)(res => { this._isBusy = false; this.SetInProgressMain(false, ""); if (res.ResultCode == ResultCode.Succeeded) { this._notifyOnCompletion(res.ResultData); } else { ExtendedMessageBox.ShowSafe(CommonResources.Error); } }), this._gid); } else { photosService.EditAlbum(album, (Action <BackendResult <ResponseWithId, ResultCode> >)(res => { this._isBusy = false; this.SetInProgressMain(false, ""); if (res.ResultCode == ResultCode.Succeeded) { this._notifyOnCompletion(album); } else { ExtendedMessageBox.ShowSafe(CommonResources.Error); } }), this._gid); } }
private void PerformLoginAttempt() { if (this._inProgress || !this._isLoginButtonEnabled) { return; } this._inProgress = true; this.SetControlsState(false); Logger.Instance.Info("Trying to log in", new object[0]); this.ShowProgressIndicator(true, ""); Logger.Instance.Info("Calling back end service", new object[0]); LoginService.Instance.GetAccessToken(this.textBoxUsername.Text, this.passwordBox.Password, delegate(BackendResult <AutorizationData, ResultCode> result) { Logger.Instance.Info("Back end service returned: " + result.ResultCode.ToString(), new object[0]); this.ShowProgressIndicator(false, ""); ResultCode resultCode = result.ResultCode; if (resultCode != ResultCode.CommunicationFailed) { if (resultCode != ResultCode.Succeeded) { if (resultCode != ResultCode.CaptchaControlCancelled) { Execute.ExecuteOnUIThread(delegate { ExtendedMessageBox.ShowSafe(AppResources.Login_Error_InvalidCredential, AppResources.Login_Error_Header); this.SetControlsState(true); this.passwordBox.Focus(); }); } else { this.SetControlsState(true); } } else { ServiceLocator.Resolve <IAppStateInfo>().HandleSuccessfulLogin(result.ResultData, true); } } else { ExtendedMessageBox.ShowSafe(AppResources.FailedToConnect, AppResources.Login_Error_Header); this.SetControlsState(true); } this._inProgress = false; }); }
private void _appBarButtonSend_Click(object sender, EventArgs e) { string str1 = this.textBoxNewMessage.Text; if (this.ReplyAutoForm != null && str1.StartsWith(this.ReplyAutoForm)) { string str2 = this.ReplyAutoForm.Remove(this.ReplyAutoForm.IndexOf(", ")); string str3 = this._replyToUid > 0L ? "id" : "club"; long num = this._replyToUid > 0L ? this._replyToUid : -this.PostCommentsVM.WallPostData.WallPost.owner_id; str1 = str1.Remove(0, this.ReplyAutoForm.Length).Insert(0, string.Format("[{0}{1}|{2}], ", str3, num, str2)); } string text = str1.Replace("\r\n", "\r").Replace("\r", "\r\n"); if (!this.PostCommentsVM.CanPostComment(text, (List <IOutboundAttachment>)Enumerable.ToList <IOutboundAttachment>(this._commentVM.OutboundAttachments), null)) { return; } bool fromGroupChecked = this.ucNewMessage.FromGroupChecked; if (this._addingComment) { return; } this._addingComment = true; this.PostCommentsVM.PostComment(text, this._replyToCid, this._replyToUid, fromGroupChecked, (List <IOutboundAttachment>)Enumerable.ToList <IOutboundAttachment>(this._commentVM.OutboundAttachments), (Action <bool>)(result => { this._addingComment = false; Execute.ExecuteOnUIThread((Action)(() => { if (!result) { ExtendedMessageBox.ShowSafe(CommonResources.Error); } else { this.textBoxNewMessage.Text = (""); this.InitializeCommentVM(); this.UpdateAppBar(); this.ScrollToBottom(); this.textBoxNewMessage.Text = (""); this.ResetReplyFields(); } })); }), null, ""); }
private void PerformLoginAttempt() { if (this._inProgress || !this._isLoginButtonEnabled) { return; } this._inProgress = true; this.SetControlsState(false); Logger.Instance.Info("Trying to log in"); this.ShowProgressIndicator(true, ""); Logger.Instance.Info("Calling back end service"); //wtf Logger.Instance.Error("WTF " + this.textBoxUsername.Text + " " + this.passwordBox.Password); // LoginService.Instance.GetAccessToken(this.textBoxUsername.Text, this.passwordBox.Password, (Action <BackendResult <AutorizationData, ResultCode> >)(result => { Logger.Instance.Info("Back end service returned: " + result.ResultCode.ToString()); this.ShowProgressIndicator(false, ""); switch (result.ResultCode) { case ResultCode.CommunicationFailed: ExtendedMessageBox.ShowSafe(AppResources.FailedToConnect, AppResources.Login_Error_Header); this.SetControlsState(true); break; case ResultCode.Succeeded: ServiceLocator.Resolve <IAppStateInfo>().HandleSuccessfulLogin(result.ResultData, true); break; case ResultCode.CaptchaControlCancelled: this.SetControlsState(true); break; default: Execute.ExecuteOnUIThread((Action)(() => { ExtendedMessageBox.ShowSafe(AppResources.Login_Error_InvalidCredential, AppResources.Login_Error_Header); this.SetControlsState(true); this.passwordBox.Focus(); })); break; } this._inProgress = false; })); }
public void Handle(StickerItemTapEvent message) { if (!this._isCurrentPage || this._isAddingComment) { return; } this._isAddingComment = true; this.GroupDiscussionVM.AddComment("", this._commentVM.OutboundAttachments.ToList <IOutboundAttachment>(), (Action <bool>)(res => { this._isAddingComment = false; Execute.ExecuteOnUIThread((Action)(() => { if (res) { return; } ExtendedMessageBox.ShowSafe(CommonResources.Error); })); }), message.StickerItem, this.newCommentUC.FromGroupChecked, message.Referrer); }
private void MenuItemTap(object sender, System.Windows.Input.GestureEventArgs e) { FrameworkElement frameworkElement = sender as FrameworkElement; DependencyObject dependencyObject = (DependencyObject)frameworkElement; while (!(dependencyObject is ContextMenu)) { dependencyObject = VisualTreeHelper.GetParent(dependencyObject); } ContextMenu contextMenu = dependencyObject as ContextMenu; int num = 0; contextMenu.IsOpen = num != 0; ConversationHeader dataContext1 = ((FrameworkElement)contextMenu).DataContext as ConversationHeader; if (!(frameworkElement.DataContext is MenuItemData)) { return; } MenuItemData dataContext2 = frameworkElement.DataContext as MenuItemData; if (dataContext2.Tag == "delete") { this.DeleteConversation(dataContext1); } if (!(dataContext2.Tag == "disableEnable")) { return; } this.ConversationsVM.SetInProgressMain(true, ""); dataContext1.DisableEnableNotifications((Action <bool>)(res => Execute.ExecuteOnUIThread((Action)(() => { this.ConversationsVM.SetInProgressMain(false, ""); if (res) { return; } ExtendedMessageBox.ShowSafe(CommonResources.Error); })))); }
internal void PinToStart() { if ((this._group == null || string.IsNullOrWhiteSpace(this._group.name)) && string.IsNullOrWhiteSpace(this._prefetchedName)) { return; } if (this._isLoading) { return; } this._isLoading = true; string smallPhoto = ""; if (this._group != null && this._group.photo_200 != null) { smallPhoto = this._group.photo_200; } string name = ""; if (!string.IsNullOrWhiteSpace(this._prefetchedName)) { name = this._prefetchedName; } if (this._group != null) { name = this._group.name; } base.SetInProgress(true, ""); SecondaryTileCreator.CreateTileFor(this._gid, true, name, delegate(bool res) { base.SetInProgress(false, ""); this._isLoading = false; if (!res) { Action arg_35_0 = new Action(() => { ExtendedMessageBox.ShowSafe(CommonResources.Error); }); Execute.ExecuteOnUIThread(arg_35_0); } }, smallPhoto); }
public static void PlayVideo(VKClient.Common.Backend.DataObjects.Video video, Action callback, int resolution, StatisticsActionSource actionSource = StatisticsActionSource.news, string videoContext = "") { if ((video != null ? video.files : null) == null || video.files.Count == 0) { callback.Invoke(); ExtendedMessageBox.ShowSafe(video == null || video.processing != 0 ? CommonResources.ProcessingVideoError : CommonResources.Conversation_VideoIsNotAvailable); } else { bool isExternal; string uri = VideoPlayerHelper.GetVideoUri(video, resolution, out isExternal); if (string.IsNullOrEmpty(uri)) { callback.Invoke(); ExtendedMessageBox.ShowSafe(video.processing == 0 ? CommonResources.Conversation_VideoIsNotAvailable : CommonResources.ProcessingVideoError); } else { EventAggregator current = EventAggregator.Current; VideoPlayEvent videoPlayEvent = new VideoPlayEvent(); videoPlayEvent.Position = StatisticsVideoPosition.start; int num1 = resolution; videoPlayEvent.quality = num1; string globallyUniqueId = video.GloballyUniqueId; videoPlayEvent.id = globallyUniqueId; int num2 = (int)actionSource; videoPlayEvent.Source = (StatisticsActionSource)num2; string str = videoContext; videoPlayEvent.Context = str; current.Publish(videoPlayEvent); ThreadPool.QueueUserWorkItem((WaitCallback)(o => { Thread.Sleep(500); VideoPlayerHelper.PlayVideo(uri, isExternal, resolution, callback); })); } } }
public async void UploadDocument(StorageFile file) { Stream stream = ((IInputStream)await file.OpenAsync((FileAccessMode)0)).AsStreamForRead(); Action <BackendResult <Doc, ResultCode> > callback = (Action <BackendResult <Doc, ResultCode> >)(result => { this.SetInProgress(false, ""); if (result.ResultCode == ResultCode.Succeeded) { Execute.ExecuteOnUIThread((Action)(() => EventAggregator.Current.Publish((object)new DocumentUploadedEvent() { OwnerId = this.OwnerId, Document = result.ResultData }))); } else { ExtendedMessageBox.ShowSafe(CommonResources.Error_Generic, CommonResources.Error); } }); this.SetInProgress(true, ""); DocumentsService.Current.UploadDocument(this.OwnerId >= 0L ? 0L : -this.OwnerId, file.Name, file.FileType, stream, callback, (Action <double>)null, (Cancellation)null); }
protected override void HandleOnNavigatedTo(NavigationEventArgs e) { base.HandleOnNavigatedTo(e); PhotosToMoveInfo photosToMove = ParametersRepository.GetParameterForIdAndReset("PhotosToMove") as PhotosToMoveInfo; bool needRefreshAfterMove = false; if (!this._isInitialized) { PhotoAlbumViewModel.PhotoAlbumViewModelInput inputData = new PhotoAlbumViewModel.PhotoAlbumViewModelInput(); inputData.AlbumId = base.NavigationContext.QueryString["albumId"]; inputData.UserOrGroupId = (long)int.Parse(base.NavigationContext.QueryString["userOrGroupId"]); inputData.IsGroup = bool.Parse(base.NavigationContext.QueryString["isGroup"]); if (base.NavigationContext.QueryString.ContainsKey("albumName")) { inputData.AlbumName = base.NavigationContext.QueryString["albumName"]; inputData.AlbumType = (AlbumType)Enum.Parse(typeof(AlbumType), base.NavigationContext.QueryString["albumType"], true); inputData.PageTitle = base.NavigationContext.QueryString["pageTitle"]; inputData.AlbumDescription = base.NavigationContext.QueryString["albumDesc"]; inputData.PhotosCount = int.Parse(base.NavigationContext.QueryString["photosCount"]); this._pickMode = bool.Parse(base.NavigationContext.QueryString["PickMode"]); inputData.AdminLevel = int.Parse(base.NavigationContext.QueryString["AdminLevel"]); inputData.ForceCanUpload = bool.Parse(base.NavigationContext.QueryString["ForceCanUpload"]); } PhotoAlbumViewModel photoAlbumViewModel = new PhotoAlbumViewModel(inputData); photoAlbumViewModel.PropertyChanged += (PropertyChangedEventHandler)((sender, args) => { bool flag = this.PhotoAlbumVM.PhotosCount > 0; if (this._appBarIconButtonEdit.IsEnabled == flag) { return; } this._appBarIconButtonEdit.IsEnabled = (flag); }); this.UpdateHeaderOpacity(); base.DataContext = (photoAlbumViewModel); if (photosToMove == null) { photoAlbumViewModel.RefreshPhotos(); } else { needRefreshAfterMove = true; } this.UpdateAppBar(); this._inputData = inputData; this._isInitialized = true; } if (photosToMove != null) { this.PhotoAlbumVM.MovePhotos(photosToMove.albumId, photosToMove.photos, (Action <bool>)(result => Execute.ExecuteOnUIThread((Action)(() => { if (needRefreshAfterMove) { this.PhotoAlbumVM.RefreshPhotos(); } if (this.PhotoAlbumVM.PhotosCount == 0) { this.IsInEditMode = false; } if (!result) { ExtendedMessageBox.ShowSafe(CommonResources.GenericErrorText); } else if (MessageBox.Show(UIStringFormatterHelper.FormatNumberOfSomething(photosToMove.photos.Count, PhotoResources.PhotoAlbumPageOnePhotoMovedFrm, PhotoResources.PhotoAlbumPageTwoFourPhotosMovedFrm, PhotoResources.PhotoAlbumPageFivePhotosMovedFrm, true, photosToMove.albumName, false), PhotoResources.PhotoAlbumPage_PhotoMove, (MessageBoxButton)1) == MessageBoxResult.OK) { Navigator.Current.NavigateToPhotoAlbum(photosToMove.TargetAlbumInputData.UserOrGroupId, photosToMove.TargetAlbumInputData.IsGroup, photosToMove.TargetAlbumInputData.AlbumType.ToString(), photosToMove.TargetAlbumInputData.AlbumId, photosToMove.TargetAlbumInputData.AlbumName, photosToMove.TargetAlbumInputData.PhotosCount + photosToMove.photos.Count, photosToMove.TargetAlbumInputData.PageTitle, photosToMove.TargetAlbumInputData.AlbumDescription, false, 0, false); } this.PhotoAlbumVM.UpdateThumbAfterPhotosMoving(); })))); } if (this._choosenPhotoPending != null) { this.PhotoAlbumVM.UploadPhoto(this._choosenPhotoPending, (Action <BackendResult <Photo, ResultCode> >)(res => {})); this._choosenPhotoPending = null; } this.HandleInputParameters(); }