Esempio n. 1
0
 private void PaintDraggedItem(MNPageContext context, PVDragContext mouseContext)
 {
     if (mouseContext.draggedItem != null)
     {
         SMTokenItem ti = mouseContext.draggedItem;
         if (ti.Text != null && ti.Text.Length > 0)
         {
             if (ti.ContentSize.Width == 0)
             {
                 SizeF sf = context.g.MeasureString(ti.Text, context.DragItemFont);
                 ti.ContentSize = new Size(Convert.ToInt32(sf.Width), Convert.ToInt32(sf.Height));
             }
             Rectangle rc = new Rectangle(mouseContext.lastPoint.X - ti.ContentSize.Width / 2,
                                          mouseContext.lastPoint.Y - ti.ContentSize.Height / 2,
                                          ti.ContentSize.Width + 2, ti.ContentSize.Height + 2);
             //context.g.FillRectangle(Brushes.LightPink, rc);
             context.g.DrawString(ti.Text, context.DragItemFont, Brushes.Red, rc);
         }
         else if (ti.Image != null)
         {
             if (ti.ContentSize.Width == 0)
             {
                 Size   sf = ti.Image.Size;
                 double d  = 64.0 / (Math.Max(sf.Width, sf.Height) + 1);
                 ti.ContentSize = new Size(Convert.ToInt32(d * sf.Width), Convert.ToInt32(d * sf.Height));
             }
             Rectangle rc = new Rectangle(mouseContext.lastPoint.X - ti.ContentSize.Width / 2,
                                          mouseContext.lastPoint.Y - ti.ContentSize.Height / 2,
                                          ti.ContentSize.Width + 2, ti.ContentSize.Height + 2);
             context.g.DrawImage(ti.Image, rc);
         }
     }
 }
Esempio n. 2
0
        public PageView()
        {
            InitializeComponent();
            ViewController       = new PageViewController();
            ViewController.View  = this;
            p_docexec            = new MNDocumentExecutor(ViewController);
            Context              = new MNPageContext();
            refusal_timer.Tick  += new EventHandler(refusal_timer_Tick);
            MouseContext.context = Context;

            InitBitmaps();
        }
Esempio n. 3
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.");
                    }
                }
            }
        }
Esempio n. 4
0
        private void exportDocumentToHTMLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PageEditView  pev     = pageDetailPanel1.GetEditView();
            MNPageContext ctx     = pev.Context;
            MNDocument    doc     = MNNotificationCenter.CurrentDocument;
            string        rootDir = "d:\\temp\\books";

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.FileName = doc.Book.BookCode + ".html";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                ConvertDocToHtml(pev, doc, sfd.FileName, rootDir);
            }
        }