WinForms

Form1.cs

using System;
using System.Windows.Forms;
using DotNetBrowser;
using DotNetBrowser.WinForms;

namespace PasswordSaveSample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            BrowserView browserView = new WinFormsBrowserView();
            Controls.Add((Control)browserView);

            browserView.Browser.PasswordManagerClient.PasswordSubmitted += PasswordManagerClient_PasswordSubmitted;
            browserView.Browser.PasswordManagerClient.UpdatePasswordSubmitted += PasswordManagerClient_UpdatePasswordSubmitted;
            browserView.Browser.LoadURL("gmail.com");
        }

        private void PasswordManagerClient_UpdatePasswordSubmitted(object sender, PasswordEventArgs e)
        {
            Form window = this;
            window.Invoke((Action)(() =>
            {
                DialogResult result = MessageBox.Show(window,
                    "Do you want to update password for " + e.Login + "?\nWebsite: " + e.Url,
                    "Update Password",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button2);

                switch (result)
                {
                    case DialogResult.Yes:
                        e.Action = SaveAction.Update;
                        break;
                }
            }));
        }

        private void PasswordManagerClient_PasswordSubmitted(object sender, PasswordEventArgs e)
        {
            Form window = this;
            window.Invoke((Action)(() =>
            {
                DialogResult result = MessageBox.Show(window,
                    "Do you want to save password for " + e.Login + "?\nWebsite: " + e.Url,
                    "Save Password",
                    MessageBoxButtons.YesNoCancel,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button3);

                switch (result)
                {
                    case DialogResult.Yes:
                        e.Action = SaveAction.Save;
                        break;
                    case DialogResult.No:
                        e.Action = SaveAction.Blacklist;
                        break;
                }
            }));
        }
    }
}


WPF

MainWindow.xaml

<Window x:Class="PasswordSaveSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wpf="clr-namespace:DotNetBrowser.WPF;assembly=DotNetBrowser"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <wpf:WPFBrowserView Name="BrowserView" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
    </Grid>
</Window>

MainWindow.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DotNetBrowser;

namespace PasswordSaveSample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            BrowserView.Browser.PasswordManagerClient.PasswordSubmitted += PasswordManagerClient_PasswordSubmitted;
            BrowserView.Browser.PasswordManagerClient.UpdatePasswordSubmitted += PasswordManagerClient_UpdatePasswordSubmitted;
            BrowserView.Browser.LoadURL("http://demo.hongkiat.com/html5-loginpage/index.html");
        }

        void PasswordManagerClient_PasswordSubmitted(object sender, PasswordEventArgs e)
        {
            var window = this;
            Application.Current.Dispatcher.Invoke(() =>
            {
                var result = MessageBox.Show(window,
                    "Do you want to save password for " + e.Login + "?\nWebsite: " + e.Url,
                    "Save Password",
                    MessageBoxButton.YesNoCancel,
                    MessageBoxImage.Question,
                    MessageBoxResult.Cancel);

                switch (result)
                {
                    case MessageBoxResult.Yes:
                        e.Action = SaveAction.Save;
                        break;
                    case MessageBoxResult.No:
                        e.Action = SaveAction.Blacklist;
                        break;
                }
            });
        }

        void PasswordManagerClient_UpdatePasswordSubmitted(object sender, PasswordEventArgs e)
        {
            var window = this;
            Application.Current.Dispatcher.Invoke(() =>
            {
                var result = MessageBox.Show(window,
                    "Do you want to update password for " + e.Login + "?\nWebsite: " + e.Url,
                    "Update Password",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Question,
                    MessageBoxResult.Cancel);

                switch (result)
                {
                    case MessageBoxResult.Yes:
                        e.Action = SaveAction.Update;
                        break;
                }
            });
        }

    }
}