private void OnDownloadFolderLinkClick(object sender, EventArgs e) { // Needed on every UI interaction SdkService.MegaSdkFolderLinks.retryPendingConnections(); // Extra check to avoid NullReferenceException if (_folderLinkViewModel == null || _folderLinkViewModel.FolderLinkRootNode == null) { var customMessageDialog = new CustomMessageDialog( AppMessages.AM_DownloadFailed_Title, AppMessages.AM_DownloadFolderLinkFailed, App.AppInformation, MessageDialogButtons.Ok); customMessageDialog.OkOrYesButtonTapped += (new_sender, args) => CancelAction(); customMessageDialog.ShowDialog(); return; } App.LinkInformation.SelectedNodes.Add(_folderLinkViewModel.FolderLinkRootNode); App.LinkInformation.LinkAction = LinkAction.Download; if (!_folderLinkViewModel.IsUserOnline()) { return; } _folderLinkViewModel.FolderLinkRootNode.Download(TransfersService.MegaTransfers); }
private void OnImportFolderLinkClick(object sender, EventArgs e) { // Needed on every UI interaction SdkService.MegaSdkFolderLinks.retryPendingConnections(); // Extra check to avoid NullReferenceException if (_folderLinkViewModel == null || _folderLinkViewModel.FolderLinkRootNode == null) { var customMessageDialog = new CustomMessageDialog( AppMessages.AM_ImportFailed_Title, AppMessages.AM_ImportFolderLinkFailed, App.AppInformation, MessageDialogButtons.Ok); customMessageDialog.OkOrYesButtonTapped += (new_sender, args) => CancelAction(); customMessageDialog.ShowDialog(); return; } App.LinkInformation.SelectedNodes.Add(_folderLinkViewModel.FolderLinkRootNode); App.LinkInformation.LinkAction = LinkAction.Import; NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.ImportFolderLink); }
private void ShowErrorMesageAndNavigate(String title, String message) { var customMessageDialog = new CustomMessageDialog( title, message, App.AppInformation, MessageDialogButtons.Ok); customMessageDialog.OkOrYesButtonTapped += (sender, args) => NavigateService.NavigateTo(NavigateToPage, NavigationParameter); customMessageDialog.ShowDialog(); }
/// <summary> /// Generic method to show dialog with a folder link alert message. /// </summary> /// <param name="title">Title of the alert dialog.</param> /// <param name="message">Message of the alert dialog.</param> private void GenericFolderLinkAlert(String title, String message) { Deployment.Current.Dispatcher.BeginInvoke(() => { var customMessageDialog = new CustomMessageDialog( title, message, App.AppInformation, MessageDialogButtons.Ok); customMessageDialog.OkOrYesButtonTapped += (sender, args) => _folderLinkViewModel._folderLinkPage.CancelAction(); customMessageDialog.ShowDialog(); }); }
public void onAccountUpdate(MegaSDK api) { Deployment.Current.Dispatcher.BeginInvoke(() => { var customMessageDialog = new CustomMessageDialog( AppMessages.AccountUpdated_Title, AppMessages.AccountUpdate, App.AppInformation, MessageDialogButtons.YesNo); customMessageDialog.OkOrYesButtonTapped += (sender, args) => { NavigateService.NavigateTo(typeof(MyAccountPage), NavigationParameter.Normal); }; customMessageDialog.ShowDialog(); }); }
private void DeleteContact(object obj) { if (FocusedContact != null) { var customMessageDialog = new CustomMessageDialog( AppMessages.DeleteContactQuestion_Title, String.Format(AppMessages.DeleteContactQuestion, FocusedContact.Email), App.AppInformation, MessageDialogButtons.OkCancel); customMessageDialog.OkOrYesButtonTapped += (sender, args) => { MegaSdk.removeContact(MegaSdk.getContact(FocusedContact.Email), new RemoveContactRequestListener(this, FocusedContact)); }; customMessageDialog.ShowDialog(); } }
public async void OnPreviewKeyDown(object sender, KeyEventArgs e) { e.Handled = true; Key key = e.ImeProcessedKey == Key.None ? e.Key : e.ImeProcessedKey; int vkCode = KeyInterop.VirtualKeyFromKey(key); int result = _profileSwitchKeyTableManager.SetSwitchKeyByIndex(_fromIdx, _toIdx, vkCode); //Use WindowManager rather than directly access to view CustomMessageDialog customMessageDialog; switch (result) { case -2: customMessageDialog = new CustomMessageDialog($"{key} is already reserved for activation key."); customMessageDialog.ShowDialog(); break; case -1: customMessageDialog = new CustomMessageDialog($"{key} is already used for other switch key."); customMessageDialog.ShowDialog(); break; case 0: customMessageDialog = new CustomMessageDialog($"{key} is already registerd as a hotkey of this profile"); customMessageDialog.ShowDialog(); break; default: await _profileSwitchKeyTableManager.SaveTableAsync(); NotifyOfPropertyChange(() => SwitchKey); break; } }
public async void OnPreviewKeyDown(object sender, KeyEventArgs e) { e.Handled = true; var key = e.ImeProcessedKey == Key.None ? e.Key : e.ImeProcessedKey; var activationKey = KeyInterop.VirtualKeyFromKey(key); if (_applicationModel.SetActivationKey(activationKey)) { await _jsonSavefileManager.SaveAsync(_options, AppConstants.OPTION_SAVE_NAME); NotifyOfPropertyChange(() => ActivationKey); return; } CustomMessageDialog dialog = new CustomMessageDialog("This key is already registered in switchkey table!"); dialog.ShowDialog(); }
public void CleanRubbishBin() { if (this.RubbishBin.ChildNodes.Count < 1) { return; } var customMessageDialog = new CustomMessageDialog( UiResources.ClearRubbishBin, AppMessages.CleanRubbishBinQuestion, App.AppInformation, MessageDialogButtons.OkCancel, MessageDialogImage.RubbishBin); customMessageDialog.OkOrYesButtonTapped += (sender, args) => { MegaSdk.cleanRubbishBin(new CleanRubbishBinRequestListener()); }; customMessageDialog.ShowDialog(); }
private async Task SaveOrEditAsync(Hotkey hotkey) { int result = CurrentProfile.AddOrEditHotkeyIfExisting(hotkey); if (result >= 0) { await _profileManager.SaveProfileAsync(CurrentProfile).ConfigureAwait(false); } switch (result) { case -1: CustomMessageDialog messageDialog = new CustomMessageDialog("No more hotkey is available"); messageDialog.ShowDialog(); break; case 0: await _eventAggregator.PublishOnUIThreadAsync(new HotkeyModifiedEvent { Hotkey = hotkey, ModifiedEvent = EHotkeyModifiedEvent.Modified }); break; case 1: await _eventAggregator.PublishOnUIThreadAsync(new HotkeyModifiedEvent { Hotkey = hotkey, ModifiedEvent = EHotkeyModifiedEvent.Added }); break; default: break; } }
public static void ShowDialogAsync(string msg, bool isModeDialog = false) { //var dialog = new MessageDialogView() //{ // Message = { Text = msg }, //}; CustomMessageDialog customMessageDialog = new CustomMessageDialog() { Message = { Text = msg }, }; //await DialogHost.Show(dialog, "rootDialog"); if (isModeDialog) { customMessageDialog.ShowDialog(); } else { customMessageDialog.Show(); } }
/// <summary> /// Returns if there is a network available and the user is online (logged in). /// <para>If there is not a network available, show the corresponding error message if enabled.</para> /// <para>If the user is not logged in, also Navigates to the "LoginPage".</para> /// </summary> /// <param name="showMessageDialog"> /// Boolean parameter to indicate if show error messages. /// <para>Default value is false.</para> /// </param> /// <returns>True if the user is online. False in other case.</returns> public bool IsUserOnline(bool showMessageDialog = false) { if (!NetworkService.IsNetworkAvailable(showMessageDialog)) { return(false); } bool isOnline = Convert.ToBoolean(App.MegaSdk.isLoggedIn()); if (!isOnline) { if (showMessageDialog) { OnUiThread(() => { var customMessageDialog = new CustomMessageDialog( AppMessages.UserNotOnline_Title, AppMessages.UserNotOnline, App.AppInformation, MessageDialogButtons.Ok); customMessageDialog.OkOrYesButtonTapped += (sender, args) => NavigateService.NavigateTo(typeof(LoginPage), NavigationParameter.Normal); customMessageDialog.ShowDialog(); }); } else { OnUiThread(() => NavigateService.NavigateTo(typeof(LoginPage), NavigationParameter.Normal)); } } return(isOnline); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); // Subscribe to the NetworkAvailabilityChanged event DeviceNetworkInformation.NetworkAvailabilityChanged += new EventHandler <NetworkNotificationEventArgs>(NetworkAvailabilityChanged); if (App.AppInformation.IsStartupModeActivate) { // Needed on every UI interaction SdkService.MegaSdkFolderLinks.retryPendingConnections(); if (!App.AppInformation.HasPinLockIntroduced && SettingsService.LoadSetting <bool>(SettingsResources.UserPinLockIsEnabled)) { NavigateService.NavigateTo(typeof(PasswordPage), NavigationParameter.Normal, this.GetType()); return; } App.AppInformation.IsStartupModeActivate = false; #if WINDOWS_PHONE_81 // Check to see if some folder has been picked var app = Application.Current as App; if (app != null && app.FolderPickerContinuationArgs != null) { FolderService.ContinueFolderOpenPicker(app.FolderPickerContinuationArgs, _folderLinkViewModel.FolderLink); } #endif } if (!NetworkService.IsNetworkAvailable()) { UpdateGUI(false); return; } // Initialize the application bar of this page SetApplicationBarData(); if (!App.LinkInformation.HasFetchedNodesFolderLink) { if (!String.IsNullOrWhiteSpace(App.LinkInformation.ActiveLink)) { SdkService.MegaSdkFolderLinks.loginToFolder(App.LinkInformation.ActiveLink, new LoginToFolderRequestListener(_folderLinkViewModel)); } else { var customMessageDialog = new CustomMessageDialog( AppMessages.AM_OpenLinkFailed_Title, AppMessages.AM_InvalidLink, App.AppInformation, MessageDialogButtons.Ok); customMessageDialog.OkOrYesButtonTapped += (sender, args) => CancelAction(); customMessageDialog.ShowDialog(); return; } } else { if (e.NavigationMode != NavigationMode.Back) { _folderLinkViewModel.LoadFolders(); if (App.LinkInformation.LinkAction == LinkAction.Download) { _folderLinkViewModel.FolderLink.MultipleDownload(App.LinkInformation.DownloadPath); } } } }
public override void onRequestFinish(MegaSDK api, MRequest request, MError e) { Deployment.Current.Dispatcher.BeginInvoke(() => { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]); ProgressService.SetProgressIndicator(false); this._confirmAccountViewModel.ControlState = true; if (request.getType() == MRequestType.TYPE_QUERY_SIGNUP_LINK) { switch (e.getErrorCode()) { case MErrorType.API_OK: // Valid and operative confirmation link if (request.getFlag()) // Auto confirmed account. { ShowErrorMesageAndNavigate(AppMessages.AlreadyConfirmedAccount_Title, AppMessages.AlreadyConfirmedAccount); break; } this._confirmAccountViewModel.Email = request.getEmail(); break; case MErrorType.API_ENOENT: // Already confirmed account ShowErrorMesageAndNavigate(AppMessages.AlreadyConfirmedAccount_Title, AppMessages.AlreadyConfirmedAccount); break; case MErrorType.API_EINCOMPLETE: // Incomplete confirmation link ShowErrorMesageAndNavigate(AppMessages.ConfirmAccountFailed_Title, AppMessages.AM_IncompleteConfirmationLink); break; case MErrorType.API_EGOINGOVERQUOTA: // Not enough quota case MErrorType.API_EOVERQUOTA: // Storage overquota error base.onRequestFinish(api, request, e); break; default: // Other error ShowDefaultErrorMessage(e); break; } } else if (request.getType() == MRequestType.TYPE_CONFIRM_ACCOUNT) { switch (e.getErrorCode()) { case MErrorType.API_OK: // Successfull confirmation process var customMessageDialog = new CustomMessageDialog( SuccessMessageTitle, SuccessMessage, App.AppInformation, MessageDialogButtons.Ok); customMessageDialog.OkOrYesButtonTapped += (sender, args) => OnSuccesAction(api, request); customMessageDialog.ShowDialog(); break; case MErrorType.API_ENOENT: // Wrong password case MErrorType.API_EKEY: // Wrong password new CustomMessageDialog( AppMessages.WrongPassword_Title, AppMessages.WrongPassword, App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); break; case MErrorType.API_EGOINGOVERQUOTA: // Not enough quota case MErrorType.API_EOVERQUOTA: // Storage overquota error base.onRequestFinish(api, request, e); break; default: // Other error ShowDefaultErrorMessage(e); break; } } }); }