/Main/Source/HtmlToMaml/MSHelpKeywordCollection.cs
C# | 98 lines | 46 code | 9 blank | 43 comment | 1 complexity | 51f4a4f094ef95133fa779b65d5fb496 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
- //=============================================================================
- // System : Sandcastle Help File Builder Utilities
- // File : MSHelpKeywordCollection.cs
- // Author : Eric Woodruff (Eric@EWoodruff.us)
- // Updated : 09/16/2008
- // Note : Copyright 2008, Eric Woodruff, All rights reserved
- // Compiler: Microsoft Visual C#
- //
- // This file contains a collection class used to hold the help index keyword
- // information.
- //
- // This code is published under the Microsoft Public License (Ms-PL). A copy
- // of the license should be distributed with the code. It can also be found
- // at the project website: http://www.CodePlex.com/SandcastleStyles. This
- // notice, the author's name, and all copyright notices must remain intact in
- // all applications, documentation, and source files.
- //
- // Version Date Who Comments
- // ============================================================================
- // 1.6.0.7 03/25/2008 EFW Created the code
- //=============================================================================
-
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.IO;
- using System.Text;
- using System.Xml;
-
- namespace SandcastleBuilder.Utils
- {
- /// <summary>
- /// This collection class is used to hold the help index keyword items for
- /// a project.
- /// </summary>
- public class MSHelpKeywordCollection : BindingList<MSHelpKeyword>
- {
- #region Sort collection
- //=====================================================================
- // Sort the collection
-
- /// <summary>
- /// This is used to sort the collection
- /// </summary>
- /// <remarks>Values are sorted by index name and term</remarks>
- public void Sort()
- {
- ((List<MSHelpKeyword>)base.Items).Sort(
- delegate(MSHelpKeyword x, MSHelpKeyword y)
- {
- return Comparer<MSHelpKeyword>.Default.Compare(x, y);
- });
- }
- #endregion
-
- #region Read/write as XML
- //=====================================================================
-
- /// <summary>
- /// This is used to save the keyword collection to the project
- /// file.
- /// </summary>
- /// <param name="xw">The XML text writer to which the information
- /// is written.</param>
- public void WriteXml(XmlWriter xw)
- {
- if(base.Count > 0)
- {
- xw.WriteStartElement("HelpKeywords");
-
- foreach(MSHelpKeyword kw in this)
- {
- xw.WriteStartElement("HelpKeyword");
- xw.WriteAttributeString("index", kw.Index);
- xw.WriteAttributeString("term", kw.Term);
- xw.WriteEndElement();
- }
-
- xw.WriteEndElement();
- }
- }
- #endregion
-
- #region Helper methods
- //=====================================================================
-
- /// <summary>
- /// This is used to mark the collection as changed when there is no
- /// associated project.
- /// </summary>
- public void MarkAsDirty()
- {
- this.OnListChanged(new ListChangedEventArgs(
- ListChangedType.ItemChanged, -1));
- }
- #endregion
- }
- }