using System;
using DotNetBrowser;
using DotNetBrowser.Events;

namespace MyNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create Browser instance.
            Browser browser = BrowserFactory.Create();

            // Register custom DownloadHandler implementation.
            browser.DownloadHandler = new MyDownloadHandler();

            // Load URL that initiates file download process.
            browser.LoadURL(
                "http://cloud.teamdev.com/downloads/dotnetbrowser/dotnetbrowser-1.8.zip");

            // Dispose Browser instance.
            browser.Dispose();
        }

        public class MyDownloadHandler : DownloadHandler
        {
            public bool AllowDownload(DownloadItem download)
            {
                // Register Downlow Progress Event listener.
                download.DownloadEvent += delegate(object sender, DownloadEventArgs e)
                {
                    // Download is completed.
                    if (e.Item.Completed)
                    {
                        Console.Out.WriteLine("Download is completed!");
                    }
                };
                // Allow downloading file.
                return true;
            }
        }
    }
}