Ejemplo n.º 1
0
        private void LoadCHM()
        {
            string CHMFilename = Path.Combine(Settings.Default.ChmPath, Settings.Default.MainChm);

            chm = new HtmlHelpSystem();
            chm.OpenFile(CHMFilename, null);

            Console.WriteLine(String.Format("Loaded main CHM: {0}",
                                            Path.GetFileName(CHMFilename)));
            foreach (string filename in Directory.GetFiles(Settings.Default.ChmPath))
            {
                if (!Path.GetExtension(filename).ToLower().Equals(".chm"))
                {
                    continue;
                }
                if (Path.GetFileName(filename).ToLower().Equals(Settings.Default.MainChm))
                {
                    continue;
                }

                Console.WriteLine(String.Format("Loading CHM: {0}",
                                                Path.GetFileName(filename)));
                try
                {
                    chm.MergeFile(filename);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(String.Format("Could not load CHM: {0}. Exception {1}",
                                                    Path.GetFileName(filename),
                                                    ex));
                }
            }
            Console.WriteLine(String.Format("Loaded {0} CHMs",
                                            chm.FileList.Length));
        }
Ejemplo n.º 2
0
        public void LoadCHM(string filePath)
        {
            ChmInit();

            try
            {
                //make sure the TOC is ready
                if (TocTree == null)
                {
                    OpenChmTocTab();
                }

                // clear current items
                TocTree.ClearContents();
                //					helpIndex1.ClearContents();
                //					helpSearch2.ClearContents();

                // open the chm-file selected in the OpenFileDialog
                _reader.OpenFile(filePath, _dmpInfo);
                _reader.MergeFile("test.chm");
                // Enable the toc-tree pane if the opened file has a table of contents
                TocTree.Enabled = _reader.HasTableOfContents;
                // Enable the index pane if the opened file has an index
                //					helpIndex1.Enabled = _reader.HasIndex;
                // Enable the full-text search pane if the opened file supports full-text searching
                //					helpSearch2.Enabled = _reader.FullTextSearch;

                //					btnContents.Enabled = _reader.HasTableOfContents;
                //					btnIndex.Enabled = _reader.HasIndex;
                //					btnSearch.Enabled = _reader.FullTextSearch;
                //
                //					miContents.Enabled = _reader.HasTableOfContents;
                //					miContents1.Enabled = _reader.HasTableOfContents;
                //					miIndex.Enabled = _reader.HasIndex;
                //					miIndex1.Enabled = _reader.HasIndex;
                //					miSearch.Enabled = _reader.FullTextSearch;
                //					miSearch1.Enabled = _reader.FullTextSearch;
                //					btnSynch.Enabled = _reader.HasTableOfContents;
                //
                //					tabControl1.SelectedIndex = 0;
                //
                //					btnRefresh.Enabled = true;
                //					if( _reader.DefaultTopic.Length > 0)
                //					{
                //						btnHome.Enabled = true;
                //						miHome.Enabled = true;
                //					}

                // Build the table of contents tree view in the classlibrary control
                TocTree.BuildTOC(_reader.TableOfContents, _filter);

                // Build the index entries in the classlibrary control
                //					if( _reader.HasKLinks )
                //						helpIndex1.BuildIndex( _reader.Index, IndexType.KeywordLinks, _filter );
                //					else if( _reader.HasALinks )
                //						helpIndex1.BuildIndex( _reader.Index, IndexType.AssiciativeLinks, _filter );

                // Navigate the embedded browser to the default help topic
                //					NavigateBrowser( _reader.DefaultTopic );

                //					miMerge.Enabled = true;
                //					miCloseFile.Enabled = true;
                //
                //					this.Text = _reader.FileList[0].FileInfo.HelpWindowTitle + " - HtmlHelp - Viewer";
                //
                //					miCustomize.Enabled = ( _reader.HasInformationTypes || _reader.HasCategories);

                // Force garbage collection to free memory
                GC.Collect();
            }
            finally
            {
            }
        }