예제 #1
0
        private void OpenDDL_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = null;

            try
            {
                dialog = new OpenFileDialog();
                dialog.CheckFileExists  = true;
                dialog.CheckPathExists  = true;
                dialog.Filter           = "MigraDoc DDL (*.mdddl)|*.mdddl|All Files (*.*)|*.*";
                dialog.FilterIndex      = 1;
                dialog.InitialDirectory = System.IO.Path.Combine(GetProgramDirectory(), "..\\..");
                //dialog.RestoreDirectory = true;
                if (dialog.ShowDialog() == true)
                {
                    Document document = DdlReader.DocumentFromFile(dialog.FileName);
                    string   ddl      = DdlWriter.WriteToString(document);
                    preview.Ddl = ddl;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Title);
                preview.Ddl = null; // TODO has no effect
            }
            finally
            {
                //if (dialog != null)
                //  dialog.Dispose();
            }
            //UpdateStatusBar();
        }
예제 #2
0
 private void OpenDdlClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var dialog = new OpenFileDialog
         {
             CheckFileExists  = true,
             CheckPathExists  = true,
             Filter           = "MigraDoc DDL (*.mdddl)|*.mdddl|All Files (*.*)|*.*",
             FilterIndex      = 1,
             InitialDirectory = Path.GetFullPath(Path.Combine(GetProgramDirectory(), "..\\..\\..\\..\\assets\\ddl"))
         };
         //dialog.RestoreDirectory = true;
         if (dialog.ShowDialog() == true)
         {
             var document = DdlReader.DocumentFromFile(dialog.FileName);
             var folder   = Path.GetDirectoryName(dialog.FileName);
             Environment.CurrentDirectory = folder;
             var ddl = DdlWriter.WriteToString(document);
             Preview.Ddl = ddl;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, Title);
         Preview.Ddl = null; // TODO has no effect
     }
     finally
     {
         //if (dialog != null)
         //  dialog.Dispose();
     }
     //UpdateStatusBar();
 }
예제 #3
0
 private void button12_Click(object sender, System.EventArgs e)
 {
     if (this.tbxDdlFile.Text != "")
     {
         try
         {
             Document   doc        = DdlReader.DocumentFromFile(tbxDdlFile.Text);
             PdfPrinter pdfPrinter = new PdfPrinter();
             pdfPrinter.Document = doc;
             pdfPrinter.PrintDocument();
             pdfPrinter.PdfDocument.Save("egal.pdf");
             System.Diagnostics.Process.Start("egal.pdf");
         }
         catch (Exception exc)
         {
             MessageBox.Show(exc.Message);
         }
     }
 }