private void btnOK_Click(object sender, EventArgs e) { string[] bestanden = Directory.GetFiles(mapnaam_func, "*.func"); foreach (string bestand in bestanden) { File.Delete(bestand); } Rijndael rijndael = Rijndael.Create(); rijndael.Key = key; rijndael.IV = IV; ICryptoTransform sleutel = rijndael.CreateEncryptor(); foreach (Functie f in functies) { switch (f.Functie_Type) { case Functie.enFunctie_type.gui: GrafischeFunctie gf = (GrafischeFunctie)f; StringBuilder b = new StringBuilder(); b.AppendLine("gui"); b.AppendLine(gf.Beschrijving); b.AppendLine(gf.Voorschrift); b.AppendLine(); foreach (Parameter p in gf.Parameters) { b.AppendLine(string.Join(";", new string[] { p.Naam, p.Beschrijving, p.Is_Getal ? "getal" : p.EnumNaam, p.Optioneel ? "1" : "0", p.StandaardWaarde.ToString() })); } b.AppendLine(); foreach (Tmp_Param p in gf.Temp) { b.AppendLine(string.Join(";", new string[] { p.Naam, p.Beschrijving, p.Berekening })); } string bestand = mapnaam_func + gf.Naam + ".func"; FileStream fs = new FileStream(bestand, FileMode.Create); CryptoStream cs = new CryptoStream(fs, sleutel, CryptoStreamMode.Write); StreamWriter writer = new StreamWriter(cs); writer.Write(b.ToString()); writer.Close(); fs.Close(); break; case Functie.enFunctie_type.tekst: TekstFunctie tf = (TekstFunctie)f; string bestand2 = mapnaam_func + tf.Naam + ".func"; FileStream fs2 = new FileStream(bestand2, FileMode.Create); CryptoStream cs2 = new CryptoStream(fs2, sleutel, CryptoStreamMode.Write); StreamWriter writer2 = new StreamWriter(cs2); writer2.Write("tekst\r\n" + tf.ToString()); writer2.Close(); fs2.Close(); break; } } this.DialogResult = DialogResult.OK; }
private void button3_Click(object sender, EventArgs e) { NieuweFunctie frm = new NieuweFunctie(); if (frm.ShowDialog(this) == DialogResult.OK) { switch (frm.GekozenSoort) { case Functie.enFunctie_type.gui: GrafischeFunctie nieuwgf = new GrafischeFunctie(); nieuwgf.Naam = "nieuwe functie"; functies.Add(nieuwgf); Functies.Items.Add(nieuwgf.Naam); break; case Functie.enFunctie_type.tekst: TekstFunctie nieuwtf = new TekstFunctie(); nieuwtf.Parse("function nieuwefunctie()\r\n{\r\n}"); functies.Add(nieuwtf); Functies.Items.Add("nieuwefunctie"); break; } } }
void MaakFuncties() { foreach (string bestand in Directory.GetFiles(mapnaam_func)) { FileStream fs = new FileStream(bestand, FileMode.Open); Rijndael rijAlg = Rijndael.Create(); rijAlg.Key = key; rijAlg.IV = IV; ICryptoTransform decryptor = rijAlg.CreateDecryptor(key, IV); CryptoStream cs = new CryptoStream(fs, decryptor, CryptoStreamMode.Read); StreamReader reader = new StreamReader(cs); string soort_functie = reader.ReadLine(); switch (soort_functie) { case "gui": GrafischeFunctie f1 = new GrafischeFunctie(); f1.Beschrijving = reader.ReadLine(); f1.Voorschrift = reader.ReadLine(); f1.Naam = Path.GetFileNameWithoutExtension(bestand); string tekst = reader.ReadToEnd().Trim(); string[] par = tekst.Split(new string[] { "\r\n\r\n" }, StringSplitOptions.None); string parameters = par[0]; string tmp = par.Length < 2 ? "" : par[1]; foreach (string paramtekst in parameters.Split(new string[] { "\r\n" }, StringSplitOptions.None)) { Parameter p = new Parameter(); string[] it = paramtekst.Split(';'); p.Naam = it[0]; p.Beschrijving = it[1]; p.Is_Getal = it[2] == "getal"; p.EnumNaam = p.Is_Getal ? "" : it[2]; p.Optioneel = it[3] == "1"; p.StandaardWaarde = Convert.ToDouble(it[4]); f1.Parameters.Add(p); } if (tmp != "") { foreach (string tmp_var in tmp.Split(new string[] { "\r\n" }, StringSplitOptions.None)) { Tmp_Param p = new Tmp_Param(); string[] it = tmp_var.Split(';'); p.Naam = it[0]; p.Beschrijving = it[1]; p.Berekening = it[2]; f1.Temp.Add(p); } } functies.Add(f1); Functies.Items.Add(f1.Naam); break; case "tekst": TekstFunctie f2 = new TekstFunctie(); f2.Parse(reader.ReadToEnd()); functies.Add(f2); Functies.Items.Add(Path.GetFileNameWithoutExtension(bestand)); break; } reader.Close(); fs.Close(); } }
private void Functies_SelectedIndexChanged(object sender, EventArgs e) { changing = true; button1.Enabled = Functies.SelectedIndex != -1; if (Functies.SelectedIndex != -1) { Functie item = functies[Functies.SelectedIndex]; switch (item.Functie_Type) { case Functie.enFunctie_type.gui: txtCode.Hide(); txtFunctieBeschrijving.Enabled = true; txtFunctieNaam.Enabled = true; txtFunctieVoorschrift.Enabled = true; GrafischeFunctie f = (GrafischeFunctie)functies[Functies.SelectedIndex]; txtFunctieNaam.Text = f.Naam; txtFunctieBeschrijving.Text = f.Beschrijving; txtFunctieVoorschrift.Text = f.Voorschrift; listView1.Items.Clear(); foreach (Parameter param in f.Parameters) { ListViewItem lvi = new ListViewItem(); lvi.Text = param.Naam; lvi.SubItems.Add(param.Is_Getal ? "Getal" : param.EnumNaam); lvi.SubItems.Add(param.Beschrijving); lvi.SubItems.Add(param.Optioneel ? "ja" : "nee"); lvi.SubItems.Add(param.Is_Getal ? param.StandaardWaarde.ToString() : ""); listView1.Items.Add(lvi); } listView2.Items.Clear(); foreach (Tmp_Param param in f.Temp) { ListViewItem lvi = new ListViewItem(); lvi.Text = param.Naam; lvi.SubItems.Add(param.Beschrijving); lvi.SubItems.Add(param.Berekening); listView2.Items.Add(lvi); } pnlGrafischeFunctie.Show(); break; case Functie.enFunctie_type.tekst: pnlGrafischeFunctie.Hide(); TekstFunctie ft = (TekstFunctie)functies[Functies.SelectedIndex]; txtCode.Text = ft.ToString(); txtCode.Show(); break; default: break; } } else { txtFunctieBeschrijving.Enabled = false; txtFunctieNaam.Enabled = false; txtFunctieVoorschrift.Enabled = false; pnlGrafischeFunctie.Hide(); txtCode.Hide(); } EnableParamAddButtons(this, EventArgs.Empty); changing = false; }