示例#1
0
        //=====================================================================

        /// <summary>
        /// Parse the topic and its sub-topic files to extract the information for conversion
        /// </summary>
        /// <param name="fileParser">The file parser</param>
        /// <param name="imageDictionary">The image dictionary</param>
        public void ParseFile(FileParser fileParser, Dictionary <FilePath, ImageReference> imageDictionary)
        {
            if (sourceFile != null && !String.IsNullOrEmpty(sourceFile.Path))
            {
                fileParser.ParseFile(sourceFile);

                if (fileParser.TopicId != Guid.Empty)
                {
                    id = fileParser.TopicId;
                }

                if (!String.IsNullOrEmpty(fileParser.RevisionNumber))
                {
                    revisionNumber = fileParser.RevisionNumber;
                }

                title          = fileParser.Title;
                topicAbstract  = fileParser.TopicAbstract;
                body           = fileParser.Body;
                tocExclude     = fileParser.TocExclude;
                defaultTopic   = fileParser.IsDefaultTopic;
                splitToc       = fileParser.SplitToc;
                sortOrder      = fileParser.SortOrder;
                helpAttributes = fileParser.HelpAttributes;
                helpKeywords   = fileParser.HelpKeywords;
            }

            subtopics.ParseFiles(fileParser, imageDictionary);
        }
示例#2
0
文件: Topic.cs 项目: wholroyd/SHFB
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        public Topic()
        {
            contentId      = Guid.NewGuid().ToString();
            subtopics      = new TopicCollection(null);
            helpAttributes = new MSHelpAttrCollection(null);
            keywords       = new MSHelpKeywordCollection();
            this.Visible   = true;

            subtopics.ListChanged      += childList_ListChanged;
            helpAttributes.ListChanged += childList_ListChanged;
            keywords.ListChanged       += childList_ListChanged;
        }
        //=====================================================================
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="currentAttributes">The item collection to edit</param>
        /// <param name="isTopic">If true, the Default button is hidden as
        /// topics don't need to include the default attributes.  They are
        /// added automatically at build time.</param>
        public MSHelpAttrEditorDlg(MSHelpAttrCollection currentAttributes,
          bool isTopic)
        {
            InitializeComponent();

            if(isTopic)
                btnDefault.Visible = false;

            attributes = currentAttributes;
            dgvAttributes.AutoGenerateColumns = false;
            dgvAttributes.DataSource = attributes;
        }
示例#4
0
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="currentAttributes">The item collection to edit</param>
        /// <param name="isTopic">If true, the Default button is hidden as
        /// topics don't need to include the default attributes.  They are
        /// added automatically at build time.</param>
        public MSHelpAttrEditorDlg(MSHelpAttrCollection currentAttributes,
                                   bool isTopic)
        {
            InitializeComponent();

            if (isTopic)
            {
                btnDefault.Visible = false;
            }

            attributes = currentAttributes;
            dgvAttributes.AutoGenerateColumns = false;
            dgvAttributes.DataSource          = attributes;
        }
示例#5
0
        //=====================================================================
        /// <summary>
        /// Constructor
        /// </summary>
        public Topic()
        {
            contentId = Guid.NewGuid().ToString();
            subtopics = new TopicCollection(null);
            helpAttributes = new MSHelpAttrCollection(null);
            keywords = new MSHelpKeywordCollection();
            this.Visible = true;

            subtopics.ListChanged += new ListChangedEventHandler(
                childList_ListChanged);
            helpAttributes.ListChanged += new ListChangedEventHandler(
                childList_ListChanged);
            keywords.ListChanged += new ListChangedEventHandler(
                childList_ListChanged);
        }
示例#6
0
        /// <inheritdoc />
        public override object ConvertTo(ITypeDescriptorContext context,
                                         CultureInfo culture, object value, Type destinationType)
        {
            MSHelpAttrCollection items = value as MSHelpAttrCollection;

            if (items == null || destinationType != typeof(string))
            {
                return(base.ConvertTo(context, culture, value, destinationType));
            }

            if (items.Count == 0)
            {
                return("(None)");
            }

            return(String.Format(culture, "{0} attribute(s)", items.Count));
        }
