软件需求及编码提示:
该软件包含一个主窗体,设置窗体大小:1000* 800。
设置窗体为:无边框窗体。//这个在窗体属性FormBorderStyle设置为None
设置窗体的起始显示位置为:屏幕中心。 //StartPosition设置为 centerscreen
设置窗体的背景图片为main2.jpg。(该素材图片在考生的素材文件夹下)//窗体上面放图片是设置属性BackGroundImage,导入图片资源
添加Label控件,text属性设置为“携程在手”, 背景颜色设置为透明,字体为:方正姚体, 40pt, style=Bold。颜色为黑色。 //很容易就不说了
添加Button控件,text属性设置为“说走就走”, 字体为:方正姚体, 25pt。
窗体又上角添加PictureBox控件, 背景图片设置为guanbi.png。 (该素材图片在考生的素材文件夹下)//也是设置BackGroundImage
设置Button控件,PictureBox控件的光标为Hand。
编写代码,当用户鼠标移入移出关闭图片的时候,该控件的背景色移出的时候为Transparent,移入的时候为Red。
//这个要打开所创建PictureBox的属性,在MouseEnter和MouseLeave上面都双击,在创建的方法体里面写代码
MouseEnter就是在鼠标进入的时候要做什么,MouseLeave就是在鼠标离开的时候要写什么
private void PictureBox1_MouseEnter(object sender, EventArgs e)
{
pictureBox1.BackColor = Color.Transparent;
}
private void PictureBox1_MouseLeave(object sender, EventArgs e)
{
pictureBox1.BackColor = Color.Red;
}
编写代码,当用户点击按钮或者关闭图片的时候,关闭主窗体,退出程序。
private void Button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Travel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Label1_Click(object sender, EventArgs e)
{
}
private void PictureBox1_MouseEnter(object sender, EventArgs e)
{
pictureBox1.BackColor = Color.Transparent;
}
private void PictureBox1_MouseLeave(object sender, EventArgs e)
{
pictureBox1.BackColor = Color.Red;
}
private void PictureBox1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void Button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}