Пример #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            double panelWidth  = this.Size.Width * MeterPerPanelPixel;
            double panelHeight = this.Size.Height * MeterPerPanelPixel;

            if (Humans.Count < NumOfHumans)
            {
                HumanDataBase human = new HumanDataBase(panelWidth, panelHeight, MinSpeed, MaxSpeed, MaxRadius, MinRadius, MaxDestinationRadius);
                Humans.Add(human);
            }
            else if (IsInitiated == false)
            {
                Random rnd = new Random();
                int    idx = rnd.Next(0, Humans.Count);
                Humans[idx].SetInfection();
                IsInitiated = true;
            }

            int healthy  = 0;
            int infected = 0;
            int opensic  = 0;

            OutputTxT.Text = "";
            foreach (HumanDataBase human in Humans)
            {
                HumanDataBase.InfectionStat stat = human.Go();
                switch (stat)
                {
                case HumanDataBase.InfectionStat.Healthy:
                    healthy++;
                    break;

                case HumanDataBase.InfectionStat.Infected:
                    infected++;
                    break;

                case HumanDataBase.InfectionStat.OpenSick:
                    opensic++;
                    break;
                }
            }

            label1.Text = "Gesund: " + healthy.ToString();
            label2.Text = "Infiziert: " + infected.ToString();
            label3.Text = "Krank: " + opensic.ToString();


            this.Invalidate();
        }
Пример #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Height = Convert.ToInt32(ConfigurationManager.AppSettings["ScreenY"]);
            this.Width  = Convert.ToInt32(ConfigurationManager.AppSettings["ScreenX"]);

            double panelWidth  = this.Size.Width * MeterPerPanelPixel;
            double panelHeight = this.Size.Height * MeterPerPanelPixel;

            HumanDataBase human = new HumanDataBase(panelWidth, panelHeight, MinSpeed, MaxSpeed, MaxRadius, MinRadius, MaxDestinationRadius);

            Humans.Add(human);

            timer1.Enabled = true;
            timer1.Start();
        }