/// <summary>
 /// If None is selected, it will select No and close the pop up.
 /// </summary>
 /// <param name="buttonToPush"></param>
 public ReplaceFormAlertHandler(ReplaceFormAlertHandler.Buttons buttonToPush)
 {
     if (buttonToPush != Buttons.None)
     {
         this._buttonToPush = buttonToPush;
     }
     else
     {
         this._buttonToPush = Buttons.KeepForm;
     }
 }
        /// <summary>
        /// Creates the new infopath and load form.
        /// </summary>
        /// <param name="FormUri">The form URI.</param>
        /// <param name="InfoPathLoginHandler">The info path login handler.</param>
        /// <param name="readOnly">if set to <c>true</c> [read only].</param>
        private void CreateNewInfopathAndLoadForm(string FormUri, LogonDialogHandler InfoPathLoginHandler, bool readOnly)
        {
            // Kill off any existing infopath processes
            foreach (Process proc in Process.GetProcessesByName("infopath"))
            {
                proc.Kill();
            }

            InitInfopathAndStartDialogWatcher(new Application());
            SecurityAlertHandler securityHandler = new SecurityAlertHandler();
            ReplaceFormAlertHandler replaceFormHandler = new ReplaceFormAlertHandler();
            DialogWatcher.Add(securityHandler);
            DialogWatcher.Add(replaceFormHandler);
            if (InfoPathLoginHandler != null)
            {
                // remove other logon dialog handlers since only one handler
                // can effectively handle the logon dialog.
                DialogWatcher.RemoveAll(new LogonDialogHandler("a", "b"));

                // Add the (new) logonHandler
                DialogWatcher.Add(InfoPathLoginHandler);
            }
            if (readOnly)
            {
                InternalInfopathXDocument = InfopathApplicationTester.XDocuments.Open(FormUri, (int)XdDocumentVersionMode.xdCanOpenInReadOnlyMode);
            }
            else
            {
                InternalInfopathXDocument = InfopathApplicationTester.XDocuments.Open(FormUri, (int)XdDocumentVersionMode.xdFailOnVersionOlder);
            }

            InternalInfopathXMLDOMDocument = InternalInfopathXDocument.DOM as IXMLDOMDocument2;
            InternalHTMLDOMDocument = IEDom.IEDOMFromhWnd(this.hWnd);
        }