WPF demo:全屏加载界面

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;
        }
        
    }
}
相关推荐
FuckPatience3 分钟前
WPF 程序用户权限模块利用MarkupExtension实现控制控件显示
wpf
Monkey-旭16 小时前
鸿蒙 5.1 深度解析:ArkUI 4.1 升级与分布式开发新范式
分布式·wpf·harmonyos·arkts·openharmony·arkui
FuckPatience3 天前
WPF TabControl页面绑定ItemsSource
wpf
cplmlm3 天前
WPF+MVVM入门学习
c#·wpf
诸葛务农5 天前
人形机器人——电子皮肤技术路线:光学式电子皮肤及MIT基于光导纤维的分布式触觉传感电子皮肤
分布式·机器人·wpf
界面开发小八哥5 天前
界面控件DevExpress WPF中文教程:Data Grid - 绑定数据
ui·.net·wpf·界面控件·devexpress·ui开发
界面开发小八哥6 天前
图表组件SciChart WPF再升级:v8.9带来油气井图、新交互与可视化增强
信息可视化·wpf·数据可视化·scichart
创可贴治愈心灵7 天前
WPF中UI线程频繁操作造成卡顿的处理
ui·c#·wpf
阿登林7 天前
初步学习WPF-Prism
学习·wpf
△曉風殘月〆8 天前
WPF MVVM进阶系列教程(三、使用依赖注入)
wpf·mvvm