public AuthenticateForm()
        {
            InitializeComponent();
            _cmsUrl = ConfigurationManager.AppSettings["CmsUrl"];

            var lastUser = ((string)@settings.Default["last_iproove_user"]);

            if (string.IsNullOrEmpty(lastUser))
            {
                lastUser = "";
            }



            var iProoveUrl = ConfigurationManager.AppSettings["iProoveUrl"];

            _pageBody = File.ReadAllText("./iProovePage.html")
                        .Replace("%IPROOV_URL%", iProoveUrl)
                        .Replace("%LAST_IPROOV_USER%", lastUser);

            AutenticationBrowser.Hide();
            AutenticationBrowser.ObjectForScripting = this;

            this.FormClosing += OnClosing;
        }
        private void OnClosing(object sender, FormClosingEventArgs e)
        {
            @settings.Default.Save();

            AutenticationBrowser.Dispose();

            if (!_authenticationSubject.IsCompleted)
            {
                _authenticationSubject.OnNext(new AuthenticationResult(false));
                _authenticationSubject.OnCompleted();
            }
        }
        private void Authenticate_Load(object sender, EventArgs e)
        {
            AutenticationBrowser.Navigate(_cmsUrl);


            Observable.FromEventPattern(AutenticationBrowser, "DocumentCompleted")
            .ObserveOn(SynchronizationContext.Current)
            .Take(1)
            .Subscribe((t) =>
            {
                AutenticationBrowser.Document.Body.InnerHtml = _pageBody;

                AutenticationBrowser.Document.InvokeScript("eval", new object[] { File.ReadAllText("./JavaScript/OverrideConsoleLog.js") });
                AutenticationBrowser.Document.InvokeScript("eval", new object[] { File.ReadAllText("./JavaScript/RemoveHeaderTags.js") });
                AutenticationBrowser.Document.InvokeScript("eval", new object[] { File.ReadAllText("./JavaScript/SetUpiProoveMessaging.js") });

                AutenticationBrowser.Show();
            });
        }