private async void ShowPrompt(object sender, RoutedEventArgs e)
        {
            bool?result = await WindowFactory.Prompt("Delete item?").Show();

            if (result == true)
            {
                await WindowFactory.Alert("Item deleted.").Show();
            }
        }
        private async void ShowInput(object sender, RoutedEventArgs e)
        {
            StringSchema schema = new StringSchema {
                Name = "Name", IconKind = PackIconKind.Account
            };
            bool?result = await WindowFactory.FromSingleSchema("What is your name?", schema).Show();

            if (result == true)
            {
                string name = schema.Value;
                await WindowFactory.Alert($"Hello {name}!").Show();
            }
        }
Exemple #3
0
        public static async void ShowLogin(object nothing)
        {
            var window = new MaterialWindow(new MaterialDialog
            {
                Title = "Please log in to continue",
                Form  = new MaterialForm
                {
                    new StringSchema
                    {
                        Name       = "Username",
                        Key        = "user",
                        IconKind   = PackIconKind.Account,
                        Validation = Validators.IsNotEmpty
                    },
                    new PasswordSchema
                    {
                        Name     = "Password",
                        Key      = "pass",
                        IconKind = PackIconKind.Key
                    },
                    new BooleanSchema
                    {
                        Name       = "Remember me",
                        IsCheckBox = true
                    }
                },
                PositiveAction   = "LOG IN",
                OnPositiveAction = async session =>
                {
                    // Simulate asynchronous work
                    await Task.Delay(2000);
                    var userCorrect     = (string)session["user"] == "test";
                    var passwordCorrect = (string)session["pass"] == "123456";
                    if (userCorrect && passwordCorrect)
                    {
                        session.Close(true);
                    }
                    else
                    {
                        if (!userCorrect)
                        {
                            session.Invalidate("user", "This username does not exist.");
                        }
                        else
                        {
                            session.Invalidate("pass", "Invalid password.");
                        }
                    }
                },
                ShowsProgressOnPositiveAction = true
            });

            var result = await window.Show();

            if (result == true)
            {
                var formData = window.Dialog.Form.GetValuesList();
                await WindowFactory.Alert($"Username: {formData[0]}\nPassword: {formData[1]}\nRemember me: {formData[2]}", "Positive").Show();
            }
            else
            {
                await WindowFactory.Alert("Dialog dismissed", "Negative").Show();
            }
        }
 private async void ShowAlert(object sender, RoutedEventArgs e)
 {
     await WindowFactory.Alert("Hello World!").Show();
 }