Exemple #1
0
        private void button2AddMullusk_Click(object sender, EventArgs e)
        {
            var mf = new MulluskForm();

            using (mf)
            {
                if (mf.ShowDialog() == DialogResult.OK)
                {
                    if (mf.octopus != null)
                    {
                        MyTimer.Enabled = false;
                        currentAquarium.AllAnimalsCollection.Add(mf.octopus);
                        currentAquarium.MolluskCollection.Add(mf.octopus);
                        var aw = new AnimalWrapper(mf.octopus);
                        //  aw.picBox.Name = mf.octopus.AnimalName;
                        animals.Add(aw);
                        this.Controls.Add(aw.picBox);
                        this.Controls.Add(aw.labelName);
                        textBox2MolluskNumber.Text = currentAquarium.MolluskCollection.Count().ToString();
                        MessageBox.Show("You successfully added a new octopus", "Happy little octopus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyTimer.Enabled = true;
                    }
                }
                if (mf.starFish != null)
                {
                    MyTimer.Enabled = false;
                    currentAquarium.AllAnimalsCollection.Add(mf.starFish);
                    currentAquarium.MolluskCollection.Add(mf.starFish);
                    var aw = new AnimalWrapper(mf.starFish);
                    animals.Add(aw);
                    this.Controls.Add(aw.picBox);
                    textBox2MolluskNumber.Text = currentAquarium.MolluskCollection.Count().ToString();
                    MessageBox.Show("You successfully added a new starfish", "Happy little starfish", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyTimer.Enabled = true;
                }
                if (mf.snail != null)
                {
                    MyTimer.Enabled = false;
                    currentAquarium.AllAnimalsCollection.Add(mf.snail);
                    currentAquarium.MolluskCollection.Add(mf.snail);
                    var aw = new AnimalWrapper(mf.snail);
                    animals.Add(aw);
                    this.Controls.Add(aw.picBox);
                    textBox2MolluskNumber.Text = currentAquarium.MolluskCollection.Count().ToString();
                    MessageBox.Show("You successfully added a new snail", "Happy little snail", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyTimer.Enabled = true;
                }
            }
        }
Exemple #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;
                    }
                }
            }
        }