学习010-04-04-03 Create and Show a Splash Form (WinForms)(创建并显示启动窗体(Windows 窗体))

Create and Show a Splash Form (WinForms)(创建并显示启动窗体(Windows 窗体))

This topic describes how to create three splash forms (a Splash Screen, a Wait Form, and a Splash Image) and use them in an application.
本主题介绍如何创建三个启动表单(启动屏幕、等待表单和启动图像)并在应用程序中使用它们。

Prerequisites(先决条件)

To use designer tools for DevExpress controls in .NET applications, install the DevExpress.Win.Design package from the local NuGet feed, or from a remote NuGet feed at https://nuget.devexpress.com .
要将设计器工具用于DevExpress控件。NET应用程序,请从本地NuGet提要或https://nuget.devexpress.com的远程NuGet提要安装DevExpress.Win.Design包。

Create and Use a Splash Screen or a Wait Form(创建和使用启动屏幕或等待表单)

There are two ways to create a Splash Screen or a Wait Form :
有两种方法可以创建启动屏幕或等待表单:

  • Create a new Windows Form in your WinForms Application project . Inherit the form from the SplashFormBase class or SplashFormBase descendant and customize the form.
    在您的WinForms应用程序项目中创建一个新的Windows表单。从SplashFormBase类或SplashFormBase后代继承表单并自定义表单。

  • Use the Splash Screen or the Progress Indicator template from the DXperience v24.1 Template Gallery project item. You can add or modify images and labels.
    使用DXperience v24.1 Template Gallery项目项中的启动屏幕或进度指示器模板。您可以添加或修改图像和标签。

To use the Splash Screen or the Wait Form at the application’s startup, open the WinApplication.cs (WinApplication.vb) file and pass the form to any DXSplashScreen constructor as the xtraSplashFormType parameter.
要在应用程序启动时使用飞溅屏幕或等待表单,请打开WinApplication. cs(WinApplication.vb)文件并将表单作为xtraSplashFormType参数传递给任何DXSplashScreen构造函数。

C#  
namespace MySolution.Win {
    public partial class MySolutionWindowsFormsApplication : WinApplication {
        public MySolutionWindowsFormsApplication() { 
            // ...
            SplashScreen = new DXSplashScreen(typeof(MySplashScreenOrWaitForm));
            ExecuteStartupLogicBeforeClosingLogonWindow = true;
        }
        // ...
    }
}

To use the Wait Form with other splash forms, use a different constructor and pass the Wait Form as the waitFormType parameter.
要将等待表单与其他启动表单一起使用,请使用不同的构造函数并将等待表单作为waitFormType参数传递。

You can use forms to indicate specific operations’ progress .
您可以使用表单来指示特定操作的进度。

Use a Splash Image(使用启动图像)

To show a Splash Image , add an image file to the Images folder in the WinForms Application project and set the file’s Build Action property to Embedded Resource.
要显示启动图像,请将图像文件添加到WinForms应用程序项目中的图像文件夹,并将文件的构建操作属性设置为嵌入式资源。

The following file types are acceptable:
以下文件类型是可以接受的:

  • SVG,
  • PNG,
  • other raster formats.

Note
You can use the Bitmap.MakeTransparent method to enable transparency for BMP images. You can also use an image editing application to convert your BMP file to PNG or another raster format that supports transparency.
您可以使用Bitmap. MakeTransparent方法为BMP图像启用透明度。您还可以使用图像编辑应用程序将您的BMP文件转换为PNG或其他支持透明度的光栅格式。

To enable the image, access the WinApplication.cs (WinApplication.vb) file and assign the image to an Image or SVGImage object. Pass the object to the DXSplashScreen(Image) or DXSplashScreen(SvgImage) constructor to set the Splash Image as the application’s default Splash Screen.
要启用图像,请访问WinApplication. cs(WinApplication.vb)文件并将图像分配给Image或SVGImage对象。将对象传递给DXSplashScreen(Image)或DXSplashScreen(SvgImage)构造函数以将Splash Image设置为应用程序的默认Splash Screen。

Raster Image(光栅图像)
C#  
using  System.IO ;
using  System.Reflection ;
using  DevExpress.ExpressApp.Win.Utils ;

namespace MySolution.Win {
    public partial class MySolutionWindowsFormsApplication : WinApplication {
        public MySolutionWindowsFormsApplication() {
            // ...
            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            Stream splashImageStream = executingAssembly.GetManifestResourceStream(
                assembly.GetName().Name + ".Images.MySplashImage.png");
            SplashScreen = new DXSplashScreen(Image.FromStream(splashImageStream));
        }
        // ...
    }
}
SVG Image
C#  
using  System.Reflection ;
using  DevExpress.Utils.Svg ;
using  DevExpress.ExpressApp.Win.Utils ;

namespace MySolution.Win {
    public partial class MySolutionWindowsFormsApplication : WinApplication {
        public MySolutionWindowsFormsApplication() {
            // ...
            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            SplashScreen = new DXSplashScreen(SvgImage.FromResources(
                assembly.GetName().Name + ".Images.SplashImage.svg", assembly));
        }
        // ...
    }
}

To use the Splash Image with other splash forms, use a different constructor .
要将启动图像与其他启动窗体一起使用,请使用不同的构造函数。

After you enable the Splash Image, you can show it for specific operations to indicate their progress .
启用Splash Image后,您可以为特定操作显示它以指示其进度。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汤姆•猫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值