Loading...
Loading...
Compare original and translation side by side
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;
}
}using Syncfusion.Windows.Forms.Tools;
public partial class Form1 : Form
{
private SplashControl splashControl1;
public Form1()
{
InitializeComponent();
// 初始化SplashControl
this.splashControl1 = new SplashControl();
// 设置闪屏图片
this.splashControl1.SplashImage = Image.FromFile("splash.png");
// 配置基础属性
this.splashControl1.HostForm = this;
this.splashControl1.TimerInterval = 3000; // 展示3秒
this.splashControl1.AutoMode = true; // 窗体加载时自动展示
this.splashControl1.DesktopAlignment = SplashAlignment.Center;
// 可选:启用动画
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 ShowSplashButton_Click(object sender, EventArgs e)
{
// 展示闪屏并禁用宿主窗体
splashControl1.ShowSplash(true);
}
// 程序化隐藏闪屏
private void HideSplashButton_Click(object sender, EventArgs e)
{
splashControl1.HideSplash();
}
// 展示为模态对话框
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();
};
}private void InitializeSplash()
{
splashControl1.HostForm = this;
splashControl1.SplashImage = Properties.Resources.CompanyLogo;
splashControl1.AutoMode = true;
splashControl1.HideHostForm = true;
splashControl1.TimerInterval = 4000;
splashControl1.DesktopAlignment = SplashAlignment.Center;
// 监听闪屏关闭事件执行初始化
splashControl1.SplashClosed += (s, e) =>
{
// 闪屏关闭后执行应用初始化
LoadApplicationData();
};
}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 SetupCustomSplashPanel()
{
// 创建并设计SplashPanel
SplashPanel splashPanel = new SplashPanel();
splashPanel.BackgroundColor = new BrushInfo(GradientStyle.Vertical,
Color.White, Color.LightBlue);
splashPanel.Size = new Size(400, 200);
// 添加标签
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);
// 配置SplashControl使用自定义面板
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 ConfigureSplashEvents()
{
splashControl1.BeforeSplash += (s, e) =>
{
// 展示前记录日志
Debug.WriteLine("Splash screen about to display");
// 按需取消展示
// 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;
}private void ConfigureTransparentSplash()
{
splashControl1.SplashImage = Properties.Resources.LogoWithTransparency;
splashControl1.TransparentColor = Color.White; // 白色像素设为透明
splashControl1.ShowAnimation = true;
splashControl1.ShowAsTopMost = true;
splashControl1.DesktopAlignment = SplashAlignment.Center;
splashControl1.TimerInterval = 3000;
}| Property | Type | Description |
|---|---|---|
| AutoMode | bool | Automatically display splash on form load |
| SplashImage | Image | Image to display as splash screen |
| TimerInterval | int | Display duration in milliseconds (default: 5000) |
| DesktopAlignment | SplashAlignment | Position on desktop (Center, SystemTray, corners, Custom) |
| HostForm | Form | Parent form of the SplashControl |
| HideHostForm | bool | Hide parent form during splash display |
| ShowAnimation | bool | Enable left-to-right animation effect |
| CustomSplashPanel | SplashPanel | Custom panel to display instead of image |
| UseCustomSplashPanel | bool | Use CustomSplashPanel instead of SplashImage |
| AutoModeDisableOwner | bool | Display splash modally in AutoMode |
| ShowAsTopMost | bool | Display splash as topmost window |
| TransparentColor | Color | Color to make transparent in splash image |
| IsShowing | bool | Indicates if splash is currently displayed (read-only) |
| 属性 | 类型 | 描述 |
|---|---|---|
| AutoMode | bool | 窗体加载时自动展示闪屏 |
| SplashImage | Image | 作为闪屏展示的图片 |
| TimerInterval | int | 展示时长,单位为毫秒(默认:5000) |
| DesktopAlignment | SplashAlignment | 桌面位置(居中、系统托盘、角落、自定义) |
| HostForm | Form | SplashControl的父窗体 |
| HideHostForm | bool | 闪屏展示期间隐藏父窗体 |
| ShowAnimation | bool | 启用从左到右的动画效果 |
| CustomSplashPanel | SplashPanel | 替代图片展示的自定义面板 |
| UseCustomSplashPanel | bool | 使用CustomSplashPanel替代SplashImage |
| AutoModeDisableOwner | bool | 自动模式下模态展示闪屏 |
| ShowAsTopMost | bool | 将闪屏展示为顶层窗口 |
| TransparentColor | Color | 闪屏图片中要设为透明的颜色 |
| IsShowing | bool | 标识闪屏是否正在展示(只读) |
| Method | Description |
|---|---|
| ShowSplash(bool disableOwner) | Display splash screen manually |
| HideSplash() | Close the splash screen programmatically |
| ShowDialogSplash(Form owner) | Display splash as modal dialog |
| ShowDialogSplash(Point location, Form owner) | Display splash at specific location as modal |
| 方法 | 描述 |
|---|---|
| ShowSplash(bool disableOwner) | 手动展示闪屏 |
| HideSplash() | 程序化关闭闪屏 |
| ShowDialogSplash(Form owner) | 展示闪屏为模态对话框 |
| ShowDialogSplash(Point location, Form owner) | 在指定位置展示模态闪屏 |
| Event | Description |
|---|---|
| BeforeSplash | Raised before splash display (cancelable) |
| SplashDisplayed | Raised after splash is shown |
| SplashClosing | Raised before splash closes (cancelable) |
| SplashClosed | Raised after splash is closed |
| 事件 | 描述 |
|---|---|
| BeforeSplash | 闪屏展示前触发(可取消) |
| SplashDisplayed | 闪屏展示后触发 |
| SplashClosing | 闪屏关闭前触发(可取消) |
| SplashClosed | 闪屏关闭后触发 |
Syncfusion.Shared.Base.dllSyncfusion.Tools.Windows.dllInstall-Package Syncfusion.Tools.WindowsSyncfusion.Shared.Base.dllSyncfusion.Tools.Windows.dllInstall-Package Syncfusion.Tools.Windows