示例#1
0
 private void btAddFish_Click(object sender, EventArgs e)
 {
     using (var fm = new FishForm())
     {
         if (fm.ShowDialog() == DialogResult.OK)
         {
             if (fm.shark != null)
             {
                 //timer.enabled = false;
                 //animal wrapper
                 //timer.enabled = true;
             }
         }
     }
 }
示例#2
0
        private void btAddFish_Click(object sender, EventArgs e)
        {
            var fm = new FishForm();

            using (fm)
            {
                if (fm.ShowDialog() == DialogResult.OK)
                {
                    if (fm.shark != null)
                    {
                        //  MyTimer.Enabled = false;
                        currentAquarium.AllAnimalsCollection.Add(fm.shark);
                        currentAquarium.FishCollection.Add(fm.shark);
                        var aw = new AnimalWrapper(fm.shark);
                        animals.Add(aw);
                        //PictureBox pb = new PictureBox();
                        //pb.Location = new Point(animal.XPossition, animal.YPossition);
                        //pb.Image = animal.Img;
                        this.Controls.Add(aw.picBox);
                        //animal wrapper
                        textBox1FishNumber.Text = currentAquarium.FishCollection.Count().ToString();
                        MessageBox.Show("You successfully added a new shark", "Happy little shark", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //  MyTimer.Enabled = true;
                    }
                    if (fm.goldFish != null)
                    {
                        MyTimer.Enabled = false;
                        currentAquarium.AllAnimalsCollection.Add(fm.goldFish);
                        currentAquarium.FishCollection.Add(fm.goldFish);
                        var aw = new AnimalWrapper(fm.goldFish);
                        animals.Add(aw);
                        this.Controls.Add(aw.picBox);
                        textBox1FishNumber.Text = currentAquarium.FishCollection.Count().ToString();
                        MessageBox.Show("You successfully added a new goldfish", "Happy little goldfish", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyTimer.Enabled = true;
                    }
                }
            }
        }