你好,堆栈溢出社区,
我已经接受了为我正在开发的游戏制作安装程序/启动器的项目,目前我遇到了一个问题,我希望安装程序在屏幕分辨率的中心打开,并具有基本UI,如下所示:
中间名为"MainText“的标签已预先配置为”正在配置“,角落中还有一个名为"label1”的隐藏标签,用于调试目的。
到目前为止,我在MainForm.cs中的代码如下,“程序路径”指的是应用程序所在的当前目录。
public MainForm()
{
//Open Window
InitializeComponent();
//placeholder song
System.Media.SoundPlayer player = new System.Media.SoundPlayer(programpath+"\\GTA 4 Loading Screen Normalized No intro.wav");
player.PlayLooping();
//newLaunch();
}
void newLaunch(){
File.Create(programpath+"\\FirstLaunch.lic");
MainText.Visible=true;
MainText.Text="Configuring Machine....\nInstalling DirectX";
Process.Start(programpath+"\\dxwebsetup.exe");
label1.Text=programpath+"\\dxwebsetup.exe";
}
但是,如果我取消对"newLaunch()“的注释,dxwebsetup应用程序将打开,然后实际的UI打开,其中MainText显示"Configuring Machine....Installing DirectX",label1显示安装程序的位置。
我如何使应用程序本身的UI显示出来,然后开始运行代码after....similar到实际的安装程序,但是仍然是完全自主的,并自行安装所有内容。
发布于 2018-06-13 08:29:56
如果我对您的问题的理解是正确的,那么您需要做的就是添加一个处理程序来处理表单的显示时间。当InitializeComponent完成调用时,并不意味着表单已经完全打开。
在InitializeComponent之后(或者最好是在内部),您可以简单地添加
Load += OnLoad;
紧接着是
public void OnLoad(object sender, EventArgs e)
{
}
您可以在其中添加或调用启动函数。
https://stackoverflow.com/questions/50827523
复制相似问题