コード例 #1
0
ファイル: MainForm.cs プロジェクト: djpnewton/ddraw
 void AnnoTools_ImportAnnotationsPage(DEngine de)
 {
     // progress form
     ProgressForm pf = new ProgressForm();
     pf.Text = WbLocale.ImportingScreenAsPage;
     pf.Shown += delegate(object s, EventArgs e)
     {
         Application.DoEvents();
         // import annotations
         undoRedoArea.Start(WbLocale.ImportAnnotations);
         CreateDEngine(this.de);
         this.de.PageSize = de.PageSize;
         this.de.SetBackgroundFigure(de.BackgroundFigure, true);
         foreach (Figure f in de.Figures)
             this.de.AddFigure(f);
         undoRedoArea.Commit();
         // make sure previews line up properly
         previewBar1.ResetPreviewPositions();
         // close dialog
         pf.Close();
     };
     pf.ShowDialog();
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: djpnewton/ddraw
 void AnnoTools_ImportAnnotationsArea(DBitmap bmp)
 {
     // progress form
     ProgressForm pf = new ProgressForm();
     pf.Text = WbLocale.ImportingAreaAsImage;
     pf.Shown += delegate(object s, EventArgs e)
     {
         Application.DoEvents();
         // import annotations
         undoRedoArea.Start(WbLocale.ImportAnnotations);
         BitmapFigure f = new BitmapFigure(new DRect(10, 10, bmp.Width, bmp.Height), 0, WFHelper.ToImageData(bmp), "annotations.png");
         de.AddFigure(f);
         dvEditor.Update();
         undoRedoArea.Commit();
         // close dialog
         pf.Close();
     };
     pf.ShowDialog();
 }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: djpnewton/ddraw
 bool Save()
 {
     bool retval = false;
     // progress form
     ProgressForm pf = new ProgressForm();
     pf.Text = WbLocale.SavingFile;
     pf.Shown += delegate(object s, EventArgs e)
     {
         Application.DoEvents();
         retval = _Save(null);
         pf.Close();
     };
     pf.ShowDialog();
     return retval;
 }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: djpnewton/ddraw
 bool OpenFile(string fileName)
 {
     bool result = false;
     CheckState();
     // create progress form
     ProgressForm pf = new ProgressForm();
     pf.Text = WbLocale.OpeningFile;
     pf.Shown += delegate(object s, EventArgs e)
     {
         Application.DoEvents();
         // start undo/redo
         undoRedoArea.Start(WbLocale.OpenDocument);
         try
         {
             // load new engines
             ClearDocument();
             DPoint pageSize;
             BackgroundFigure bf;
             Dictionary<string, byte[]> extraEntries;
             List<DEngine> engines = FileHelper.Load(fileName, undoRedoArea, out pageSize, out bf,
                 new string[] { AttachmentView.ATTACHMENTS_DIR }, out extraEntries);
             if (pageSize != null)
                 NewPageSize = pageSize;
             else
                 NewPageSize = PageTools.FormatToSize(PageFormat.Default);
             if (bf != null)
                 BackgroundFigure = bf;
             else
                 BackgroundFigure = new BackgroundFigure();
             // init new dengines
             foreach (DEngine newDe in engines)
             {
                 InitDEngine(newDe, false);
                 this.engines.Add(newDe);
                 Application.DoEvents(); // update progress form
             }
             // set attachments
             attachmentView1.ClearAttachments();
             if (extraEntries != null)
                 foreach (string name in extraEntries.Keys)
                     if (name.IndexOf(AttachmentView.ATTACHMENTS_DIR) == 0)
                         attachmentView1.AddAttachment(name, extraEntries[name]);
             // commit undo/redo
             undoRedoArea.Commit();
             Dirty = false;
             // update vars
             this.fileName = fileName;
             beenSaved = true;
             needSave = false;
             UpdateTitleBar();
             // show first page
             ShowFirstPage();
             // add to recent documents
             AddRecentDocument(fileName);
             // start autosaving
             StartAutoSaveTimer();
             // result true!
             result = true;
         }
         catch (Exception e2)
         {
             undoRedoArea.Cancel();
             MessageBox.Show(e2.Message, WbLocale.ErrorReadingFile, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         pf.Close();
     };
     pf.ShowDialog();
     return result;
 }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: djpnewton/ddraw
 private void importNotebookToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (CheckDirty())
     {
         OpenFileDialog ofd = new OpenFileDialog();
         ofd.Filter = "Smart Notebook|*.notebook";
         if (ofd.ShowDialog() == DialogResult.OK)
         {
             CheckState();
             // setup progress form
             ProgressForm pf = new ProgressForm();
             pf.Text = WbLocale.ImportingNotebookFile;
             pf.Shown += delegate(object s, EventArgs e2)
             {
                 Application.DoEvents();
                 // start undo/redo
                 undoRedoArea.Start(WbLocale.ImportNotebook);
                 try
                 {
                     // clear pages & attachments
                     ClearDocument();
                     attachmentView1.ClearAttachments();
                     // load notebook file
                     Dictionary<string, byte[]> attachments;
                     List<DEngine> engines = Converters.Converters.FromNotebook(ofd.FileName, undoRedoArea, out attachments);
                     // add new pages
                     foreach (DEngine de in engines)
                     {
                         InitDEngine(de, false);
                         this.engines.Add(de);
                         Application.DoEvents(); // update progress form
                     }
                     // add new attachments
                     foreach (string name in attachments.Keys)
                         attachmentView1.AddAttachment(name, attachments[name]);
                     // clear undos
                     undoRedoArea.Commit();
                     undoRedoArea.ClearHistory();
                     // update vars
                     fileName = Path.GetFileNameWithoutExtension(ofd.FileName);
                     beenSaved = false;
                     needSave = false;
                     UpdateTitleBar();
                     // show first page
                     ShowFirstPage();
                     // start autosaving
                     StartAutoSaveTimer();
                 }
                 catch (Exception e3)
                 {
                     undoRedoArea.Cancel();
                     MessageBox.Show(e3.Message, WbLocale.ErrorReadingFile, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 pf.Close();
             };
             pf.ShowDialog();
         }
     }
 }
コード例 #6
0
ファイル: ExportForm.cs プロジェクト: djpnewton/ddraw
 private bool ExportImage(IList<DEngine> expEngines)
 {
     bool result = false;
     FolderBrowserDialog fbd = new FolderBrowserDialog();
     if (fbd.ShowDialog() == DialogResult.OK)
     {
         result = true;
         try
         {
             // setup progress form
             ProgressForm pf = new ProgressForm();
             pf.Text = WbLocale.ExportingToImages;
             pf.Shown += delegate(object s, EventArgs e)
             {
                 string fileNameTemplate;
                 if (rbPng.Checked)
                     fileNameTemplate = Path.GetFileNameWithoutExtension(docFileName) + "{0}.png";
                 else
                     fileNameTemplate = Path.GetFileNameWithoutExtension(docFileName) + "{0}.emf";
                 DPrintViewer dvPrint = new DPrintViewer();
                 foreach (DEngine de in expEngines)
                 {
                     DBitmap bmp = WFHelper.MakeBitmap((int)de.PageSize.X, (int)de.PageSize.Y);
                     DGraphics dg;
                     if (rbPng.Checked)
                         dg = WFHelper.MakeGraphics(bmp);
                     else
                         dg = new EmfGraphics(new DRect(0, 0, de.PageSize.X, de.PageSize.Y), WorkBookUtils.GetScreenMM(), WorkBookUtils.GetScreenRes());
                     dvPrint.Paint(dg, de.BackgroundFigure, de.Figures);
                     if (rbPng.Checked)
                         bmp.Save(Path.Combine(fbd.SelectedPath, string.Format(fileNameTemplate, engines.IndexOf(de) + 1)));
                     else
                         ((EmfGraphics)dg).SaveToFile(Path.Combine(fbd.SelectedPath, string.Format(fileNameTemplate, engines.IndexOf(de) + 1)));
                     dg.Dispose();
                     bmp.Dispose();
                 }
                 pf.Close();
                 System.Diagnostics.Process.Start(fbd.SelectedPath);
             };
             pf.ShowDialog();
         }
         catch (Exception e)
         {
             result = false;
             MessageBox.Show(WbLocale.ERROR, e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     return result;
 }