コード例 #1
0
        /// <summary>
        /// Add a new help file builder project to the reference link settings.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnAddFile_Click(object sender, EventArgs e)
        {
            ReferenceLinkSettings newItem;
            int idx = 0;

            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Title  = "Select the help file builder project(s)";
                dlg.Filter = "Sandcastle Help File Builder Project Files " +
                             "(*.shfbproj)|*.shfbproj|All Files (*.*)|*.*";
                dlg.InitialDirectory = Directory.GetCurrentDirectory();
                dlg.DefaultExt       = "shfbproj";
                dlg.Multiselect      = true;

                // If selected, add the file(s)
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    foreach (string file in dlg.FileNames)
                    {
                        newItem = new ReferenceLinkSettings();
                        newItem.HelpFileProject = new FilePath(file, project);

                        // It will end up on the last one added
                        idx = lbReferences.Items.Add(newItem);
                    }

                    pgProps.Enabled            = btnDelete.Enabled = true;
                    lbReferences.SelectedIndex = idx;
                }
            }
        }
コード例 #2
0
        //=====================================================================

        /// <summary>
        /// Create a reference link settings instance from an XPath navigator
        /// containing the settings.
        /// </summary>
        /// <param name="pathProvider">The base path provider object</param>
        /// <param name="navigator">The XPath navigator from which to
        /// obtain the settings.</param>
        /// <returns>A <see cref="ReferenceLinkSettings"/> object containing the
        /// settings from the XPath navigator.</returns>
        /// <remarks>It should contain an element called <c>target</c>
        /// with two attributes (<c>linkType</c> and <c>helpFileProject</c>).
        /// </remarks>
        public static ReferenceLinkSettings FromXPathNavigator(
            IBasePathProvider pathProvider, XPathNavigator navigator)
        {
            ReferenceLinkSettings rl = new ReferenceLinkSettings();

            if (navigator != null)
            {
                // Ignore if it's the older style
                if (navigator.GetAttribute("linkType", String.Empty).Length == 0)
                {
                    rl.HtmlSdkLinkType = (HtmlSdkLinkType)Enum.Parse(typeof(HtmlSdkLinkType), navigator.GetAttribute(
                                                                         "htmlSdkLinkType", String.Empty).Trim(), true);
                    rl.MSHelp2SdkLinkType = (MSHelp2SdkLinkType)Enum.Parse(typeof(MSHelp2SdkLinkType),
                                                                           navigator.GetAttribute("help2SdkLinkType", String.Empty).Trim(), true);
                    rl.MSHelpViewerSdkLinkType = (MSHelpViewerSdkLinkType)Enum.Parse(typeof(MSHelpViewerSdkLinkType),
                                                                                     navigator.GetAttribute("helpViewerSdkLinkType", String.Empty).Trim(), true);
                    rl.WebsiteSdkLinkType = (HtmlSdkLinkType)Enum.Parse(typeof(HtmlSdkLinkType), navigator.GetAttribute(
                                                                            "websiteSdkLinkType", String.Empty).Trim(), true);
                }

                rl.HelpFileProject = new FilePath(navigator.GetAttribute("helpFileProject", String.Empty).Trim(),
                                                  pathProvider);
            }

            return(rl);
        }
コード例 #3
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the build process.
        /// </summary>
        /// <param name="buildProcess">A reference to the current build process.</param>
        /// <param name="configuration">The configuration data that the plug-in should use to initialize
        /// itself.</param>
        /// <exception cref="BuilderException">This is thrown if the plug-in configuration is not valid.</exception>
        public void Initialize(BuildProcess buildProcess, XElement configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            builder    = buildProcess ?? throw new ArgumentNullException(nameof(buildProcess));
            otherLinks = new List <ReferenceLinkSettings>();

            var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
                typeof(HelpFileBuilderPlugInExportAttribute), false).First();

            builder.ReportProgress("{0} Version {1}\r\n{2}", metadata.Id, metadata.Version, metadata.Copyright);

            if (configuration.IsEmpty)
            {
                throw new BuilderException("ARL0001", "The Additional Reference Links plug-in has not been " +
                                           "configured yet");
            }

            // Load the reference links settings
            foreach (var t in configuration.Descendants("target"))
            {
                otherLinks.Add(ReferenceLinkSettings.FromXml(buildProcess.CurrentProject, t));
            }

            if (otherLinks.Count == 0)
            {
                throw new BuilderException("ARL0002", "At least one target is required for the Additional " +
                                           "Reference Links plug-in.");
            }
        }
