Ejemplo n.º 1
0
        //read through ctrl m+o

        public Form1()
        {
            InitializeComponent();
            fillListBoxes();
            this.bt_save.Enabled           = false;
            this.gb_lockdownPolicy.Enabled = false;
            this.gb_time.Enabled           = false;
            simulationTime = new SimulationTime();
            initializeHeatMaps();
            initializeCurveGraph();

            //Selecting default values in optional groupbox
            listBox_culture.SelectedIndex          = 1;
            listBox_doctorPercentage.SelectedIndex = 3;
            listBox_areaSize.SelectedIndex         = 4;
            listBox_herdPercentage.SelectedIndex   = 2;
            listBox_nursePercentage.SelectedIndex  = 5;
        }
Ejemplo n.º 2
0
        private void bt_load_Click(object sender, EventArgs e)
        {
            //TODO deserialize hospital, community, simulationTime, stopwatch objects
            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "Save files (*.csimsave)|*.csimsave";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    FileStream fileStream = null;
                    try
                    {
                        fileStream = new FileStream(ofd.FileName, FileMode.OpenOrCreate);
                        BinaryFormatter binaryFormatter = new BinaryFormatter();
                        object          h = binaryFormatter.Deserialize(fileStream);
                        if (h is Hospital)
                        {
                            hospital = (Hospital)h;
                        }
                        object c = binaryFormatter.Deserialize(fileStream);
                        if (c is Community)
                        {
                            community = (Community)c;
                        }
                        object st = binaryFormatter.Deserialize(fileStream);
                        if (st is SimulationTime)
                        {
                            simulationTime = (SimulationTime)st;
                        }
                    }
                        #pragma warning disable 0168
                    catch (SerializationException ex) { }
                        #pragma warning restore 0168
                        #pragma warning disable 0168
                    catch (IOException ex) { }
                        #pragma warning restore 0168

                    finally { fileStream.Close(); }
                }
            }
            UpdateGUI();
        }