示例#7
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context,
                                         IServiceProvider provider, object value)
        {
            // Get the help attribute item collection
            MSHelpAttrCollection items = value as MSHelpAttrCollection;

            if (context == null || provider == null || context.Instance == null ||
                items == null)
            {
                return(base.EditValue(context, provider, value));
            }

            bool isTopic = (context.Instance.GetType() == typeof(Topic));

            using (MSHelpAttrEditorDlg dlg = new MSHelpAttrEditorDlg(items,
                                                                     isTopic))
            {
                dlg.ShowDialog();
            }

            return(value);
        }
        /// <inheritdoc />
        protected override bool BindControlValue(System.Windows.Forms.Control control)
        {
            ProjectProperty projProp;

#if !STANDALONEGUI
            if (this.ProjectMgr == null)
            {
                return(false);
            }
#else
            if (this.CurrentProject == null)
            {
                return(false);
            }
#endif
            if (control.Name == "dgvHelpAttributes")
            {
                attributesChanged = false;

#if !STANDALONEGUI
                attributes = new MSHelpAttrCollection(
                    ((SandcastleBuilderProjectNode)base.ProjectMgr).SandcastleProject);
                projProp = this.ProjectMgr.BuildProject.GetProperty("HelpAttributes");
#else
                attributes = new MSHelpAttrCollection(this.CurrentProject);
                projProp   = this.CurrentProject.MSBuildProject.GetProperty("HelpAttributes");
#endif
                if (projProp != null && !String.IsNullOrEmpty(projProp.UnevaluatedValue))
                {
                    attributes.FromXml(projProp.UnevaluatedValue);
                }

                dgvHelpAttributes.DataSource = attributes;
                return(true);
            }

            return(false);
        }
        //=====================================================================

        /// <summary>
        /// Parse the specified HTML file
        /// </summary>
        /// <param name="filename">The file to parse</param>
        /// <remarks>After parsing, the properties can be used to retrieve the information parsed from
        /// the file.</remarks>
        public void ParseFile(string filename)
        {
            Match    m;
            Encoding enc     = Encoding.Default;
            string   content = ReadWithEncoding(filename, ref enc);

            helpAttributes = new MSHelpAttrCollection();
            helpKeywords   = new MSHelpKeywordCollection();
            topicId        = Guid.Empty;
            title          = body = topicAbstract = null;
            revisionNumber = "1";
            tocExclude     = defaultTopic = splitToc = false;
            sortOrder      = Int32.MaxValue;

            m = reTopicId.Match(content);

            if (m.Success)
            {
                Guid.TryParse(HttpUtility.HtmlDecode(m.Groups[1].Value), out topicId);
            }

            m = reRevisionNumber.Match(content);

            if (m.Success)
            {
                revisionNumber = HttpUtility.HtmlDecode(m.Groups[1].Value);
            }

            m = reTitle.Match(content);

            if (m.Success)
            {
                title = HttpUtility.HtmlDecode(m.Groups[1].Value);
            }

            tocExclude   = reTocExclude.IsMatch(content);
            defaultTopic = reIsDefaultTopic.IsMatch(content);
            splitToc     = reSplitToc.IsMatch(content);

            m = reSortOrder.Match(content);

            if (m.Success)
            {
                sortOrder = Convert.ToInt32(m.Groups["SortOrder"].Value, CultureInfo.InvariantCulture);
            }

            m = reBody.Match(content);

            if (m.Success)
            {
                body = m.Groups["Body"].Value;
            }

            foreach (Match attr in reMSHelpAttr.Matches(content))
            {
                if (attr.Groups["Name"].Value == "Abstract")
                {
                    topicAbstract = attr.Groups["Value"].Value;
                }
                else
                {
                    helpAttributes.Add(attr.Groups["Name"].Value, attr.Groups["Value"].Value);
                }
            }

            foreach (Match keyword in reMSHelpKeyword.Matches(content))
            {
                helpKeywords.Add(new MSHelpKeyword(keyword.Groups["Index"].Value,
                                                   keyword.Groups["Term"].Value));
            }
        }
