Пример #1
0
        /// <summary>
        /// Launches the cage window.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void showCageButton_Click(object sender, RoutedEventArgs e)
        {
            // Gets the animal from the animal list box.
            Animal animal = (Animal)animalListBox.SelectedItem;

            // Find the cage based on the animal's type.
            Cage cage = zoo.FindCage(animal.GetType());

            // If an animal was selected, create a new cage window and put the animal in the cage.
            if (animal != null)
            {
                CageWindow cageWindow = new CageWindow(cage);


                cageWindow.Show();
                //if (cageWindow.ShowDialog() == true)
                //{
                //}
            }
            // Ask user to select an animal.
            else
            {
                MessageBox.Show("Please select an aniaml to put in the cage.");
            }
        }
Пример #2
0
        /// <summary>
        /// Shows the animal cage.
        /// </summary>
        /// <param name="sender">The object that initiated the event.</param>
        /// <param name="e">The event arguments of the event.</param>
        private void showCageButton_Click(object sender, RoutedEventArgs e)
        {
            Animal animal = this.animalListBox.SelectedItem as Animal;

            if (animal != null)
            {
                CageWindow window = new CageWindow
                                    (
                    this.comoZoo.FindCage(animal.GetType())
                                    );

                window.Show();
            }
        }
        /// <summary>
        /// Shows the cage of the specified animal.
        /// </summary>
        /// <param name="sender">The object that initiated the event.</param>
        /// <param name="e">The arguments of the event.</param>
        private void showCageButton_Click(object sender, RoutedEventArgs e)
        {
            Animal animal = this.animalListBox.SelectedItem as Animal;

            if (animal != null)
            {
                Cage cage = this.comoZoo.FindCage(animal.GetType());

                CageWindow window = new CageWindow(cage);

                window.Show();
            }
            else
            {
                MessageBox.Show("Select an animal whose cage to show.");
            }
        }
Пример #4
0
        /// <summary>
        /// Shows the cage window.
        /// </summary>
        /// <param name="sender">System data.</param>
        /// <param name="e">Associated event data.</param>
        private void showCageButton_Click(object sender, RoutedEventArgs e)
        {
            // Get the animal selected in the list box.
            Animal animal = this.animalListBox.SelectedItem as Animal;

            if (animal != null)
            {
                // Get the cage of the animal selected.
                Cage cageResult = comoZoo.FindCage(animal.GetType());

                CageWindow cageWindow = new CageWindow(cageResult);
                cageWindow.Show();
            }
            else
            {
                MessageBox.Show("You must select an animal to show.");
            }
        }