コード例 #1
0
ファイル: Form1.cs プロジェクト: Morozbea/AnimalHotel
        // Show the selected animals informations its their textboxes or comboboxes
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox_Animals.SelectedIndex > -1)
            {
                Animal an = m_anim_mngr.GetAt(listBox_Animals.SelectedIndex);

                genderCmb.SelectedIndex = (int)an.GenderOfAnimal;
                nameTxtBox.Text         = an.Name;
                ageTxtBox.Text          = an.Age.ToString();

                if (an is Eagle)
                {
                    Eagle eg = (Eagle)an;
                    categoryCmb.SelectedIndex  = (int)Category.Bird;
                    animalObjCmb.SelectedIndex = (int)Bird.Eagle;
                    textBox1.Text = eg.WingsLength.ToString();
                    textBox2.Text = eg.BirdType;
                    UpdateLabel(Category.Bird);
                    comboBoxEaterType.SelectedIndex = (int)an.GetEaterType();
                    SpecieNameLbl.Text = an.GetSpecies();

                    string[] list = an.GetFoodSchedule().GetFoodSchedule();
                    listbox_Food_Schedule.Items.AddRange(list);
                }

                if (an is Duck)
                {
                    Duck duck = (Duck)an;
                    categoryCmb.SelectedIndex  = (int)Category.Bird;
                    animalObjCmb.SelectedIndex = (int)Bird.Duck;
                    textBox1.Text = duck.WingsLength.ToString();
                    textBox2.Text = duck.BirdType;
                    UpdateLabel(Category.Bird);
                    comboBoxEaterType.SelectedIndex = (int)an.GetEaterType();
                    SpecieNameLbl.Text = an.GetSpecies();

                    string[] list = an.GetFoodSchedule().GetFoodSchedule();
                    listbox_Food_Schedule.Items.AddRange(list);
                }

                if (an is Chicken)
                {
                    Chicken chick = (Chicken)an;
                    categoryCmb.SelectedIndex  = (int)Category.Bird;
                    animalObjCmb.SelectedIndex = (int)Bird.Chicken;
                    textBox1.Text = chick.WingsLength.ToString();
                    textBox2.Text = chick.BirdType;
                    UpdateLabel(Category.Bird);
                    comboBoxEaterType.SelectedIndex = (int)an.GetEaterType();
                    SpecieNameLbl.Text = an.GetSpecies();

                    string[] list = an.GetFoodSchedule().GetFoodSchedule();
                    listbox_Food_Schedule.Items.AddRange(list);
                }

                if (an is Deer)
                {
                    Deer deer = (Deer)an;
                    categoryCmb.SelectedIndex  = (int)Category.Mammal;
                    animalObjCmb.SelectedIndex = (int)Mammal.Deer;
                    textBox1.Text = deer.NumberOfTooth.ToString();
                    textBox2.Text = deer.LengthOfTail;
                    UpdateLabel(Category.Mammal);
                    comboBoxEaterType.SelectedIndex = (int)an.GetEaterType();
                    SpecieNameLbl.Text = an.GetSpecies();

                    string[] list = an.GetFoodSchedule().GetFoodSchedule();
                    listbox_Food_Schedule.Items.AddRange(list);
                }

                if (an is Cat)
                {
                    Cat cat = (Cat)an;
                    categoryCmb.SelectedIndex  = (int)Category.Mammal;
                    animalObjCmb.SelectedIndex = (int)Mammal.Cat;
                    textBox1.Text = cat.NumberOfTooth.ToString();
                    textBox2.Text = cat.LengthOfTail;
                    UpdateLabel(Category.Mammal);
                    comboBoxEaterType.SelectedIndex = (int)an.GetEaterType();
                    SpecieNameLbl.Text = an.GetSpecies();

                    string[] list = an.GetFoodSchedule().GetFoodSchedule();
                    listbox_Food_Schedule.Items.AddRange(list);
                }

                if (an is Dog)
                {
                    Dog cat = (Dog)an;
                    categoryCmb.SelectedIndex  = (int)Category.Mammal;
                    animalObjCmb.SelectedIndex = (int)Mammal.Dog;
                    textBox1.Text = cat.NumberOfTooth.ToString();
                    textBox2.Text = cat.LengthOfTail;
                    UpdateLabel(Category.Mammal);
                    comboBoxEaterType.SelectedIndex = (int)an.GetEaterType();
                    SpecieNameLbl.Text = an.GetSpecies();

                    string[] list = an.GetFoodSchedule().GetFoodSchedule();
                    listbox_Food_Schedule.Items.AddRange(list);
                }
            }
        }