Esempio n. 1
0
        public TableOfContents(string projectPath)
        {
            string projectName = new DirectoryInfo(projectPath).Name;
            _tableOfContentsFilename = Path.Combine(projectPath,projectName + Constants.TableOfContentsFileExtension);

            if( !File.Exists(_tableOfContentsFilename) )
                File.WriteAllText(_tableOfContentsFilename,"",Encoding.UTF8);

            _tableOfContentsParser = new TopicListParser(false);
        }
Esempio n. 2
0
        public Index(string projectPath)
        {
            string projectName = new DirectoryInfo(projectPath).Name;
            _indexFilename = Path.Combine(projectPath,projectName + Constants.IndexFileExtension);

            if( !File.Exists(_indexFilename) )
                File.WriteAllText(_indexFilename,"",Encoding.UTF8);

            _indexParser = new TopicListParser(true);
        }
Esempio n. 3
0
        private void SaveForChmNode(TextWriter tw,Dictionary<Preprocessor.TopicPreprocessor,string> outputTopicFilenames,TopicListParser.TopicListNode node)
        {
            bool ulStartWritten = false;

            while( node != null )
            {
                string linkedChmFilename = TopicListParser.GetLinkToChm(node.Title);
                string textAfterRecursion = null;

                if( linkedChmFilename != null ) // a link to another help file
                {
                    if( _processedFirstTopicChapter )
                        _processedLastTopicChapter = true;

                    if( ulStartWritten )
                    {
                        tw.WriteLine("</ul>");
                        ulStartWritten = false;
                    }

                    linkedChmFilename = Path.GetFileNameWithoutExtension(linkedChmFilename);

                    tw.WriteLine("<object type=\"text/sitemap\">");
                    tw.WriteLine("<param name=\"Name\" value=\"{0}.chm::/{0}.hhc\"/>",linkedChmFilename);
                    tw.WriteLine("<param name=\"Merge\" value=\"{0}.chm::/{0}.hhc\"/>",linkedChmFilename);
                    tw.WriteLine("</object>");
                }

                else // a chapter or topic
                {
                    _processedFirstTopicChapter = true;

                    if( !ulStartWritten )
                    {
                        tw.WriteLine("<ul>");
                        ulStartWritten = true;
                    }

                    tw.WriteLine("<li><object type=\"text/sitemap\">");

                    if( _processedLastTopicChapter )
                        throw new Exception("Linked help files must come before or after all chapters and topics.");

                    tw.WriteLine("<param name=\"Name\" value=\"{0}\"/>",node.Title);

                    if( node.Topic != null )
                        tw.WriteLine("<param name=\"Local\" value=\"{0}\"/>",outputTopicFilenames[node.Topic]);

                    tw.WriteLine("</object>");

                    textAfterRecursion = "</li>";
                }

                if( node.ChildNode != null )
                    SaveForChmNode(tw,outputTopicFilenames,node.ChildNode);

                if( textAfterRecursion != null )
                    tw.WriteLine(textAfterRecursion);

                node = node.SiblingNode;
            }

            if( ulStartWritten )
                tw.WriteLine("</ul>");
        }
Esempio n. 4
0
        private void SaveForChmNode(TextWriter tw,Dictionary<Preprocessor.TopicPreprocessor,string> outputTopicFilenames,TopicListParser.TopicListNode node)
        {
            tw.WriteLine("<ul>");

            while( node != null )
            {
                if( node.Topic == null )
                    _mergeFiles.Add(TopicListParser.GetLinkToChm(node.Title));

                else
                {
                    tw.WriteLine("<li><object type=\"text/sitemap\">");
                    tw.WriteLine("<param name=\"Name\" value=\"{0}\"/>",node.Title);
                    tw.WriteLine("<param name=\"Name\" value=\"{0}\"/>",node.Topic.Title);
                    tw.WriteLine("<param name=\"Local\" value=\"{0}\"/>",outputTopicFilenames[node.Topic]);
                    tw.WriteLine("</object></li>");
                }

                if( node.ChildNode != null )
                    SaveForChmNode(tw,outputTopicFilenames,node.ChildNode);

                node = node.SiblingNode;
            }

            tw.WriteLine("</ul>");
        }