Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Diagnostics;
- using System.IO;
- namespace WindowsFormsApplication2
- {
- public partial class Form1 : Form
- {
- public Form1() { InitializeComponent(); }
- private void button1_Click(object sender, EventArgs e)
- {
- string baseDir = "c:\\ss\\";
- string tempFile = "den";
- string tex = tempFile + ".tex";
- string png = tempFile + ".png";
- string ps = tempFile + ".ps";
- string dvi = tempFile + ".dvi";
- //if (File.Exists(baseDir + png))
- // File.Delete(baseDir + png);
- File.WriteAllLines(baseDir + tempFile + ".tex", textBoxCommands.Lines);
- string strCmdLine =
- "/C cd c:\\ss & " + Ozellikler.texi2dviPath + " " + tex +
- "&" + Ozellikler.dvipsPath + " -E " + dvi;
- string str2 =
- "/C cd c:\\ss & " + Ozellikler.imageMagickPath + " -density 200x200 " +
- baseDir + ps + " " + baseDir + png;
- // Use ProcessStartInfo class
- ProcessStartInfo startInfo = new ProcessStartInfo();
- startInfo.CreateNoWindow = false;
- startInfo.UseShellExecute = false;
- startInfo.FileName = "cmd.exe";
- startInfo.WindowStyle = ProcessWindowStyle.Hidden;
- startInfo.Arguments = strCmdLine + " & " + str2; ;
- try
- {
- using (Process exeProcess = Process.Start(startInfo))
- {
- exeProcess.WaitForExit(3000);
- {
- foreach (Process p in System.Diagnostics.Process.GetProcessesByName("cmd"))
- {
- try
- {
- p.Kill();
- p.WaitForExit();
- p.CloseMainWindow();
- WindowState = FormWindowState.Normal;
- }
- catch
- {
- MessageBox.Show("LATEX isleme hatasi");
- }
- }
- }
- }
- }
- catch
- {
- MessageBox.Show("PROCESS OLUSTURMA HATASI");
- }
- try
- {
- pictureBox1.Image = Image.FromFile(baseDir + png);
- pictureBox1.Show();
- }
- catch
- {
- MessageBox.Show("Resim Bulunan Dizinde Degil");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement