Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Tagged as

Word2CHM, Convert a Word Document to a CHM File

, 17 Nov 2010 CPOL
Word2CHM, convert a Word document to a CHM file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Word2CHM.CHMDom
{
    /// <summary>
    /// document properties dialog
    /// </summary>
    public partial class dlgDocumentProperties : Form
    {
        public dlgDocumentProperties()
        {
            InitializeComponent();
            this.DialogResult = DialogResult.Cancel;
        }

        private CHMDocument myDocument = null;

        public CHMDocument Document
        {
            get { return myDocument; }
            set { myDocument = value; }
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void dlgDocumentProperties_Load(object sender, EventArgs e)
        {
            if (myDocument == null)
                return;
            txtName.Text = myDocument.Name;
            txtTitle.Text = myDocument.Title;
            cboDefaultDoc.Text = myDocument.DefaultTopic;
            chkBinaryIndex.Checked = myDocument.BinaryIndex;
            chkBinaryTOC.Checked = myDocument.BinaryToc;
            chkFullTextSearch.Checked = myDocument.FullTextSearch;
            chkAutoIndex.Checked = myDocument.AutoIndex;
            txtHeaderHtml.Text = myDocument.HelpHeaderHtml;
            txtFooterHtml.Text = myDocument.HelpFooterHtml;
            foreach (string name in myDocument.Files)
            {
                cboDefaultDoc.Items.Add(name);
                lstFiles.Items.Add(name);
            }
        }

        private void btnAddFile_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.CheckFileExists = true;
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    string name = myDocument.GetRelPath(dlg.FileName);
                    lstFiles.Items.Add(name);
                }
            }
        }

        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (myDocument != null)
            {
                myDocument.Name = txtName.Text.Trim();
                myDocument.Title = txtTitle.Text.Trim();
                myDocument.DefaultTopic = cboDefaultDoc.Text.Trim();
                myDocument.BinaryIndex = chkBinaryIndex.Checked;
                myDocument.BinaryToc = chkBinaryTOC.Checked;
                myDocument.FullTextSearch = chkFullTextSearch.Checked;
                myDocument.AutoIndex = chkAutoIndex.Checked;
                myDocument.HelpFooterHtml = txtFooterHtml.Text;
                myDocument.HelpHeaderHtml = txtHeaderHtml.Text;
                myDocument.Files.Clear();
                foreach (string name in lstFiles.Items)
                {
                    myDocument.Files.Add(name);
                }
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void cmdCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lstFiles.SelectedIndex >= 0)
            {
                lstFiles.Items.RemoveAt(lstFiles.SelectedIndex);
            }
        }
         
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

yuan yong fu
Web Developer duchang soft
China China
yuan yong fu of duchang soft , come from CHINA , 2008 Microsoft MVP,Use GDI+,XML/XSLT, site:http://www.cnblogs.com/xdesigner/

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 17 Nov 2010
Article Copyright 2010 by yuan yong fu
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid