Code Monkey home page Code Monkey logo

splashscreen.fody's Introduction

This is an add-in for Fody

Build status NuGet Status

Icon

The default WPF Splash Screen implementation only supports a static bitmap, which is very unhandy. With this add-in you can easily design your splash screen as a WPF Control, utilizing all WPF features, as you would expect for a WPF application.

It also gives you some extra control over the behavior without the need to write extra code. All you have to provide is a WPF Control with the splash screen design. You can use all design features of WPF, e.g. file and version info can be read dynamically via binding. However due to the fact that the final splash is a bitmap, animations are not supported.

How to use

To have a dynamically designable splash screen in your application, simply add a WPF UserControl to your applications assembly, design it, and apply the [SplashScreen] attribute to it:

/// <summary>
/// Interaction logic for MySplashScreen.xaml
/// </summary>
[SplashScreen(MinimumVisibilityDuration = 4, FadeoutDuration = 1)]
public partial class MySplashScreen
{
    public MySplashScreen()
    {
        InitializeComponent();
    }

    /// <summary>
    /// Gets the file version info.
    /// </summary>
    public FileVersionInfo FileVersionInfo { get; } = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
}

You can also control the minimum visibility duration and fadeout duration via this attribute.

What it does

  • Generates a bitmap image from your control and embed it into the assembly.
  • Removes the user control and it's associated xaml resource.
  • Merges the code to control the splash screen into your assembly, so you don't have any additional dependencies.
  • Injects the code to initialize the splash screen into your applications entry point.

Controlling the splash behavior

Beside configuring the minimum visibility and default fadeout duration, you can also close the splash screen manually. The SplashScreenAdapter class has two static methods to achieve this, one to fade out the splash, and one to close it immediately:

SplashScreenAdapter.CloseSplashScreen();

or

SplashScreenAdapter.CloseSplashScreen(TimeSpan.FromSeconds(5));

Things to consider

  • Do not add a static image with the build action SplashScreen to your project, as described here
  • The WPF control marked with the [SplashScreen] attribute will be removed, so do not use it anywhere else.
  • If showing an error message, make sure to close the splash screen immediately, using SplashScreenAdapter.CloseSplashScreen(), before you show a message box. Do not use fade out, since during fade out it again becomes the active window, and you might end up with the problem described here: MessageBox with exception details immediately disappears if use splash screen in WPF 4.0

splashscreen.fody's People

Contributors

tom-englert avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.