Beispiel #1
0
        private void openToolStripMenuOpen_Click(object sender, EventArgs e)
        {
            debug    = this.cBDebugPoint.Checked;
            cardebug = this.cBDebugCars.Checked;

            if (selectedPicBox != null)
            {
                unselectCurrentCrossing();
            }

            if (Simulation.Saved == true)
            {
                Clear();
            }
            else
            {
                DialogResult dResult = MessageBox.Show("Would you like to save your changes? Unsaved changes will be lost.", "New simulation", MessageBoxButtons.YesNoCancel);
                if (dResult == DialogResult.Yes)
                {
                    Simulation.SaveAs(Simulation.Name);
                    SaveToFile();

                    Clear();
                }
                else if (dResult == DialogResult.No)
                {
                    Clear();
                }
            }


            if (!GetFromFile())
            {
                MessageBox.Show("Error whilst loading file");
            }
            else
            {
                foreach (Crossing item in Simulation.Crossings)
                {
                    tempCrossing.Add(item);
                }
                Simulation.Crossings.Clear();

                foreach (Crossing cr in tempCrossing)
                {
                    if (cr.GetType() == typeof(Crossing_A))
                    {
                        Crossing_A cra = new Crossing_A(cr.CrossingId);
                        Simulation.AddCrossing(cra);
                        CrossingType(cra);
                    }
                    else
                    {
                        Crossing_B crb = new Crossing_B(cr.CrossingId);
                        Simulation.AddCrossing(crb);
                        CrossingType(crb);
                    }
                }
            }
        }
        private void openToolStripMenuOpen_Click(object sender, EventArgs e)
        {
            debug = this.cBDebugPoint.Checked;
            cardebug = this.cBDebugCars.Checked;

            if (selectedPicBox != null)
            {
                unselectCurrentCrossing();
            }

            if (Simulation.Saved == true)
            {
                Clear();
            }
            else
            {
                DialogResult dResult = MessageBox.Show("Would you like to save your changes? Unsaved changes will be lost.", "New simulation", MessageBoxButtons.YesNoCancel);
                if (dResult == DialogResult.Yes)
                {
                    Simulation.SaveAs(Simulation.Name);
                    SaveToFile();

                    Clear();
                }
                else if (dResult == DialogResult.No)
                {
                    Clear();
                }
            }


            if (!GetFromFile())
            {
                MessageBox.Show("Error whilst loading file");
            }
            else
            {
                foreach (Crossing item in Simulation.Crossings)
                {
                    tempCrossing.Add(item);
                }
                Simulation.Crossings.Clear();

                foreach (Crossing cr in tempCrossing)
                {
                    if (cr.GetType() == typeof(Crossing_A))
                    {
                        Crossing_A cra = new Crossing_A(cr.CrossingId);
                        Simulation.AddCrossing(cra);
                        CrossingType(cra);
                    }
                    else
                    {
                        Crossing_B crb = new Crossing_B(cr.CrossingId);
                        Simulation.AddCrossing(crb);
                        CrossingType(crb);
                    }

                }

            }
        }