Esempio n. 1
0
        protected async void GeneratePasswordCommandHandler(object p)
        {
            // Get data context
            var field = p as FieldModel;
            // Prompt only if there is something in the field
            var prompt = !string.IsNullOrWhiteSpace(field.Value);
            // If we don't need to prompt, then show the dialog
            var result = !prompt;

            // Prompt only if we need to
            if (prompt)
            {
                await DialogHelper.Confirm(
                    "This will replace your existing password with a new one. Are you sure?",
                    (c) => { result = true; });
            }

            // If the result is true, then show the dialog
            if (result)
            {
                // Show the add field dialog
                var d = new PasswordGeneratorDialog();

                // Show the dialog
                var action = await d.ShowAsync();

                if (action == ContentDialogResult.Primary)
                {
                    // Set the password field to the new value
                    field.Value = (d.DataContext as PasswordGeneratorDialogViewModel)?.Password;
                }
            }
        }
Esempio n. 2
0
 private async Task ExecuteGeneratePasswordCommandAsync(object parameter, CancellationToken cancellationToken)
 {
     await TaskHelper.RunOnUIThreadAsync(async() =>
     {
         var passwordGeneratorDialog = new PasswordGeneratorDialog();
         await passwordGeneratorDialog.ShowAsync();
     }).ConfigureAwait(false);
 }