Using Visual studio Orion is one of the most famous constellations in the night
ID: 667909 • Letter: U
Question
Using Visual studio
Orion is one of the most famous constellations in the night sky. In the Chap02 folder
of the Student Sample Programs that accompany this book, you will find an image
file named Orion.bmp, which contains a diagram of the Orion constellation. Create
an application that displays the Orion image in a PictureBox control, as shown on
the left in Figure 2-82 . The application should have a button that, when clicked,
displays the names of each of the stars, as shown on the right in Figure 2-82 . The
application should have another button that, when clicked, hides the star names.
The names of the stars are Betelgeuse , Meissa , Alnitak , Alnilam , Mintaka , Saiph ,
and Rigel .
Hint: Place the PictureBox control with the Orion image on the form. Then, place
Label controls containing the star names on top of the PictureBox. Use the Properties
window to set each of the Label control’s Visible property to False. That
will cause the labels to be invisible when the application runs. The Show Star
Names button will set each of the Label control’s Visible property to true , and
the Hide Star Names button will set each of the Label control’s Visible property
to false .
Explanation / Answer
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace P1JMB { public partial class starWind : Form { //initialization of designer code public starWind() { InitializeComponent(); } // show label buttons => setting all labels to Visible = true; private void showStar_Click(object sender, EventArgs e) { betelgeuseLabel.Visible = true; meissaLabel.Visible = true; mintakaLabel.Visible = true; alnilamLabel.Visible = true; alnitakLabel.Visible = true; saiphLabel.Visible = true; rigelLabel.Visible = true; } // hide label buttons => setting all labels to Visible = false; private void hideStar_Click(object sender, EventArgs e) { betelgeuseLabel.Visible = false; meissaLabel.Visible = false; mintakaLabel.Visible = false; alnilamLabel.Visible = false; alnitakLabel.Visible = false; saiphLabel.Visible = false; rigelLabel.Visible = false; } // exit program button private void exitButton_Click(object sender, EventArgs e) { this.Close(); } private void orionImage_Click(object sender, EventArgs e) { } } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.