/// <summary>
        /// This is overridden to validate the option values
        /// </summary>
        /// <param name="e">The event arguments</param>
        protected override void OnDeactivate(CancelEventArgs e)
        {
            base.OnDeactivate(e);

            if (!e.Cancel && control != null)
            {
                e.Cancel = !control.IsValid;

                // We must apply changes here if valid or they don't stick
                if (!e.Cancel)
                {
                    this.MSHelpViewerPath            = control.MSHelpViewerPath;
                    this.AspNetDevelopmentServerPort = control.AspNetDevelopmentServerPort;
                    this.VerboseLogging             = control.VerboseLogging;
                    this.OpenLogViewerOnFailedBuild = control.OpenLogViewerOnFailedBuild;
                    this.OpenHelpAfterBuild         = control.OpenHelpAfterBuild;
                    this.UseExternalWebBrowser      = control.UseExternalWebBrowser;

                    // MEF provider options are stored separately to avoid loading the entire package just to
                    // access these options.
                    var mefOptions = new MefProviderOptions(this.Site);

                    mefOptions.EnableExtendedXmlCommentsCompletion = control.EnableExtendedXmlCommentsCompletion;
                    mefOptions.EnableGoToDefinition          = control.EnableGoToDefinition;
                    mefOptions.EnableCtrlClickGoToDefinition = control.EnableCtrlClickGoToDefinition;
                    mefOptions.EnableGoToDefinitionInCRef    = control.EnableGoToDefinitionInCRef;

                    mefOptions.SaveConfiguration();
                }
                ;
            }
        }
        /// <summary>
        /// This is called by the owning dialog page to validate the values and apply changes to the properties
        /// </summary>
        /// <param name="optionsPage">The options page</param>
        public void ApplyChanges(SandcastleBuilderOptionsPage optionsPage)
        {
            if (this.IsValid)
            {
                optionsPage.HxsViewerPath               = txtHxSViewerPath.Text;
                optionsPage.MSHelpViewerPath            = txtMSHelpViewerPath.Text;
                optionsPage.AspNetDevelopmentServerPort = (int)udcASPNetDevServerPort.Value;
                optionsPage.VerboseLogging              = chkVerboseLogging.Checked;
                optionsPage.OpenLogViewerOnFailedBuild  = chkOpenLogViewerOnFailure.Checked;
                optionsPage.OpenHelpAfterBuild          = chkOpenHelpAfterBuild.Checked;
                optionsPage.UseExternalWebBrowser       = chkUseExternalBrowser.Checked;

                // MEF provider options are stored separately to avoid loading the entire package just to access
                // these options.
                MefProviderOptions mefProviderOptions = GetMefProviderOptions(optionsPage.Site);
                mefProviderOptions.EnableExtendedXmlCommentsCompletion = chkEnableExtendedXmlComments.Checked;
                mefProviderOptions.EnableGoToDefinition       = chkEnableGoToDefinition.Checked;
                mefProviderOptions.EnableGoToDefinitionInCRef = chkEnableGoToDefinitionInCRef.Checked;

                mefProviderOptions.SaveConfiguration();
            }
        }
        /// <summary>
        /// This is called by the owning dialog page to validate the values and apply changes to the properties
        /// </summary>
        /// <param name="optionsPage">The options page</param>
        public void ApplyChanges(SandcastleBuilderOptionsPage optionsPage)
        {
            if(this.IsValid)
            {
                optionsPage.MSHelpViewerPath = txtMSHelpViewerPath.Text;
                optionsPage.AspNetDevelopmentServerPort = (int)udcASPNetDevServerPort.Value;
                optionsPage.VerboseLogging = chkVerboseLogging.Checked;
                optionsPage.OpenLogViewerOnFailedBuild = chkOpenLogViewerOnFailure.Checked;
                optionsPage.OpenHelpAfterBuild = chkOpenHelpAfterBuild.Checked;
                optionsPage.UseExternalWebBrowser = chkUseExternalBrowser.Checked;

                // MEF provider options are stored separately to avoid loading the entire package just to access
                // these options.
                var mefOptions = new MefProviderOptions(optionsPage.Site);

                mefOptions.EnableExtendedXmlCommentsCompletion = chkEnableExtendedXmlComments.Checked;
                mefOptions.EnableGoToDefinition = chkEnableGoToDefinition.Checked;
                mefOptions.EnableCtrlClickGoToDefinition = chkEnableCtrlClickGoToDefinition.Checked;
                mefOptions.EnableGoToDefinitionInCRef = chkEnableGoToDefinitionInCRef.Checked;

                mefOptions.SaveConfiguration();
            }
        }