我想创建一个新组件,当我调用.show()方法时,它将显示一个启动画面。该组件必须像Windows窗体一样具有图像和以毫秒为单位的持续时间,如同参数一样传递。我应该在Visual Studio中选择哪种类型的项目?如果我选择一个ClassLibrary,它创建一个dll类,但如果我选择一个新的ControlLibrary它创建一个新的控件,但我不能使用Windows窗体。为SplashScreen创建一个C#组件
protected int nSec;
public SplashScreen(string img, int nSec)
{
// duration
this.nSec = nSec;
// background splash screen
this.BackgroundImage = Image.FromFile("img.jpg");
InitializeComponent();
}
private void SplashScreen_Load(object sender, EventArgs e)
{
timer1.Interval = nSec * 1000;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Close()
}
我希望在未来的其他工作中重复使用此“组件”,而不是每次都创建一个新组件。
您需要像Windows窗体一样的东西,但不能使用Windows窗体。你的意思是你不能使用Windows窗体项目模板?或者你不能使用Form对象? –
听起来像他们希望你创建一个类库并让它创建表单,那么显然可以调用引用该库并在需要启动屏幕时调用所需的函数。 –
但我应该创建一个包含Windows窗体的ClassLibrary和我的Splash Screen? – user2921326