/// <summary>
        /// This is used to determine the state of the help content and set the form options when a help viewer
        /// version is selected.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void cboHelpViewerVersion_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtInfo.Text = null;

            grpOptions.Enabled = rbInstall.Enabled = true;
            lastVersionSelected = cboHelpViewerVersion.SelectedIndex;

            // If there are substitution tags present, have a go at resolving them
            if(helpFilePath.IndexOf("{@", StringComparison.Ordinal) != -1)
            {
                try
                {
                    var bp = new SandcastleBuilder.Utils.BuildEngine.BuildProcess(project);
                    helpFilePath = bp.SubstitutionTags.TransformText(helpFilePath);
                    setupFile = Path.ChangeExtension(helpFilePath, ".msha");
                }
                catch
                {
                    // Ignore errors
                    txtInfo.AppendText("The help filename appears to contain substitution tags but they could " +
                        "not be resolved to determine the actual file to use for installation.  Building " +
                        "website output and viewing it can be used to work around this issue.\r\n\r\n");
                    rbInstall.Enabled = false;
                }
            }

            if(rbInstall.Enabled && (!File.Exists(helpFilePath) || !File.Exists(setupFile)))
            {
                txtInfo.AppendText("A copy of the help file does not appear to exist yet.  It may need to be built.\r\n\r\n");
                rbInstall.Enabled = false;
            }

            try
            {
                viewerVersion = new Version((string)cboHelpViewerVersion.SelectedItem);

                HelpLibraryManager hlm = new HelpLibraryManager(viewerVersion);

                // Can't do anything if the Help Library Manager is not installed
                if(hlm.HelpLibraryManagerPath == null)
                    throw new HelpLibraryManagerException(viewerVersion,
                        HelpLibraryManagerException.HelpLibraryManagerNotFound);

                // Can't do anything if the Help Library Manager is already running
                if(Process.GetProcessesByName(Path.GetFileNameWithoutExtension(hlm.HelpLibraryManagerPath)).Length > 0)
                    throw new HelpLibraryManagerException(viewerVersion,
                        HelpLibraryManagerException.HelpLibraryManagerAlreadyRunning);

                // Can't do anything if the local store is not initialized
                if(!hlm.LocalStoreInitialized)
                    throw new HelpLibraryManagerException(viewerVersion,
                        HelpLibraryManagerException.LocalStoreNotInitialized);

                if(hlm.HelpContentFileInstalled(helpFilePath))
                    rbOpenCurrent.Enabled = rbRemove.Enabled = true;
                else
                {
                    txtInfo.AppendText("The help file does not appear to be installed yet.\r\n");
                    rbOpenCurrent.Enabled = rbRemove.Enabled = false;
                }
            }
            catch(Exception ex)
            {
                txtInfo.AppendText("Problem: " + ex.Message + "\r\n");
                rbOpenCurrent.Enabled = rbRemove.Enabled = false;
            }

            if(rbOpenCurrent.Enabled)
                rbOpenCurrent.Checked = true;
            else
                if(rbInstall.Enabled)
                    rbInstall.Checked = true;
                else
                    rbLaunchContentManager.Checked = true;

            if(!rbOpenCurrent.Enabled && !rbInstall.Enabled && !rbRemove.Enabled)
                txtInfo.AppendText("\r\nNo action can be taken with the help content.");

            // Determine the catalog name here as it's used in a lot of places and varies by version if not
            // defined in the project.
            catalogName = !String.IsNullOrWhiteSpace(project.CatalogName) ? project.CatalogName :
                HelpLibraryManager.DefaultCatalogName(viewerVersion);

            // If it looks like a default value, warn the user if it doesn't match.  It may need to be cleared.
            if(!String.IsNullOrWhiteSpace(project.CatalogName) && project.CatalogName.StartsWith("VisualStudio",
              StringComparison.Ordinal) && project.CatalogName != HelpLibraryManager.DefaultCatalogName(viewerVersion))
                txtInfo.AppendText("\r\n\r\nWARNING:  The project's catalog name property is set to '" +
                    project.CatalogName + "' which does not match the default catalog name for the selected " +
                    "version of the help viewer.  If necessary, clear the catalog name property value.");
        }
        /// <summary>
        /// This is used to determine the state of the help content and set the form options when a help viewer
        /// version is selected.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void cboHelpViewerVersion_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtInfo.Text = null;

            grpOptions.Enabled  = rbInstall.Enabled = true;
            lastVersionSelected = cboHelpViewerVersion.SelectedIndex;

            // If there are substitution tags present, have a go at resolving them
            if (helpFilePath.IndexOf("{@", StringComparison.Ordinal) != -1)
            {
                try
                {
                    var bp = new SandcastleBuilder.Utils.BuildEngine.BuildProcess(project);
                    helpFilePath = bp.TransformText(helpFilePath);
                    setupFile    = Path.ChangeExtension(helpFilePath, ".msha");
                }
                catch
                {
                    // Ignore errors
                    txtInfo.AppendText("The help filename appears to contain substitution tags but they could " +
                                       "not be resolved to determine the actual file to use for installation.  Building " +
                                       "website output and viewing it can be used to work around this issue.\r\n\r\n");
                    rbInstall.Enabled = false;
                }
            }

            if (rbInstall.Enabled && (!File.Exists(helpFilePath) || !File.Exists(setupFile)))
            {
                txtInfo.AppendText("A copy of the help file does not appear to exist yet.  It may need to be built.\r\n\r\n");
                rbInstall.Enabled = false;
            }

            try
            {
                viewerVersion = new Version((string)cboHelpViewerVersion.SelectedItem);

                HelpLibraryManager hlm = new HelpLibraryManager(viewerVersion);

                // Can't do anything if the Help Library Manager is not installed
                if (hlm.HelpLibraryManagerPath == null)
                {
                    throw new HelpLibraryManagerException(viewerVersion,
                                                          HelpLibraryManagerException.HelpLibraryManagerNotFound);
                }

                // Can't do anything if the Help Library Manager is already running
                if (Process.GetProcessesByName(Path.GetFileNameWithoutExtension(hlm.HelpLibraryManagerPath)).Length > 0)
                {
                    throw new HelpLibraryManagerException(viewerVersion,
                                                          HelpLibraryManagerException.HelpLibraryManagerAlreadyRunning);
                }

                // Can't do anything if the local store is not initialized
                if (!hlm.LocalStoreInitialized)
                {
                    throw new HelpLibraryManagerException(viewerVersion,
                                                          HelpLibraryManagerException.LocalStoreNotInitialized);
                }

                if (hlm.HelpContentFileInstalled(helpFilePath))
                {
                    rbOpenCurrent.Enabled = rbRemove.Enabled = true;
                }
                else
                {
                    txtInfo.AppendText("The help file does not appear to be installed yet.\r\n");
                    rbOpenCurrent.Enabled = rbRemove.Enabled = false;
                }

                if (rbOpenCurrent.Enabled)
                {
                    rbOpenCurrent.Checked = true;
                }
                else
                if (rbInstall.Enabled)
                {
                    rbInstall.Checked = true;
                }

                btnOK.Enabled = (rbOpenCurrent.Enabled || rbInstall.Enabled || rbRemove.Enabled);
            }
            catch (Exception ex)
            {
                txtInfo.AppendText("Problem: " + ex.Message + "\r\n");
                btnOK.Enabled = false;
            }

            if (!btnOK.Enabled)
            {
                txtInfo.AppendText("\r\nNo action can be taken.");
            }
        }
        /// <summary>
        /// This is used to determine the state of the help content and set
        /// the form options.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void LaunchMSHelpViewerDlg_Load(object sender, EventArgs e)
        {
            if(!File.Exists(helpFilePath) || !File.Exists(setupFile))
            {
                txtInfo.AppendText("A copy of the help file does not appear to exist yet.  It may need to be built.\r\n");
                rbInstall.Enabled = false;
            }

            try
            {
                HelpLibraryManager hlm = new HelpLibraryManager();

                // Can't do anything if the Help Library Manager is not installed
                if(hlm.HelpLibraryManagerPath == null)
                    throw new HelpLibraryManagerException(HelpLibraryManagerException.HelpLibraryManagerNotFound);

                // Can't do anything if the Help Library Manager is already running
                if(Process.GetProcessesByName(Path.GetFileNameWithoutExtension(hlm.HelpLibraryManagerPath)).Length > 0)
                    throw new HelpLibraryManagerException(HelpLibraryManagerException.HelpLibraryManagerAlreadyRunning);

                // Can't do anything if the local store is not initialized
                if(!hlm.LocalStoreInitialized)
                    throw new HelpLibraryManagerException(HelpLibraryManagerException.LocalStoreNotInitialized);

                if(!hlm.HelpContentFileInstalled(helpFilePath))
                {
                    txtInfo.AppendText("The help file does not appear to be installed yet.\r\n");
                    rbOpenCurrent.Enabled = rbRemove.Enabled = false;
                }

                grpOptions.Enabled = true;
                btnOK.Enabled = (rbOpenCurrent.Enabled || rbInstall.Enabled || rbRemove.Enabled);
            }
            catch(Exception ex)
            {
                txtInfo.AppendText("Problem: " + ex.Message + "\r\n");
            }

            if(!btnOK.Enabled)
                txtInfo.AppendText("\r\nNo action can be taken.");
        }
Example #4
0
        /// <summary>
        /// This is used to determine the state of the help content and set the form options when a help viewer
        /// version is selected.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void cboHelpViewerVersion_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtInfo.Text = null;

            grpOptions.Enabled  = rbInstall.Enabled = true;
            lastVersionSelected = cboHelpViewerVersion.SelectedIndex;

            // If there are substitution tags present, have a go at resolving them
            if (helpFilePath.IndexOf("{@", StringComparison.Ordinal) != -1)
            {
                try
                {
                    var bp = new BuildProcess(project);
                    helpFilePath = bp.SubstitutionTags.TransformText(helpFilePath);
                    setupFile    = Path.ChangeExtension(helpFilePath, ".msha");
                }
                catch
                {
                    // Ignore errors
                    txtInfo.AppendText("The help filename appears to contain substitution tags but they could " +
                                       "not be resolved to determine the actual file to use for installation.  Building " +
                                       "website output and viewing it can be used to work around this issue.\r\n\r\n");
                    rbInstall.Enabled = false;
                }
            }

            if (rbInstall.Enabled && (!File.Exists(helpFilePath) || !File.Exists(setupFile)))
            {
                txtInfo.AppendText("A copy of the help file does not appear to exist yet.  It may need to be built.\r\n\r\n");
                rbInstall.Enabled = false;
            }

            try
            {
                viewerVersion = new Version((string)cboHelpViewerVersion.SelectedItem);

                HelpLibraryManager hlm = new HelpLibraryManager(viewerVersion);

                // Can't do anything if the Help Library Manager is not installed
                if (hlm.HelpLibraryManagerPath == null)
                {
                    throw new HelpLibraryManagerException(viewerVersion,
                                                          HelpLibraryManagerException.HelpLibraryManagerNotFound);
                }

                // Can't do anything if the Help Library Manager is already running
                if (Process.GetProcessesByName(Path.GetFileNameWithoutExtension(hlm.HelpLibraryManagerPath)).Length > 0)
                {
                    throw new HelpLibraryManagerException(viewerVersion,
                                                          HelpLibraryManagerException.HelpLibraryManagerAlreadyRunning);
                }

                // Can't do anything if the local store is not initialized
                if (!hlm.LocalStoreInitialized)
                {
                    throw new HelpLibraryManagerException(viewerVersion,
                                                          HelpLibraryManagerException.LocalStoreNotInitialized);
                }

                if (hlm.HelpContentFileInstalled(helpFilePath))
                {
                    rbOpenCurrent.Enabled = rbRemove.Enabled = true;
                }
                else
                {
                    txtInfo.AppendText("The help file does not appear to be installed yet.\r\n");
                    rbOpenCurrent.Enabled = rbRemove.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                txtInfo.AppendText("Problem: " + ex.Message + "\r\n");
                rbOpenCurrent.Enabled = rbRemove.Enabled = false;
            }

            if (rbOpenCurrent.Enabled)
            {
                rbOpenCurrent.Checked = true;
            }
            else
            if (rbInstall.Enabled)
            {
                rbInstall.Checked = true;
            }
            else
            {
                rbLaunchContentManager.Checked = true;
            }

            if (!rbOpenCurrent.Enabled && !rbInstall.Enabled && !rbRemove.Enabled)
            {
                txtInfo.AppendText("\r\nNo action can be taken with the help content.");
            }

            // Determine the catalog name here as it's used in a lot of places and varies by version if not
            // defined in the project.
            catalogName = !String.IsNullOrWhiteSpace(project.CatalogName) ? project.CatalogName :
                          HelpLibraryManager.DefaultCatalogName(viewerVersion);

            // If it looks like a default value, warn the user if it doesn't match.  It may need to be cleared.
            if (!String.IsNullOrWhiteSpace(project.CatalogName) && project.CatalogName.StartsWith("VisualStudio",
                                                                                                  StringComparison.Ordinal) && project.CatalogName != HelpLibraryManager.DefaultCatalogName(viewerVersion))
            {
                txtInfo.AppendText("\r\n\r\nWARNING:  The project's catalog name property is set to '" +
                                   project.CatalogName + "' which does not match the default catalog name for the selected " +
                                   "version of the help viewer.  If necessary, clear the catalog name property value.");
            }
        }
        /// <summary>
        /// This is used to determine the state of the help content and set the form options when a help viewer
        /// version is selected.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void cboHelpViewerVersion_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtInfo.Text = null;

            grpOptions.Enabled = rbInstall.Enabled = true;
            lastVersionSelected = cboHelpViewerVersion.SelectedIndex;

            // If there are substitution tags present, have a go at resolving them
            if(helpFilePath.IndexOf("{@", StringComparison.Ordinal) != -1)
            {
                try
                {
                    var bp = new SandcastleBuilder.Utils.BuildEngine.BuildProcess(project);
                    helpFilePath = bp.TransformText(helpFilePath);
                    setupFile = Path.ChangeExtension(helpFilePath, ".msha");
                }
                catch
                {
                    // Ignore errors
                    txtInfo.AppendText("The help filename appears to contain substitution tags but they could " +
                        "not be resolved to determine the actual file to use for installation.  Building " +
                        "website output and viewing it can be used to work around this issue.\r\n\r\n");
                    rbInstall.Enabled = false;
                }
            }

            if(rbInstall.Enabled && (!File.Exists(helpFilePath) || !File.Exists(setupFile)))
            {
                txtInfo.AppendText("A copy of the help file does not appear to exist yet.  It may need to be built.\r\n\r\n");
                rbInstall.Enabled = false;
            }

            try
            {
                viewerVersion = new Version((string)cboHelpViewerVersion.SelectedItem);

                HelpLibraryManager hlm = new HelpLibraryManager(viewerVersion);

                // Can't do anything if the Help Library Manager is not installed
                if(hlm.HelpLibraryManagerPath == null)
                    throw new HelpLibraryManagerException(viewerVersion,
                        HelpLibraryManagerException.HelpLibraryManagerNotFound);

                // Can't do anything if the Help Library Manager is already running
                if(Process.GetProcessesByName(Path.GetFileNameWithoutExtension(hlm.HelpLibraryManagerPath)).Length > 0)
                    throw new HelpLibraryManagerException(viewerVersion,
                        HelpLibraryManagerException.HelpLibraryManagerAlreadyRunning);

                // Can't do anything if the local store is not initialized
                if(!hlm.LocalStoreInitialized)
                    throw new HelpLibraryManagerException(viewerVersion,
                        HelpLibraryManagerException.LocalStoreNotInitialized);

                if(hlm.HelpContentFileInstalled(helpFilePath))
                    rbOpenCurrent.Enabled = rbRemove.Enabled = true;
                else
                {
                    txtInfo.AppendText("The help file does not appear to be installed yet.\r\n");
                    rbOpenCurrent.Enabled = rbRemove.Enabled = false;
                }

                if(rbOpenCurrent.Enabled)
                    rbOpenCurrent.Checked = true;
                else
                    if(rbInstall.Enabled)
                        rbInstall.Checked = true;

                btnOK.Enabled = (rbOpenCurrent.Enabled || rbInstall.Enabled || rbRemove.Enabled);
            }
            catch(Exception ex)
            {
                txtInfo.AppendText("Problem: " + ex.Message + "\r\n");
                btnOK.Enabled = false;
            }

            if(!btnOK.Enabled)
                txtInfo.AppendText("\r\nNo action can be taken.");
        }