Enterwell / Wpf.Notifications

WPF notifications UI controls (as seen in VS Code)
MIT License
400 stars 40 forks source link

API: `DismissDelayed` extension #5

Closed AleksandarDev closed 6 years ago

AleksandarDev commented 6 years ago

NotificationMessageBuilder.DismissNotificationMessageButton needs to be refactored to NotificationMessageBuilder.DismissNotificationMessage

Implement following builder methods:

public static NotificationMessageBuilder Delayed(
        this NotificationMessageBuilder.DismissNotificationMessage dismiss,
        long delayMilliseconds,
        Action<INotificationMessage> callback = null)

public static NotificationMessageBuilder Delayed(
        this NotificationMessageBuilder.DismissNotificationMessage dismiss,
        TimeSpan delay,
        Action<INotificationMessage> callback = null)

Delay is required (no default), callback is optional.

Use case:

var builder = this.Manager
    .CreateMessage()
    .Accent("#E0A030")
    .Background("#333")
    .HasBadge("Warn")
    .HasMessage("Failed to retrieve data.")
    .WithButton("Try again", button => { })
    .Dismiss().Delayed(5000);

Should still support Dismiss().WithButton() API for backward-compatibility.