P h i l

advertisement
Philadelphia University
Lecturer
: Mrs. Eman Alnaji
Coordinator : Miss. Reem AlQaqa
Internal Examiner: Dr. Nameer Al Emam
Visual Programming (761220)
Date: 26-11-2014
First Exam
I
Faculty of Information Technology
Department of CIS
Examination Paper
First Semester of 2014-2015
Time: 60 minutes
Information for Candidates
1. This examination paper contains four questions, totaling 22 marks (2 bonus)
2. The marks for parts of questions are shown in square brackets.
Advice to Candidates
1. You should attempt all questions.
2. You should write your answers clearly.
I. Basic concepts
Objective: The aim of the questions in this part is to evaluate your knowledge and skills concerning with the basic
concepts of windows programming using .NET environment
Question1: Choose the correct answer of the following:
[5 Marks, 1 Mark each]
1. Which of the following windows contains the control items that you can add to a form:
A) Events Window
B) Properties Window
C) Solution Explorer
D) Toolbox
2. Which of the following control items display a text that can be edited by the user?
A) CheckBox
B) TextBox
C) Label
D) Panel
3. Which of the following options is considered a container?
A) RadioButton
B) Menu
C) Form
D) Button
4. CheckedChanged is the default event of:
A) TextBox
B) RadioButton
C) CheckBox
D) B+C
5. The property you use to change the font color of the text written in a label, is:
A) FontColor
B) BackColor
C) Color
D) ForeColor
1
II. Familiar Problem Solving
Objective: The aim of the questions in this part is to evaluate that the student has some basic knowledge of the
key aspects of the lecture material and can attempt to solve familiar problems.
Question2: Answer the following:
[Total: 4 Marks]
1. Write a C# code that hides a button named “button1”.
button1.hide();
or
button1.visible = false;
2. Write a C# code that concatenates the values of two textboxes, “t1” and “t2” and displays the new
value in textbox “t3”
t3.Text = t1.Text + t2.Text;
3. In the form displayed below,
a. specify the property that makes the button looks this way (i.e. the button covers the whole
form area)
Dock
b. And specify the value of this property.
fill
2
Question3: Create a form as displayed below, which performs the following: [Total: 7 Marks]
1. Activate the checkboxes (Bold, Italic and Underline) to behave together as shown in the image
above, and change the style of the label font.
(3 Marks)
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
label1.Font = new Font(label1.Font.Name, label1.Font.Size,
label1.Font.Style ^ FontStyle.Bold);
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
label1.Font = new Font(label1.Font.Name, label1.Font.Size,
label1.Font.Style ^ FontStyle.Italic);
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
label1.Font = new Font(label1.Font.Name, label1.Font.Size,
label1.Font.Style ^ FontStyle.Underline);
}
2. Use the appropriate keyboard event(s), to change the color of the form background as follows:
-
When 'R' is pressed, the background becomes red.
When 'G' is pressed, the background becomes green.
When Ctrl + 'Z' are pressed, the background returns to gray.
3
(4 Marks)
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.R)
this.BackColor = Color.Red;
else if (e.KeyCode == Keys.G)
this.BackColor = Color.Green;
else if (e.KeyCode == Keys.Z && e.Control)
this.BackColor = Color.Gray;
}
III. Unfamiliar Problem Solving
Objective: The aim of the question in this part is to evaluate that student can solve familiar problems with ease
and can make progress toward the solution of unfamiliar problems, and can set out reasoning and explanation in
clear and coherent manner of the topics related to the function.
Question4: Create the following form, which should perform the following: [6 Marks]
4
1. When the user enters the mouse into the picture box, an image named "p1.jpg" should appear in it,
when the mouse leaves another image "p2.jpg" should appear.
(2 Marks)
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile("f:\\ex\\p1.jpg");
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile("f:\\ex\\p2.jpg");
}
2. When the user clicks "Close" menu item, the following message should be displayed: (2 Marks)
If the user clicks "Yes", the form should be closed, otherwise just close the message.
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult r = MessageBox.Show("Are you sure you want to close?",
"Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (r == DialogResult.Yes)
Close();
5
}
3. From Submenu "Size Mode", change the SizeMode Property of the picture box, according to the
user's click.
(2 Marks – Bonus)
private void centerImageToolStripMenuItem_Click(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
}
private void stretchImageToolStripMenuItem_Click(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
}
private void normalToolStripMenuItem_Click(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Normal;
}
Good Luck
6
Download