如何从加载的图像文件而不是项目资源构建 SplashScreen

发布于 2024-11-08 10:50:02 字数 340 浏览 2 评论 0原文

您将如何继承 System.Windows.SplashScreen 因此必须通过在精确路径加载图像时构建自身的可能性来丰富此类。

根据定义,System.Windows.SplashScreen 只提供这两个构造函数:

public SplashScreen(string resourceName);
public SplashScreen(Assembly resourceAssembly, string resourceName);

由于我仍然对 WPF 感到不自在,我不知道从哪里开始修改?

或者我应该完全重新设计我自己的 SplashScreen 类?

How would you inherit System.Windows.SplashScreen so has to enrich this class by the possibility of constructing itself on loading an image at a precise path.

By definition System.Windows.SplashScreen offers only these two constructors:

public SplashScreen(string resourceName);
public SplashScreen(Assembly resourceAssembly, string resourceName);

As I still feel ill at ease with WPF, I don't have the single idea where to start modifications ?

Or should I redesign completely my own SplashScreen class ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

誰認得朕 2024-11-15 10:50:02

可能无法回答您正在寻找的问题。但是如何将该图像(您有精确的路径)添加到本地资源中,并且您可以重复使用 SplashScreen 而无需重新设计

只需阅读 MSDN 文章 这里,WPF SplashScreen 似乎很差,在 WinForm 中您可以添加文本(您可以在其中显示状态消息和内容)。

might not answer you are looking for. but how about adding that image (which you have precise path) into your local resource and you can reuse SplashScreen without redesign

Just read MSDN article here, WPF SplashScreen seems to quite poor, in WinForm you could add text (where you could display status message and stuff).

太阳男子 2024-11-15 10:50:02

为什么不为每个客户安装包含图像的资源程序集并在运行时引用或使用 Assembly.Load() 加载它?

您甚至可以在工具中使用 Mono.Cecil 自动构建此类资源程序集

why not installing a resource assembly containing the image for each customer and reference or load it with Assembly.Load() at runtime?

you can even automate the build of such a resourceassembly using Mono.Cecil in a tool

挽清梦 2024-11-15 10:50:02

创建一个名为splashscreen 的窗口并使其成为单例,如下所示:

public partial class Splashscreen:Window
{
 static Splashscreen splashscreen;
    public Splashscreen()
    {
        InitializeComponent();
    }

    public static void ShowSplashScreen()
    {
        splashscreen = new Splashscreen();
        splashscreen.Show();
    }

    public static Splashscreen SplashScreen { get { return splashscreen; } set { splashscreen = value; } }

在 xaml 中执行您想要的所有自定义操作,例如显示状态、进度、图像等。

读取 app.config 以获取客户端详细信息并根据用户显示它。

在 void main() 的第一行或应用程序启动中调用splashscreen.showsplashscreen()。
一旦应用程序完全加载,通过同步或异步调用splashscreen.splashscreen.close()来销毁启动屏幕。

Create a window called splashscreen and make it singleton like:

public partial class Splashscreen:Window
{
 static Splashscreen splashscreen;
    public Splashscreen()
    {
        InitializeComponent();
    }

    public static void ShowSplashScreen()
    {
        splashscreen = new Splashscreen();
        splashscreen.Show();
    }

    public static Splashscreen SplashScreen { get { return splashscreen; } set { splashscreen = value; } }

Do all the customizations you want in the xaml like showing status, progress,image etc.

read app.config to get the client details and show it according to the user.

call splashscreen.showsplashscreen() in the first line of your void main() or in your appstartup.
once the application is fully loaded destroy splashscreen by calling splashscreen.splashscreen.close() either sync or async.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文