示例#10
0
        //=====================================================================

        /// <summary>
        /// Parse the topic and its sub-topic files to extract the information for conversion
        /// </summary>
        /// <param name="fileParser">The file parser</param>
        /// <param name="imageDictionary">The image dictionary</param>
        public void ParseFile(FileParser fileParser, Dictionary<FilePath, ImageReference> imageDictionary)
        {
            if(sourceFile != null && !String.IsNullOrEmpty(sourceFile.Path))
            {
                fileParser.ParseFile(sourceFile);

                if(fileParser.TopicId != Guid.Empty)
                    id = fileParser.TopicId;

                if(!String.IsNullOrEmpty(fileParser.RevisionNumber))
                    revisionNumber = fileParser.RevisionNumber;

                title = fileParser.Title;
                topicAbstract = fileParser.TopicAbstract;
                body = fileParser.Body;
                tocExclude = fileParser.TocExclude;
                defaultTopic = fileParser.IsDefaultTopic;
                splitToc = fileParser.SplitToc;
                sortOrder = fileParser.SortOrder;
                helpAttributes = fileParser.HelpAttributes;
                helpKeywords = fileParser.HelpKeywords;
            }

            subtopics.ParseFiles(fileParser, imageDictionary);
        }
示例#11
0
        //=====================================================================

        /// <summary>
        /// Parse the specified HTML file
        /// </summary>
        /// <param name="filename">The file to parse</param>
        /// <remarks>After parsing, the properties can be used to retrieve the information parsed from
        /// the file.</remarks>
        public void ParseFile(string filename)
        {
            Match m;
            Encoding enc = Encoding.Default;
            string content = ReadWithEncoding(filename, ref enc);

            helpAttributes = new MSHelpAttrCollection();
            helpKeywords = new MSHelpKeywordCollection();
            topicId = Guid.Empty;
            title = body = topicAbstract = null;
            revisionNumber = "1";
            tocExclude = defaultTopic = splitToc = false;
            sortOrder = Int32.MaxValue;

            m = reTopicId.Match(content);

            if(m.Success)
                Guid.TryParse(HttpUtility.HtmlDecode(m.Groups[1].Value), out topicId);

            m = reRevisionNumber.Match(content);

            if(m.Success)
                revisionNumber = HttpUtility.HtmlDecode(m.Groups[1].Value);

            m = reTitle.Match(content);

            if(m.Success)
                title = HttpUtility.HtmlDecode(m.Groups[1].Value);

            tocExclude = reTocExclude.IsMatch(content);
            defaultTopic = reIsDefaultTopic.IsMatch(content);
            splitToc = reSplitToc.IsMatch(content);

            m = reSortOrder.Match(content);

            if(m.Success)
                sortOrder = Convert.ToInt32(m.Groups["SortOrder"].Value, CultureInfo.InvariantCulture);

            m = reBody.Match(content);

            if(m.Success)
                body = m.Groups["Body"].Value;

            foreach(Match attr in reMSHelpAttr.Matches(content))
                if(attr.Groups["Name"].Value == "Abstract")
                    topicAbstract = attr.Groups["Value"].Value;
                else
                    helpAttributes.Add(attr.Groups["Name"].Value, attr.Groups["Value"].Value);

            foreach(Match keyword in reMSHelpKeyword.Matches(content))
                helpKeywords.Add(new MSHelpKeyword(keyword.Groups["Index"].Value,
                    keyword.Groups["Term"].Value));
        }
        /// <inheritdoc />
        protected override bool BindControlValue(System.Windows.Forms.Control control)
        {
            ProjectProperty projProp;

#if !STANDALONEGUI
            if(this.ProjectMgr == null)
                return false;
#else
            if(this.CurrentProject == null)
                return false;
#endif
            if(control.Name == "dgvHelpAttributes")
            {
                attributesChanged = false;

#if !STANDALONEGUI
                attributes = new MSHelpAttrCollection(
                    ((SandcastleBuilderProjectNode)base.ProjectMgr).SandcastleProject);
                projProp = this.ProjectMgr.BuildProject.GetProperty("HelpAttributes");
#else
                attributes = new MSHelpAttrCollection(this.CurrentProject);
                projProp = this.CurrentProject.MSBuildProject.GetProperty("HelpAttributes");
#endif
                if(projProp != null && !String.IsNullOrEmpty(projProp.UnevaluatedValue))
                    attributes.FromXml(projProp.UnevaluatedValue);

                dgvHelpAttributes.DataSource = attributes;
                return true;
            }

            return false;
        }
