-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForm1.cs
More file actions
130 lines (113 loc) · 4.06 KB
/
Copy pathForm1.cs
File metadata and controls
130 lines (113 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using System;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
namespace ISO_Builder
{
public partial class FormBuildISO : Form
{
string source, destination, fileName;
private FolderBrowserDialog ChooseSource = new FolderBrowserDialog();
private FolderBrowserDialog ChooseDestination = new FolderBrowserDialog();
public FormBuildISO()
{
InitializeComponent();
}
private void FormBuildISO_Load(object sender, EventArgs e)
{
progressBar1.Hide();
lblProgress.Hide();
btnBuildISO.Enabled = false;
}
private void btnOpenSource_Click(object sender, EventArgs e)
{
lblProgress.Hide();
try
{
ChooseSource.ShowDialog();
txtSourceFiles.Text = ChooseSource.SelectedPath;
if (CheckFields()) { btnBuildISO.Enabled = true; }
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnDestinationPath_Click(object sender, EventArgs e)
{
lblProgress.Hide();
try
{
ChooseDestination.ShowDialog();
txtDestinationPath.Text = ChooseDestination.SelectedPath;
if (CheckFields()) { btnBuildISO.Enabled = true; }
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void txtISOFileName_TextChanged(object sender, EventArgs e)
{
lblProgress.Hide();
try
{
if (txtISOFileName.Text.Contains(".iso"))
{
if (CheckFields()) { btnBuildISO.Enabled = true; }
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnBuildISO_Click(object sender, EventArgs e)
{
source = txtSourceFiles.Text;
destination = txtDestinationPath.Text;
fileName = txtISOFileName.Text;
string Cmd = "\"" + Application.StartupPath + "\\References\\oscdimg.exe\"";
string Args = "-n -m -b\"" + Application.StartupPath + "\\References\\etfsboot.com\" " +
"\"" + source + "\" \"" + destination + "\\" + fileName + "\"";
BuildISO(Cmd, Args);
}
private void BuildISO(string Cmd, string Args)
{
progressBar1.MarqueeAnimationSpeed = 10;
progressBar1.Show();
Thread thread = new Thread(() => {
ProcessStartInfo info = new ProcessStartInfo();
info.CreateNoWindow = true;
info.FileName = Cmd;
info.Arguments = Args;
info.UseShellExecute = false;
info.RedirectStandardError = true;
info.RedirectStandardOutput = true;
Process run = new Process();
run.StartInfo = info;
try
{
run.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
});
thread.Start();
progressBar1.MarqueeAnimationSpeed = 0;
lblProgress.Show();
}
private bool CheckFields()
{
if (!String.IsNullOrWhiteSpace(txtSourceFiles.Text) &
!String.IsNullOrWhiteSpace(txtDestinationPath.Text) &
!String.IsNullOrWhiteSpace(txtISOFileName.Text))
{
return true;
}
else { return false; }
}
}
}