コード例 #4
0
        /// <summary>
        /// Update the property grid with the selected item
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void lbReferences_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbReferences.SelectedItem != null)
            {
                ReferenceLinkSettings rl =
                    (ReferenceLinkSettings)lbReferences.SelectedItem;
                pgProps.SelectedObject = rl;
            }
            else
            {
                pgProps.SelectedObject = null;
            }

            pgProps.Refresh();
        }
コード例 #5
0
        /// <summary>
        /// Add a new help file builder project to the reference link settings.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnAddFile_Click(object sender, EventArgs e)
        {
            ReferenceLinkSettings newItem;
            int idx = 0;

            using(OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Title = "Select the help file builder project(s)";
                dlg.Filter = "Sandcastle Help File Builder Project Files " +
                    "(*.shfbproj)|*.shfbproj|All Files (*.*)|*.*";
                dlg.InitialDirectory = Directory.GetCurrentDirectory();
                dlg.DefaultExt = "shfbproj";
                dlg.Multiselect = true;

                // If selected, add the file(s)
                if(dlg.ShowDialog() == DialogResult.OK)
                {
                    foreach(string file in dlg.FileNames)
                    {
                        newItem = new ReferenceLinkSettings();
                        newItem.HelpFileProject = new FilePath(file, project);

                        // It will end up on the last one added
                        idx = lbReferences.Items.Add(newItem);
                    }

                    pgProps.Enabled = btnDelete.Enabled = true;
                    lbReferences.SelectedIndex = idx;
                }
            }
        }
コード例 #6
0
        //=====================================================================

        /// <summary>
        /// Create a reference link settings instance from an XPath navigator
        /// containing the settings.
        /// </summary>
        /// <param name="pathProvider">The base path provider object</param>
        /// <param name="navigator">The XPath navigator from which to
        /// obtain the settings.</param>
        /// <returns>A <see cref="ReferenceLinkSettings"/> object containing the
        /// settings from the XPath navigator.</returns>
        /// <remarks>It should contain an element called <c>target</c>
        /// with two attributes (<c>linkType</c> and <c>helpFileProject</c>).
        /// </remarks>
        public static ReferenceLinkSettings FromXPathNavigator(
          IBasePathProvider pathProvider, XPathNavigator navigator)
        {
            ReferenceLinkSettings rl = new ReferenceLinkSettings();

            if(navigator != null)
            {
                // Ignore if it's the older style
                if(navigator.GetAttribute("linkType", String.Empty).Length == 0)
                {
                    rl.HtmlSdkLinkType = (HtmlSdkLinkType)Enum.Parse(typeof(HtmlSdkLinkType), navigator.GetAttribute(
                        "htmlSdkLinkType", String.Empty).Trim(), true);
                    rl.MSHelpViewerSdkLinkType = (MSHelpViewerSdkLinkType)Enum.Parse(typeof(MSHelpViewerSdkLinkType),
                        navigator.GetAttribute("helpViewerSdkLinkType", String.Empty).Trim(), true);
                    rl.WebsiteSdkLinkType = (HtmlSdkLinkType)Enum.Parse(typeof(HtmlSdkLinkType), navigator.GetAttribute(
                        "websiteSdkLinkType", String.Empty).Trim(), true);
                }

                rl.HelpFileProject = new FilePath(navigator.GetAttribute("helpFileProject", String.Empty).Trim(),
                    pathProvider);
            }

            return rl;
        }