//===================================================================== /// <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); }
//===================================================================== /// <summary> /// Constructor /// </summary> /// <param name="currentKeywords">The item collection to edit</param> public MSHelpKeywordEditorDlg(MSHelpKeywordCollection currentKeywords) { InitializeComponent(); keywords = currentKeywords; dgvKeywords.AutoGenerateColumns = false; dgvKeywords.DataSource = keywords; }
//===================================================================== /// <summary> /// Constructor /// </summary> public Topic() { contentId = Guid.NewGuid().ToString(); subtopics = new TopicCollection(null); keywords = new MSHelpKeywordCollection(); this.Visible = true; subtopics.ListChanged += childList_ListChanged; keywords.ListChanged += childList_ListChanged; }
//===================================================================== /// <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); }
/// <inheritdoc /> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { MSHelpKeywordCollection items = value as MSHelpKeywordCollection; if (items == null || destinationType != typeof(string)) { return(base.ConvertTo(context, culture, value, destinationType)); } if (items.Count == 0) { return("(None)"); } return(String.Format(culture, "{0} keyword(s)", items.Count)); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { // Get the help index keyword collection MSHelpKeywordCollection items = value as MSHelpKeywordCollection; if (context == null || provider == null || context.Instance == null || items == null) { return(base.EditValue(context, provider, value)); } using (MSHelpKeywordEditorDlg dlg = new MSHelpKeywordEditorDlg(items)) { dlg.ShowDialog(); } return(value); }
//===================================================================== /// <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)); } }
//===================================================================== /// <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); }
//===================================================================== /// <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)); }