📄 quizresultform.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MySchool
{
public partial class QuizResultForm : Form
{
public QuizResultForm()
{
InitializeComponent();
}
// 退出应用程序
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
// 显示分数
private void QuizResultForm_Load(object sender, EventArgs e)
{
// 计算答对的题目数量
int correctNum = 0;
for (int i = 0; i < QuizHelper.questionNum; i++)
{
if (QuizHelper.studentAnswers[i] == QuizHelper.correctAnswers[i])
{
correctNum++;
}
}
// 计算得分
int score = correctNum * 100 / QuizHelper.questionNum;
lblMark.Text = score.ToString()+"分";
// 确定显示分数的label的宽度
lblStudentScoreStrip.Width = lblFullMarkStrip.Width * score / 100;
// 根据不同的得分,显示不同的颜色
if (score < 60)
{
lblStudentScoreStrip.BackColor = Color.Red;
lblComment.Text = "该好好复习啦!";
picFace.Image = ilFaces.Images[0];
}
else if (score >= 60 && score < 85)
{
lblStudentScoreStrip.BackColor = Color.Blue;
lblComment.Text = "还不错,继续努力哦!";
picFace.Image = ilFaces.Images[1];
}
else if (score >= 85 && score < 100)
{
lblStudentScoreStrip.BackColor = Color.CornflowerBlue;
lblComment.Text = "真厉害,得了优秀呢!";
picFace.Image = ilFaces.Images[2];
}
else if (score == 100)
{
lblStudentScoreStrip.BackColor = Color.Green;
lblComment.Text = "你真棒,全都答对了!";
picFace.Image = ilFaces.Images[3];
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -