xml
复制代码
<Window>
<Grid x:Name="LoadingLayer" Background="#FF0A0A0A" >
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<ProgressBar x:Name="LoadingProgress" Visibility="Hidden" Width="400" Height="20" Margin="0,0,0,20" IsIndeterminate="True" Foreground="#FF4A90E2" ></ProgressBar>
<TextBlock x:Name="LoadingText" Text="" HorizontalAlignment="Center" Foreground="#CCFFFFFF" FontSize="18" FontWeight="SemiBlod"></TextBlock>
</StackPanel>
</Grid>
</Window>
csharp
复制代码
namespace project
{
public partial class MainWindow : Window
{
public MainWindow()
{
this.Topmost = true;
this.Left = 0.0;
this.Top = 0.0;
this.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
this.Height = System.Windows.SystemParameters.PrimaryScreenHeight;
this.WindowState = System.Windows.WindowState.Normal;
this.WindowStyle = System.Windows.WindowStyle.None;
this.ResizeMode = System.Windows.ResizeMode.NoResize;
this.Loaded += ShowWindow;
}
protected override void OnKeyDown(RoutedEventArgs e)
{
if(e.Key == Key.Escape)
{
Application.current.ShutDown();
}
base.OnKeyDown(e);
}
private async Task Wait()
{
await Task.Delay(2000);
}
private async void ShowWindow(object sender, RoutedEventArgs e)
{
await Wait();
LoadingProgress.Visibility=Visibility.Visible;
await LoadingRes();
}
private async Task LoadingRes()
{
for(int i=0;i<100;i++)
{
await Task.Delay(60);
if(i<60)
LoadingText = "正在初始化核心模块...";
else if(i<90)
LoadingText = "正在加载用户数据...";
else
LoadingText = "正在创建游戏场景...";
}
LoadingProgress.Visibility=Visibility.Hidden;
LoadingText.Visibility = Visibility.Hidden;
}
}
}