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;
        }
        
    }
}
相关推荐
听麟1 天前
HarmonyOS 6.0+ 智慧出行导航APP开发实战:离线地图与多设备位置协同落地
华为·wpf·harmonyos
笨蛋不要掉眼泪2 天前
Spring Boot + RedisTemplate 数据结构的基础操作
java·数据结构·spring boot·redis·wpf
LcVong3 天前
WPF MediaPlayer获取网络视频流当前帧并展示图片完整范例
网络·wpf
bugcome_com3 天前
WPF数据绑定入门:从传统事件到5种绑定模式
wpf
LateFrames3 天前
我用 WPF 做了一个 “苍蝇飞舞” 的屏保
ui·wpf
wuty0073 天前
完善基于WPF开发的标尺控件(含实例代码)
wpf·wpf标尺·支持横向竖向标尺·ruler
浩浩测试一下3 天前
洪水猛兽攻击 Ddos Dos cc Drdos floods区别
安全·web安全·网络安全·系统安全·wpf·可信计算技术·安全架构
无心水4 天前
分布式环境下定时任务与SELECT FOR UPDATE的陷阱与解决方案
分布式·后端·wpf·xxl-job·quartz·定时任务·selectforupdate
xdpcxq10294 天前
Spring AOP + Guava RateLimiter 用注解实现优雅限流
spring·wpf·guava
Aevget4 天前
界面控件DevExpress WPF v25.2新版亮点:模板工具包全新升级
wpf·界面控件·devexpress·ui开发·.net 10