示例#13
0
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <overloads>There are five overloads for the constructor</overloads>
        protected SandcastleProject()
        {
            characterMatchEval = new MatchEvaluator(this.OnCharacterMatch);
            buildVarMatchEval = new MatchEvaluator(this.OnBuildVarMatch);

            docSources = new DocumentationSourceCollection(this);
            docSources.ListChanged += docSources_ListChanged;

            namespaceSummaries = new NamespaceSummaryItemCollection(this);
            namespaceSummaries.ListChanged += ItemList_ListChanged;

            references = new ReferenceItemCollection(this);
            references.ListChanged += ItemList_ListChanged;

            componentConfigs = new ComponentConfigurationDictionary(this);
            plugInConfigs = new PlugInConfigurationDictionary(this);

            apiFilter = new ApiFilterCollection(this);
            apiFilter.ListChanged += ItemList_ListChanged;

            helpAttributes = new MSHelpAttrCollection(this);
            helpAttributes.ListChanged += ItemList_ListChanged;

            try
            {
                loadingProperties = removeProjectWhenDisposed = true;

                contentPlacement = ContentPlacement.AboveNamespaces;
                cleanIntermediates = keepLogFile = binaryTOC = includeStopWordList = true;

                this.BuildLogFile = null;

                missingTags = MissingTags.Summary | MissingTags.Parameter | MissingTags.TypeParameter |
                    MissingTags.Returns | MissingTags.AutoDocumentCtors | MissingTags.Namespace |
                    MissingTags.AutoDocumentDispose;

                visibleItems = VisibleItems.InheritedFrameworkMembers | VisibleItems.InheritedMembers |
                    VisibleItems.Protected | VisibleItems.ProtectedInternalAsProtected;

                buildAssemblerVerbosity = BuildAssemblerVerbosity.OnlyWarningsAndErrors;
                helpFileFormat = HelpFileFormats.HtmlHelp1;
                htmlSdkLinkType = websiteSdkLinkType = HtmlSdkLinkType.Msdn;
                help2SdkLinkType = MSHelp2SdkLinkType.Msdn;
                helpViewerSdkLinkType = MSHelpViewerSdkLinkType.Msdn;
                sdkLinkTarget = SdkLinkTarget.Blank;
                presentationStyle = Constants.DefaultPresentationStyle;
                namingMethod = NamingMethod.Guid;
                syntaxFilters = ComponentUtilities.DefaultSyntaxFilter;
                collectionTocStyle = CollectionTocStyle.Hierarchical;
                helpFileVersion = "1.0.0.0";
                tocOrder = -1;
                maximumGroupParts = 2;

                this.OutputPath = null;
                this.HtmlHelp1xCompilerPath = this.HtmlHelp2xCompilerPath = this.WorkingPath =
                    this.ComponentPath = null;

                this.HelpTitle = this.HtmlHelpName = this.CopyrightHref = this.CopyrightText =
                    this.FeedbackEMailAddress = this.FeedbackEMailLinkText = this.HeaderText = this.FooterText =
                    this.ProjectSummary = this.RootNamespaceTitle = this.PlugInNamespaces = this.TopicVersion =
                    this.TocParentId = this.TocParentVersion = this.CatalogProductId = this.CatalogVersion =
                    this.CatalogName = null;
                this.FrameworkVersion = null;

                language = new CultureInfo("en-US");
            }
            finally
            {
                loadingProperties = false;
            }
        }