Beispiel #1
0
        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;
        }
Beispiel #2
0
        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;
        }