Splash Screen Manager - 使用教程
在应用程序的开发过程中,启动界面的展示不仅能提升用户体验,还能在后台进行初始化操作时给予用户视觉反馈。Splash Screen Manager 作为一款强大的工具,提供了多种灵活的启动界面展示方式。本文将详细介绍其各类屏幕的使用方法,助力开发者打造个性化的应用启动体验。
一、简介
Splash Screen Manager 是一个用于管理应用程序启动界面的工具,它支持多种不同风格和功能的启动屏幕,包括 Skin Splash Screen、Fluent Splash Screen、Splash Image、Wait Form 以及 Overlay Form 等。通过使用 Splash Screen Manager,开发者可以轻松自定义启动界面的外观、内容和动画效果,在应用程序启动时展示品牌信息、加载进度等内容,同时在后台进行数据加载、资源初始化等操作,避免用户因等待而产生不好的体验。
二、Skin Splash Screen
Skin Splash Screen 是一种具有丰富自定义内容的启动屏幕类型,开发者可以灵活设置标题、副标题、页脚、加载提示等信息,还能添加自定义 logo 图片。以下是具体的使用代码及说明:
// 获取用于展示的logo图片
var logo = this.sbSkinSplashScreen.ImageOptions.Image;
// 显示Skin Splash Screen
SplashScreenManager.ShowSkinSplashScreen(
logoImage: logo,
title: "这是Skin Splash Screen标题..",
subtitle: "这是Skin Splash Screen副标题..",
footer: "Copyright © 1990 - 2025 Armon Inc." + Environment.NewLine + "All Rights reserved.",
loading: "加载中..",
parentForm: this,
useFadeIn: true,
useFadeOut: true,
startPos: SplashFormStartPosition.CenterScreen
);
// 暂停线程,模拟后台加载操作耗时5秒
Thread.Sleep(TimeSpan.FromSeconds(5));
// 后续可在此添加应用程序初始化或数据加载等逻辑代码
//...
// 更新Skin Splash Screen的加载提示文本为"完成"
SplashScreenManager.Default.SendCommand(SkinSplashScreenCommand.UpdateLoadingText, "完成");
// 暂停线程1秒,让用户看到更新后的提示
Thread.Sleep(TimeSpan.FromSeconds(1));
// 关闭Skin Splash Screen
SplashScreenManager.CloseForm();
在使用过程中,ShowSkinSplashScreen
方法用于显示启动屏幕,通过设置不同的参数来定制屏幕内容和展示效果;SendCommand
方法可以在启动过程中动态更新屏幕上的文本、图片等内容;最后通过CloseForm
方法关闭启动屏幕。
三、Fluent Splash Screen
Fluent Splash Screen 提供了现代化、简洁的启动界面风格,通过FluentSplashScreenOptions
类来配置屏幕的各项属性。以下是使用示例:
// 创建FluentSplashScreenOptions对象并设置相关属性
var options = new FluentSplashScreenOptions()
{
Title = "这是Skin Splash Screen标题..",
Subtitle = "这是Skin Splash Screen副标题..",
RightFooter = "加载中...",
LeftFooter = "Copyright © 1990 - 2025 Armon Inc." + Environment.NewLine + "All Rights reserved.",
LoadingIndicatorType = FluentLoadingIndicatorType.Dots,
OpacityColor = Color.Gray,
Opacity = 130,
};
// 设置logo图片
options.LogoImageOptions.SvgImage = this.sbFluentSplashScreen.ImageOptions.SvgImage;
// 显示Fluent Splash Screen
SplashScreenManager.ShowFluentSplashScreen(
fluentOptions: options,
parentForm: this,
useFadeIn: true,
useFadeOut: true
);
// 暂停线程,模拟后台操作耗时5秒
Thread.Sleep(TimeSpan.FromSeconds(5));
// 后续可添加应用程序相关逻辑代码
//...
// 更新Fluent Splash Screen的显示内容
SplashScreenManager.Default.SendCommand(FluentSplashScreenCommand.UpdateOptions, new FluentSplashScreenOptions()
{
RightFooter = "完成",
Title = "哈哈哈哈,终于...",
Subtitle = "我要这天,再遮不住我眼",
});
// 暂停线程1秒,展示更新后的效果
Thread.Sleep(TimeSpan.FromSeconds(1));
// 关闭Fluent Splash Screen
SplashScreenManager.CloseForm();
这里通过配置FluentSplashScreenOptions
对象来设置屏幕的标题、副标题、页脚、加载指示器类型、透明度等属性,使用ShowFluentSplashScreen
方法显示屏幕,同样利用SendCommand
方法更新屏幕内容,最后关闭屏幕。
四、Splash Image
Splash Image 是一种较为简单直接的启动展示方式,仅展示一张图片。其使用代码如下:
// 获取要展示的图片
var image = this.sbSplashImage.ImageOptions.SvgImage;
// 显示图片作为启动界面
SplashScreenManager.ShowImage(image);
// 暂停线程2秒,模拟展示时间
Thread.Sleep(TimeSpan.FromSeconds(2));
// 后续可添加应用程序逻辑代码
//...
// 隐藏图片启动界面
SplashScreenManager.HideImage();
通过ShowImage
方法展示图片,HideImage
方法隐藏图片,实现简单的启动界面展示与关闭。
五、Wait Form和Splash Screen
Wait Form 主要用于在应用程序进行某些耗时操作时,向用户展示等待提示。使用方式如下:
-
- 添加
SplashScreenManager
控件,命名为ssmManager
- 添加
-
- 添加Wait Form,如下图:
- 添加Wait Form,如下图:
-
- 重命名WaitForm为FormWait(可根据规范自行修改)
-
- 下面是具体使用代码
// 显示Wait Form
this.ssmManager.ShowWaitForm();
// 暂停线程2秒,模拟耗时操作
Thread.Sleep(TimeSpan.FromSeconds(2));
// 后续可添加具体的耗时操作逻辑代码
//...
// 关闭Wait Form
this.ssmManager.CloseWaitForm();
ShowWaitForm
方法用于显示等待界面,CloseWaitForm
方法用于关闭该界面,在等待界面显示期间,可在后台执行相关的操作。
六、Overlay Form
Overlay Form 可以在应用程序窗口上覆盖一层透明的窗口,常用于在特定操作时提供遮罩效果或显示提示信息。其使用示例如下:
// 创建OverlayWindowOptions对象并设置相关属性
var options = new OverlayWindowOptions(
startupDelay: 1000,
backColor: Color.Green,
opacity: 0.8,
fadeIn: true,
fadeOut: true,
imageSize: new Size(64, 64)
);
// 显示Overlay Form,并在using块结束时自动释放资源
using (var handle = SplashScreenManager.ShowOverlayForm(this, options))
{
handle.QueueFocus(IntPtr.Zero);
// 暂停线程5秒,模拟操作时间
Thread.Sleep(TimeSpan.FromSeconds(5));
// 后续可添加相关逻辑代码
//...
}
通过配置OverlayWindowOptions
对象来设置覆盖窗口的启动延迟、背景颜色、透明度、淡入淡出效果等属性,ShowOverlayForm
方法用于显示覆盖窗口,在using
块内使用,可确保资源的正确释放。
七、总结
Splash Screen Manager 提供了丰富多样的启动界面展示方式,满足了不同场景下的应用需求。从功能丰富、高度可定制的 Skin Splash Screen 和 Fluent Splash Screen,到简洁的 Splash Image,以及用于显示等待提示的 Wait Form 和实现覆盖效果的 Overlay Form,开发者可以根据应用程序的特点和业务需求选择合适的方式。在使用过程中,要注意各个方法的参数设置以及动态更新内容的方式,合理利用暂停线程模拟后台操作时间,从而为用户带来流畅且友好的启动体验。同时,在实际项目中,结合具体的业务逻辑,将 Splash Screen Manager 的功能发挥到极致,提升应用程序的整体品质。
八、源码
https://gitcode.com/huyu107/DevExpress.WinForms.git