private void createBinaryReplaceJobFromFileToolStripMenuItem_Click(object sender, EventArgs e)
{
int n;
if (pcc == null || !GetSelected(out n) || n < 0)
{
return;
}
OpenFileDialog d = new OpenFileDialog();
d.Filter = "*.bin|*.bin";
if (d.ShowDialog() == DialogResult.OK)
{
FileStream fs = new FileStream(d.FileName, FileMode.Open, FileAccess.Read);
byte[] buff = new byte[fs.Length];
int cnt;
int sum = 0;
while ((cnt = fs.Read(buff, sum, buff.Length - sum)) > 0) sum += cnt;
fs.Close();
KFreonLib.Scripting.ModMaker.ModJob mj = new KFreonLib.Scripting.ModMaker.ModJob();
string currfile = Path.GetFileName(pcc.FileName);
mj.data = buff;
mj.Name = "Binary Replacement for file \"" + currfile + "\" in Object #" + n + " with " + buff.Length + " bytes of data";
string loc = Path.GetDirectoryName(Application.ExecutablePath);
string template = File.ReadAllText(loc + "\\exec\\JobTemplate_Binary2.txt");
template = template.Replace("**m1**", n.ToString());
template = template.Replace("**m2**", currfile);
mj.Script = template;
KFreonLib.Scripting.ModMaker.JobList.Add(mj);
MessageBox.Show("Done");
}
}