示例#1
0
        private void convertAllFilesToHTMLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PageEditView  pev     = pageDetailPanel1.GetEditView();
            MNPageContext ctx     = pev.Context;
            string        rootDir = Properties.Settings.Default.ExportHTMLFolder;


            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter      = "SlideViewer books (*.smb)|*.smb";
            ofd.FilterIndex = 0;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                if (MessageBox.Show("Now select folder where output will be writen (in the form of many HTml files and images)") == DialogResult.OK)
                {
                    FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
                    folderBrowser.SelectedPath = rootDir;
                    if (folderBrowser.ShowDialog() == DialogResult.OK)
                    {
                        rootDir = folderBrowser.SelectedPath;
                        Properties.Settings.Default.ExportHTMLFolder = rootDir;
                        Properties.Settings.Default.Save();
                        MNExportContext etx = new MNExportContext();
                        etx.DirAllBooks = rootDir;
                        foreach (string file in Directory.EnumerateFiles(Path.GetDirectoryName(ofd.FileName)))
                        {
                            if (file.EndsWith(".smb"))
                            {
                                MNDocument docx = LoadDocument(file);
                                //ConvertDocToHtml(pev, docx, file.Replace(".smb", ".html"), rootDir);
                                docx.ExportToHtml(etx, Path.GetFileNameWithoutExtension(file));
                                Debugger.Log(0, "", "Converted " + Path.GetFileName(file) + ".\n");
                                docx = null;
                            }
                            MNNotificationCenter.CurrentDocument = null;
                            GC.Collect();
                            GC.WaitForPendingFinalizers();
                            if (etx.Files >= etx.MaxFiles)
                            {
                                break;
                            }
                        }
                        Debugger.Log(0, "", "Finished.\n");

                        MessageBox.Show("Files were converted.");
                    }
                }
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            MNExportContext etx = new MNExportContext();

            etx.DirAllBooks = @"e:\temp";
            string file = @"e:\Dropbox\ReaderBooks\STFK.smb";

            if (!File.Exists(file))
            {
                Console.WriteLine("File {0} does not exist.", file);
                return;
            }

            Console.WriteLine("File: {0}", file);
            MNDocument docx = Program.LoadDocument(file);

            docx.ExportToHtml(etx, Path.GetFileNameWithoutExtension(file));

            docx = null;

            StringBuilder Consolereport = new StringBuilder();

            Consolereport.AppendLine("Used controls:");
            foreach (string s in etx.UsedControls.Keys)
            {
                HashSet <long> hash = etx.UsedControls[s];
                Consolereport.AppendFormat("{0}:", s);
                foreach (long l in hash)
                {
                    Consolereport.AppendFormat(" {0}", l);
                }
                Consolereport.AppendLine();
            }

            Console.WriteLine(Consolereport.ToString());
            File.WriteAllText(Path.Combine(etx.DirCurrentBook, "info.txt"), Consolereport.ToString());

            Console.ReadLine();
        }