关于 syncfusion-winforms-splash-control
面向 Windows Forms 开发者的 Syncfusion SplashControl 使用指南,可创建图像或自定义面板启动屏,并设置时长、位置、动画及生命周期处理。
主要功能
- 01图像与自定义面板启动屏
- 02自动或手动显示
- 03可配置时长与位置
- 04动画与透明度选项
- 05主窗体及生命周期事件控制
适用场景
- 01启动时展示品牌标识
- 02显示初始化进度
- 03呈现更新说明
- 04定时展示公告
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ syncfusion/ winforms-ui-components-skills --skill syncfusion-winforms-splash-control安装后在 Claude Code 中输入/syncfusion-winforms-splash-control确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
references/alignment-positioning.mdautomode-timing.mdevents.mdgetting-started.mdhost-form-settings.mdimage-animation.mdsplashpanel-integration.md详细介绍
实现 Syncfusion WinForms SplashControl
SplashControl 组件可轻松为 Windows Forms 应用程序创建专业的启动画面。只需将控件拖放到窗体上,设置图像,启动画面便会在运行时自动显示,并支持自定义显示时长、动画和位置。
何时使用此技能
在以下情况下使用此技能:
- 在应用程序启动期间显示启动画面
- 在应用初始化时显示品牌信息、徽标或加载信息
- 创建定时或手动控制的启动画面
- 实现带视觉效果的动画启动画面
- 设计包含控件和内容的自定义启动面板
- 在启动画面显示期间控制宿主窗体的可见性
- 处理启动画面的生命周期事件
- 将启动画面定位到桌面的特定位置
组件概览
SplashControl 提供两种显示模式:
- 基于图像的启动画面: 显示静态或动画图像
- 自定义 SplashPanel: 使用任意控件设计完全可自定义的面板
主要功能:
- 自动或手动控制显示
- 可配置显示时长和计时器间隔
- 内置动画效果(从左向右展开)
- 灵活的桌面定位(居中、角落、系统托盘、自定义)
- 宿主窗体可见性管理
- 模态或非模态显示模式
- 支持透明效果
- 完整的事件生命周期
文档与导航指南
入门
📄 阅读: references/getting-started.md
从这里开始进行初始设置:
- 程序集引用和 NuGet 包
- 通过设计器或代码添加 SplashControl
- 基本属性配置
- AutoMode 与手动调用
- 运行第一个启动画面
显示和计时配置
📄 阅读: references/automode-timing.md
配置启动画面何时以及如何显示:
- 使用 AutoMode 在窗体加载时自动显示
- 使用 AutoModeDisableOwner 实现模态启动画面
- 使用 ShowSplash() 方法手动控制显示
- 使用 HideSplash() 以编程方式关闭
- 使用 ShowDialogSplash() 显示模态对话框
- 使用 TimerInterval 控制显示时长
- 使用 IsShowing 属性检查显示状态
图像和动画设置
📄 阅读: references/image-animation.md
自定义视觉外观:
- 设置 SplashImage 属性
- 使用 ShowAnimation 启用动画
- 配置透明颜色
- 使用 ShowAsTopMost 控制窗口层级
- 动画行为和效果
对齐和定位
📄 阅读: references/alignment-positioning.md
控制启动画面在桌面上的位置:
- DesktopAlignment 选项(居中、系统托盘、角落)
- 自定义定位策略
- 各种对齐模式的视觉示例
宿主窗体管理
📄 阅读: references/host-form-settings.md
管理启动画面显示期间的父窗体:
- HostForm 属性配置
- 使用 HideHostForm 隐藏主窗体
- 使用 HostFormWindowState 控制窗体状态(Normal、Minimized、Maximized)
- 协调启动画面和宿主窗体
自定义 SplashPanel 集成
📄 阅读: references/splashpanel-integration.md
创建完全自定义的启动面板:
- 使用 SplashPanel 代替静态图像
- CustomSplashPanel 属性
- 使用 UseCustomSplashPanel 启用自定义面板
- 使用控件(标签、进度条等)设计面板
- SplashControlPanel 属性
- ShowInTaskbar 和 FormIcon 配置
- 包含代码示例的完整集成工作流
事件处理
📄 阅读: references/events.md
处理启动画面生命周期事件:
- BeforeSplash 事件(支持取消)
- SplashDisplayed 事件
- SplashClosing 事件
- SplashClosed 事件
- 事件通知方法
- 日志记录和调试模式
快速入门
基于图像的基本启动画面
using Syncfusion.Windows.Forms.Tools;
public partial class Form1 : Form
{
private SplashControl splashControl1;
public Form1()
{
InitializeComponent();
// Initialize SplashControl
this.splashControl1 = new SplashControl();
// Set the splash image
this.splashControl1.SplashImage = Image.FromFile("splash.png");
// Configure basic properties
this.splashControl1.HostForm = this;
this.splashControl1.TimerInterval = 3000; // Display for 3 seconds
this.splashControl1.AutoMode = true; // Auto-display on form load
this.splashControl1.DesktopAlignment = SplashAlignment.Center;
// Optional: Enable animation
this.splashControl1.ShowAnimation = true;
}
}
手动控制显示
// Display splash screen manually
private void ShowSplashButton_Click(object sender, EventArgs e)
{
// Show splash and disable owner form
splashControl1.ShowSplash(true);
}
// Hide splash screen programmatically
private void HideSplashButton_Click(object sender, EventArgs e)
{
splashControl1.HideSplash();
}
// Show as modal dialog
private void ShowModalSplash_Click(object sender, EventArgs e)
{
splashControl1.ShowDialogSplash(this);
}
常见模式
使用隐藏宿主窗体自动显示启动画面
初始化期间显示启动画面,同时隐藏主窗体:
private void InitializeSplash()
{
splashControl1.HostForm = this;
splashControl1.SplashImage = Properties.Resources.CompanyLogo;
splashControl1.AutoMode = true;
splashControl1.HideHostForm = true;
splashControl1.TimerInterval = 4000;
splashControl1.DesktopAlignment = SplashAlignment.Center;
// Handle splash closed event to perform initialization
splashControl1.SplashClosed += (s, e) =>
{
// Perform app initialization after splash closes
LoadApplicationData();
};
}
带进度指示的自定义 SplashPanel
创建带控件的自定义启动画面面板:
private void SetupCustomSplashPanel()
{
// Create and design SplashPanel
SplashPanel splashPanel = new SplashPanel();
splashPanel.BackgroundColor = new BrushInfo(GradientStyle.Vertical,
Color.White, Color.LightBlue);
splashPanel.Size = new Size(400, 200);
// Add label
Label statusLabel = new Label
{
Text = "Loading Application...",
AutoSize = true,
Location = new Point(50, 80),
Font = new Font("Segoe UI", 14, FontStyle.Bold)
};
splashPanel.Controls.Add(statusLabel);
// Configure SplashControl to use custom panel
splashControl1.CustomSplashPanel = splashPanel;
splashControl1.UseCustomSplashPanel = true;
splashControl1.HostForm = this;
splashControl1.TimerInterval = 5000;
}
事件驱动的启动画面显示
处理事件以进行日志记录和控制:
private void ConfigureSplashEvents()
{
splashControl1.BeforeSplash += (s, e) =>
{
// Log before display
Debug.WriteLine("Splash screen about to display");
// Cancel if needed
// e.Cancel = true;
};
splashControl1.SplashDisplayed += (s, e) =>
{
Debug.WriteLine("Splash screen is now visible");
StartBackgroundInitialization();
};
splashControl1.SplashClosing += (s, e) =>
{
Debug.WriteLine("Splash screen is closing");
};
splashControl1.SplashClosed += (s, e) =>
{
Debug.WriteLine("Splash screen closed");
ShowMainForm();
};
}
透明启动画面
创建带透明区域的启动画面:
private void ConfigureTransparentSplash()
{
splashControl1.SplashImage = Properties.Resources.LogoWithTransparency;
splashControl1.TransparentColor = Color.White; // Make white pixels transparent
splashControl1.ShowAnimation = true;
splashControl1.ShowAsTopMost = true;
splashControl1.DesktopAlignment = SplashAlignment.Center;
splashControl1.TimerInterval = 3000;
}
关键属性
| 属性 | 类型 | 说明 |
|---|---|---|
| AutoMode | bool | 窗体加载时自动显示启动画面 |
| SplashImage | Image | 要显示为启动画面的图像 |
| TimerInterval | int | 显示时长(毫秒,默认值:5000) |
| DesktopAlignment | SplashAlignment | 在桌面上的位置(Center、SystemTray、角落、自定义) |
| HostForm | Form | SplashControl 的父窗体 |
| HideHostForm | bool | 显示启动画面期间隐藏父窗体 |
| HostFormWindowState | FormWindowState | 控制宿主窗体的状态(Normal、Minimized、Maximized) |
| ShowAnimation | bool | 启用从左到右的动画效果 |
| CustomSplashPanel | SplashPanel | 用于替代图像显示的自定义面板 |
| UseCustomSplashPanel | bool | 使用 CustomSplashPanel 替代 SplashImage |
| AutoModeDisableOwner | bool | 在 AutoMode 下以模态方式显示启动画面 |
| ShowAsTopMost | bool | 将启动画面显示为最顶层窗口 |
| TransparentColor | Color | 启动画面图像中要设为透明的颜色 |
| IsShowing | bool | 指示启动画面当前是否正在显示(只读) |
关键方法
| 方法 | 说明 |
|---|---|
| ShowSplash(bool disableOwner) | 手动显示启动画面 |
| HideSplash() | 以编程方式关闭启动画面 |
| ShowDialogSplash(Form owner) | 以模态对话框形式显示启动画面 |
| ShowDialogSplash(Point location, Form owner) | 在指定位置以模态形式显示启动画面 |
关键事件
| 事件 | 说明 |
|---|---|
| BeforeSplash | 在显示启动画面前触发(可取消) |
| SplashDisplayed | 启动画面显示后触发 |
| SplashClosing | 在启动画面关闭前触发(可取消) |
| SplashClosed | 启动画面关闭后触发 |
常见用例
应用启动品牌展示
应用加载期间显示公司徽标和版本信息,并在初始化完成前隐藏主窗体。
耗时的初始化过程
加载数据、初始化组件或连接服务时,显示带进度指示器的自定义启动画面面板。
版本更新通知
应用更新后启动时,显示包含“更新内容”信息的启动画面。
专业的用户体验
创建与应用品牌和设计语言相匹配的动画、透明启动画面。
定时信息展示
在允许用户交互前,在指定时长内显示重要公告、提示或消息。
提示和最佳实践
- 合理设置启动画面显示时长: 理想时长为 2-5 秒;时间过长会让用户感到烦躁
- 与应用程序主题保持一致: 确保启动画面的设计符合应用程序的视觉形象
- 使用 AutoMode 简化操作: 除非需要复杂的控制,否则 AutoMode 可处理大多数场景
- 处理 SplashClosed 事件: 在启动画面关闭时执行初始化任务,确保平滑过渡
- 动态内容可考虑使用 SplashPanel: 需要进度条或动态文本时,使用自定义面板
- 测试不同的对齐方式: 居中通常效果最好,但 SystemTray 的干扰较小
- 谨慎使用 HideHostForm: 隐藏宿主窗体可以带来更简洁的启动体验
- 有选择地启用动画: 动画可以提升质感,但可能不适合所有类型的应用程序
程序集依赖项
必需的程序集:
Syncfusion.Shared.Base.dllSyncfusion.Tools.Windows.dll
NuGet 包:
Install-Package Syncfusion.Tools.Windows
如需完整的依赖项信息,请参阅 Syncfusion 控件依赖项文档。