Skip to content

Commit 8bb7048

Browse files
committed
Fix compile
1 parent 3a5eaf4 commit 8bb7048

11 files changed

Lines changed: 605 additions & 295 deletions

CompileForm.Designer.cs

Lines changed: 5 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CompileForm.cs

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Drawing;
77
using System.IO;
88
using System.Linq;
9+
using System.Runtime.InteropServices;
910
using System.Text;
1011
using System.Threading;
1112
using System.Threading.Tasks;
@@ -34,6 +35,18 @@ private void CompileForm_Load(object sender, EventArgs e)
3435
{
3536
richTextBox1.Text = ToBuild;
3637
this.MaximizeBox = false;//Messes up UI
38+
button2.Enabled = false;
39+
progressBar1.Maximum = 100;
40+
progressBar1.Step = 1;
41+
running = true;
42+
this.Text = "Compiling...";
43+
//TODO Compile code
44+
ToBuild = richTextBox1.Text;//Load any changes the user has made
45+
var ts = new ThreadStart(() => DoTheDeed(tempdir));
46+
ts += UIMarkEndInstall;
47+
Thread t = new Thread(ts);
48+
49+
t.Start();
3750
}
3851

3952
private void button1_Click(object sender, EventArgs e)
@@ -47,53 +60,68 @@ private void button1_Click(object sender, EventArgs e)
4760
this.Close();
4861
}
4962
}
63+
private void OnInputRecv(object sender, DataReceivedEventArgs e)
64+
{
65+
this.Invoke((MethodInvoker)delegate {
66+
// Running on the UI thread
67+
richTextBox1.Text += "\n"+e.Data;
68+
progressBar1.PerformStep();
69+
});
70+
}
5071
private void DoTheDeed(string tempdir)
5172
{
5273
Process p = new Process();
5374
var slp = CLISplit.SplitCommandLine(ToBuild).ToList();
54-
p.StartInfo.FileName = "powershell.exe";
55-
p.StartInfo.Arguments = ToBuild+$" | tee {tempdir}\\compile.log";
75+
p.StartInfo.FileName = "pyinstaller";
76+
p.StartInfo.Arguments = String.Join(" ",slp.GetRange(1,slp.Count-1));
77+
5678
p.StartInfo.UseShellExecute = false;
57-
if (!checkBox1.Checked)
58-
{
59-
p.StartInfo.CreateNoWindow = true;
60-
} else
79+
p.StartInfo.RedirectStandardOutput = true;
80+
p.StartInfo.RedirectStandardError = true;
81+
82+
p.StartInfo.CreateNoWindow = true;
83+
p.OutputDataReceived += OnInputRecv;
84+
p.ErrorDataReceived += OnInputRecv;
85+
p.Start();
86+
p.BeginOutputReadLine();
87+
p.BeginErrorReadLine();
88+
89+
while (!p.HasExited)
6190
{
62-
p.StartInfo.CreateNoWindow = false;
91+
if (abort)
92+
{
93+
p.Kill();
94+
MessageBox.Show("Compilation aborted", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
95+
break;
96+
}
6397
}
64-
p.Start();
65-
p.WaitForExit();
98+
this.Invoke((MethodInvoker)delegate {
99+
// Running on the UI thread
100+
progressBar1.Value = progressBar1.Maximum;
101+
});
102+
66103
var ec = p.ExitCode;
67104
if (ec != 0)
68105
{
69106
MessageBox.Show("Error compiling: Please check log", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
70107
} else
71108
{
72-
MessageBox.Show("Completed successfully!");
109+
MessageBox.Show("Completed successfully!","Report",MessageBoxButtons.OK,MessageBoxIcon.Information);
73110
}
74111
}
75112

76113

77114
private void button2_Click(object sender, EventArgs e)
78115
{
79-
button2.Enabled = false;
80-
progressBar1.Style = ProgressBarStyle.Marquee;
81-
running = true;
82-
this.Text = "Compiling...";
83-
//TODO Compile code
84-
ToBuild = richTextBox1.Text;//Load any changes the user has made
85-
var ts = new ThreadStart(() => DoTheDeed(tempdir));
86-
ts += UIMarkEndInstall;
87-
Thread t = new Thread(ts) ;
88-
89-
t.Start();
90116

117+
this.Close();
91118

92119
}
93120
private void UIMarkEndInstall()
94121
{
95122
this.Invoke((MethodInvoker)delegate {
96123
// Running on the UI thread
124+
File.WriteAllText(tempdir + "\\compile.log", richTextBox1.Text);
97125
Text = "Finished";
98126
progressBar1.Style = ProgressBarStyle.Continuous;
99127
running = false;
@@ -104,7 +132,8 @@ private void UIMarkEndInstall()
104132

105133
private void richTextBox1_TextChanged(object sender, EventArgs e)
106134
{
107-
135+
richTextBox1.SelectionStart = richTextBox1.Text.Length;
136+
richTextBox1.ScrollToCaret();
108137
}
109138
}
110139
}

0 commit comments

Comments
 (0)