Beispiel #1
0
        public NodeActionResult Rename()
        {
            // User must be online to perform this operation
            if (!IsUserOnline())
            {
                return(NodeActionResult.NotOnline);
            }

            // Only 1 CustomInputDialog should be open at the same time.
            if (this.AppInformation.PickerOrAsyncDialogIsOpen)
            {
                return(NodeActionResult.Cancelled);
            }

            var settings = new CustomInputDialogSettings()
            {
                DefaultText                = this.Name,
                SelectDefaultText          = true,
                IgnoreExtensionInSelection = true,
            };

            var inputDialog = new CustomInputDialog(UiResources.Rename, UiResources.RenameItem, this.AppInformation, settings);

            inputDialog.OkButtonTapped += (sender, args) =>
            {
                this.MegaSdk.renameNode(this.OriginalMNode, args.InputText, new RenameNodeRequestListener(this));
            };
            inputDialog.ShowDialog();

            return(NodeActionResult.IsBusy);
        }
Beispiel #2
0
        private void UpdateInfoThread()
        {
            UsersController   userController = new UsersController();
            CustomInputDialog inputdialog    = new CustomInputDialog("Type your current password", "Password", "");

            if (inputdialog.ShowDialog() == DialogResult.OK)
            {
                MainForm.session.Password = inputdialog.ResultText;
                if (userController.IsExist(MainForm.session))
                {
                    if (!string.IsNullOrEmpty(this.txtPassword.Text))
                    {
                        MainForm.session.Password = this.txtPassword.Text;
                    }
                    MainForm.session.Email    = this.txtEmail.Text;
                    MainForm.session.Fullname = this.txtFullName.Text;
                    userController.UpdateUser(ref MainForm.session);
                    CustomMessageBox.Show("User infomation updated", "Yay", CustomMessageBox.Buttons.OK, CustomMessageBox.Icon.Info);
                }
                else
                {
                    CustomMessageBox.Show("Incorrect password", "Yay", CustomMessageBox.Buttons.OK, CustomMessageBox.Icon.Info);
                }
            }
        }
Beispiel #3
0
        public Task <string> ShowCustomInput(string message, string title, int maxLength = 15)
        {
            var metroDialogSettings = new MetroDialogSettings
            {
                AffirmativeButtonText = "OK",
                NegativeButtonText    = "CANCEL",
                AnimateHide           = true,
                AnimateShow           = true,
                ColorScheme           = MetroDialogColorScheme.Accented
            };

            var dialog = new CustomInputDialog(View, metroDialogSettings)
            {
                Message        = message,
                Title          = title,
                Input          = metroDialogSettings.DefaultText,
                MaxInputLength = maxLength
            };

            return(InvokeOnCurrentDispatcher(() =>
            {
                View.ShowMetroDialogAsync(dialog, metroDialogSettings);

                return dialog.WaitForButtonPressAsync().ContinueWith(m =>
                {
                    InvokeOnCurrentDispatcher(() => View.HideMetroDialogAsync(dialog));
                    return m.Result;
                });
            }));
        }
Beispiel #4
0
        public void AddContact()
        {
            if (!IsUserOnline())
            {
                return;
            }

            // Only 1 CustomInputDialog should be open at the same time.
            if (this.AppInformation.PickerOrAsyncDialogIsOpen)
            {
                return;
            }

            var inputDialog = new CustomInputDialog(UiResources.AddContact, UiResources.CreateContact, this.AppInformation);

            inputDialog.OkButtonTapped += (sender, args) =>
            {
                if (String.IsNullOrWhiteSpace(args.InputText) || !ValidationService.IsValidEmail(args.InputText))
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        new CustomMessageDialog(
                            AppMessages.InviteContactAddFailed_Title.ToUpper(),
                            AppMessages.AM_IncorrectEmailFormat,
                            App.AppInformation,
                            MessageDialogButtons.Ok).ShowDialog();
                    });

                    return;
                }

                if (args.InputText.Equals(SdkService.MegaSdk.getMyEmail()))
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        new CustomMessageDialog(
                            AppMessages.InviteContactAddFailed_Title.ToUpper(),
                            AppMessages.InviteContactAddFailedOwnEmail,
                            App.AppInformation,
                            MessageDialogButtons.Ok).ShowDialog();
                    });

                    return;
                }

                MegaSdk.inviteContact(args.InputText, "", MContactRequestInviteActionType.INVITE_ACTION_ADD,
                                      new InviteContactRequestListener());
            };
            inputDialog.ShowDialog();
        }
        /// <summary>
        /// Show a message indicating that the introduced decryption key is not valid.
        /// <para>Also asks introduce the correct decryption key.</para>
        /// </summary>
        /// <param name="api">MegaSDK object that started the request</param>
        /// <param name="request">Information about the request.</param>
        protected void ShowDecryptionKeyNotValidAlert(MegaSDK api, MRequest request)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                var inputDialog = new CustomInputDialog(
                    AppMessages.AM_DecryptionKeyNotValid,
                    AppMessages.AM_DecryptionKeyAlertMessage,
                    App.AppInformation);

                inputDialog.OkButtonTapped += (sender, args) =>
                                              OpenLink(api, request, args.InputText);

                inputDialog.ShowDialog();
            });
        }
Beispiel #6
0
        public NodeActionResult Rename()
        {
            // User must be online to perform this operation
            if (!IsUserOnline())
            {
                return(NodeActionResult.NotOnline);
            }

            // Only 1 CustomInputDialog should be open at the same time.
            if (this.AppInformation.PickerOrAsyncDialogIsOpen)
            {
                return(NodeActionResult.Cancelled);
            }

            var settings = new CustomInputDialogSettings()
            {
                DefaultText                = this.Name,
                SelectDefaultText          = true,
                IgnoreExtensionInSelection = true,
            };

            var inputDialog = new CustomInputDialog(UiResources.Rename, UiResources.RenameItem, this.AppInformation, settings);

            inputDialog.OkButtonTapped += (sender, args) =>
            {
                if (SdkService.ExistsNodeByName(this.MegaSdk.getParentNode(this.OriginalMNode), args.InputText, this.OriginalMNode.isFolder()))
                {
                    inputDialog.HideDialog();
                    OnUiThread(() =>
                    {
                        new CustomMessageDialog(
                            AppMessages.RenameNodeFailed_Title,
                            this.OriginalMNode.isFolder() ? AppMessages.AM_FolderAlreadyExists : AppMessages.AM_FileAlreadyExists,
                            App.AppInformation,
                            MessageDialogButtons.Ok).ShowDialog();
                    });

                    return;
                }

                this.MegaSdk.renameNode(this.OriginalMNode, args.InputText, new RenameNodeRequestListener(this));
            };
            inputDialog.ShowDialog();

            return(NodeActionResult.IsBusy);
        }
        public void OpenLink()
        {
            if (!IsUserOnline())
            {
                return;
            }

            // Only 1 CustomInputDialog should be open at the same time.
            if (this.AppInformation.PickerOrAsyncDialogIsOpen)
            {
                return;
            }

            var inputDialog = new CustomInputDialog(UiResources.UI_OpenMegaLink, UiResources.UI_PasteMegaLink, this.AppInformation);

            inputDialog.OkButtonTapped += (sender, args) =>
            {
                if (!String.IsNullOrWhiteSpace(args.InputText))
                {
                    App.LinkInformation.ActiveLink = UriService.ReformatUri(args.InputText);

                    if (App.LinkInformation.ActiveLink.Contains("https://mega.nz/#!"))
                    {
                        App.LinkInformation.UriLink = UriLinkType.File;
                        this.MegaSdk.getPublicNode(App.LinkInformation.ActiveLink, new GetPublicNodeRequestListener(this));
                    }
                    else if (App.LinkInformation.ActiveLink.Contains("https://mega.nz/#F!"))
                    {
                        App.LinkInformation.UriLink = UriLinkType.Folder;
                        NavigateService.NavigateTo(typeof(FolderLinkPage), NavigationParameter.FolderLinkLaunch);
                    }
                    else
                    {
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            new CustomMessageDialog(
                                AppMessages.AM_OpenLinkFailed_Title,
                                AppMessages.AM_InvalidLink,
                                App.AppInformation,
                                MessageDialogButtons.Ok).ShowDialog();
                        });
                    }
                }
            };
            inputDialog.ShowDialog();
        }
        public void AddFolder()
        {
            if (!IsUserOnline())
            {
                return;
            }

            // Only 1 CustomInputDialog should be open at the same time.
            if (this.AppInformation.PickerOrAsyncDialogIsOpen)
            {
                return;
            }

            var inputDialog = new CustomInputDialog(UiResources.AddFolder, UiResources.UI_CreateFolder, this.AppInformation);

            inputDialog.OkButtonTapped += (sender, args) =>
            {
                if (this.FolderRootNode == null)
                {
                    OnUiThread(() =>
                    {
                        new CustomMessageDialog(
                            AppMessages.CreateFolderFailed_Title,
                            AppMessages.CreateFolderFailed,
                            App.AppInformation,
                            MessageDialogButtons.Ok).ShowDialog();
                    });

                    return;
                }

                this.MegaSdk.createFolder(args.InputText, this.FolderRootNode.OriginalMNode,
                                          new CreateFolderRequestListener());
            };
            inputDialog.ShowDialog();
        }