Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Toevoegen Locatie 1
            if (comboBox1.Text != "Geen")
            {
                nw = createKruispunt(comboBox1);

            }

            //Toevoegen Locatie 2
            if (comboBox2.Text != "Geen")
            {
                ne = createKruispunt(comboBox2);

            }

            //Toevoegen Locatie 3
            if (comboBox3.Text != "Geen")
            {
                sw = createKruispunt(comboBox3);

            }

            //Toevoegen Locatie 4
            if (comboBox4.Text != "Geen")
            {
                se = createKruispunt(comboBox4);

            }

            initKruispunten();

            simulator.InitMap(nw.Component, ne.Component, sw.Component, se.Component);

            ai = new Ai.Ai(simulator);

            button2.Enabled = true;
        }
Example #2
0
        private void load_Click(object sender, EventArgs e)
        {
            bool enabled = timer1.Enabled;
            timer1.Enabled = false;

            simulator.postSimulate -= postSimulateEvent;

            OpenFileDialog openDialog = new OpenFileDialog();
            openDialog.Filter = "simulatiebestand (*.sim)|*.sim";
            openDialog.CheckPathExists = true;
            openDialog.CheckFileExists = true;
            openDialog.Title = "Kies een bestand om op te slaan";

            if (openDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    FileStream bestand = File.OpenRead(openDialog.FileName);
                    BinaryFormatter formatter = new BinaryFormatter();

                    simulator = (Simulator)formatter.Deserialize(bestand);
                    nw = loadKruispunt((IKruispunt)formatter.Deserialize(bestand));
                    ne = loadKruispunt((IKruispunt)formatter.Deserialize(bestand));
                    se = loadKruispunt((IKruispunt)formatter.Deserialize(bestand));
                    sw = loadKruispunt((IKruispunt)formatter.Deserialize(bestand));
                    ai = (Ai.Ai)formatter.Deserialize(bestand);

                    initKruispunten();
                    button2.Enabled = true;
                    button3.Enabled = true;

                    simulator.postSimulate += postSimulateEvent;
                    timer1.Enabled = true;

                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Er is een fout opgetreden bij het laden!");
                }
            }

            simulator.postSimulate += postSimulateEvent;
        }