diff --git a/Changelog.md b/Changelog.md
new file mode 100644
index 0000000..14d1200
--- /dev/null
+++ b/Changelog.md
@@ -0,0 +1,14 @@
+# Changelog
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
+and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+
+
+## [1.1.0] - 2018-04-03
+### Added
+- Support for delayed dismiss `WithDelay` extension method for LINQ builder.
+
+## [1.0.0] - 2017-03-08
+### Added
+- Initial release.
\ No newline at end of file
diff --git a/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml b/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml
index 67136a3..2845ecb 100644
--- a/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml
+++ b/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml
@@ -75,6 +75,16 @@
Content="Error message"
Style="{StaticResource NotificationMessageButtonStyle}" />
+
+
diff --git a/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml.cs b/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml.cs
index 61faada..089c783 100644
--- a/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml.cs
+++ b/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml.cs
@@ -73,6 +73,20 @@ private void ButtonBaseInfoOnClick(object sender, RoutedEventArgs e)
.Queue();
}
+ private void ButtonBaseInfoDelayOnClick(object sender, RoutedEventArgs e)
+ {
+ this.Manager
+ .CreateMessage()
+ .Accent("#1751C3")
+ .Background("#333")
+ .HasBadge("Info")
+ .HasMessage("Update will be installed on next application restart. This message will be dismissed after 5 seconds.")
+ .Dismiss().WithButton("Update now", button => { })
+ .Dismiss().WithButton("Release notes", button => { })
+ .Dismiss().WithDelay(TimeSpan.FromSeconds(5))
+ .Queue();
+ }
+
public INotificationMessageManager Manager { get; } = new NotificationMessageManager();
}
}
diff --git a/Enterwell.Clients.Wpf.Notifications.sln b/Enterwell.Clients.Wpf.Notifications.sln
index 1e80570..c1e9554 100644
--- a/Enterwell.Clients.Wpf.Notifications.sln
+++ b/Enterwell.Clients.Wpf.Notifications.sln
@@ -9,6 +9,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Enterwell.Clients.Wpf.Notif
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3AF6FCB5-2016-41CA-9DBD-5C628B3509AE}"
ProjectSection(SolutionItems) = preProject
+ Changelog.md = Changelog.md
Readme.md = Readme.md
EndProjectSection
EndProject
@@ -30,4 +31,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {007773A2-8852-4770-8634-FC68BA83ACE6}
+ EndGlobalSection
EndGlobal
diff --git a/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilder.cs b/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilder.cs
index 7e6f4b1..055f753 100644
--- a/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilder.cs
+++ b/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilder.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading.Tasks;
using System.Windows.Media;
namespace Enterwell.Clients.Wpf.Notifications
@@ -111,18 +112,39 @@ public INotificationMessage Queue()
return this.Message;
}
+ ///
+ /// Executes the action after specified delay time.
+ ///
+ /// The delay in milliseconds.
+ /// The action.
+ public void Delay(int delayMilliseconds, Action action)
+ {
+ this.Delay(TimeSpan.FromMilliseconds(delayMilliseconds), action);
+ }
+
+ ///
+ /// Executes the action after specified delay time.
+ ///
+ /// The delay.
+ /// The action.
+ public void Delay(TimeSpan delay, Action action)
+ {
+ Task.Delay(delay).ContinueWith(
+ context => action(this.Message),
+ TaskScheduler.FromCurrentSynchronizationContext());
+ }
///
/// The notification message button that is required to dismiss the notification.
///
- public class DismissNotificationMessageButton
+ public class DismissNotificationMessage
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The builder.
/// builder
- public DismissNotificationMessageButton(NotificationMessageBuilder builder)
+ public DismissNotificationMessage(NotificationMessageBuilder builder)
{
this.Builder = builder ?? throw new ArgumentNullException(nameof(builder));
}
diff --git a/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilderLinq.cs b/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilderLinq.cs
index dfbf45c..dc3c340 100644
--- a/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilderLinq.cs
+++ b/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilderLinq.cs
@@ -131,30 +131,64 @@ public static NotificationMessageBuilder CreateMessage(
}
///
- /// Marks next button to be dismiss button.
+ /// Marks next button to be dismiss.
/// This button will dismiss the noitification message when clicked.
///
/// The builder.
/// Returns the notiification message builder.
- public static NotificationMessageBuilder.DismissNotificationMessageButton Dismiss(
+ public static NotificationMessageBuilder.DismissNotificationMessage Dismiss(
this NotificationMessageBuilder builder)
{
- return new NotificationMessageBuilder.DismissNotificationMessageButton(builder);
+ return new NotificationMessageBuilder.DismissNotificationMessage(builder);
+ }
+
+ ///
+ /// Dismisses the notification message after specified time.
+ ///
+ /// The dismiss.
+ /// The delay in milliseconds.
+ /// The callback.
+ /// Returns the notification message builder.
+ public static NotificationMessageBuilder WithDelay(
+ this NotificationMessageBuilder.DismissNotificationMessage dismiss,
+ int delayMilliseconds,
+ Action callback = null)
+ {
+ dismiss.Builder.Delay(delayMilliseconds, dismiss.Builder.DismissBefore(callback));
+
+ return dismiss.Builder;
+ }
+
+ ///
+ /// Withes the delay.
+ ///
+ /// The dismiss.
+ /// The delay.
+ /// The callback.
+ /// Returns the notification message builder.
+ public static NotificationMessageBuilder WithDelay(
+ this NotificationMessageBuilder.DismissNotificationMessage dismiss,
+ TimeSpan delay,
+ Action callback = null)
+ {
+ dismiss.Builder.Delay(delay, dismiss.Builder.DismissBefore(callback));
+
+ return dismiss.Builder;
}
///
/// Adds the button to the notification message.
///
- /// The dismiss button.
+ /// The dismiss.
/// The content.
/// The callback.
/// Returns the notification message builder.
public static NotificationMessageBuilder WithButton(
- this NotificationMessageBuilder.DismissNotificationMessageButton dismissButton,
+ this NotificationMessageBuilder.DismissNotificationMessage dismiss,
object content,
Action callback)
{
- return dismissButton.Builder.WithButton(content, dismissButton.Builder.DismissBefore(callback));
+ return dismiss.Builder.WithButton(content, dismiss.Builder.DismissBefore(callback));
}
///
@@ -178,6 +212,26 @@ public static NotificationMessageBuilder WithButton(
return builder;
}
+ ///
+ /// Attaches the dismiss action before callback action.
+ ///
+ /// The builder.
+ /// The callback.
+ ///
+ /// Returns the action that will call manager dismiss for notification
+ /// message builder when called and then call the callback action.
+ ///
+ private static Action DismissBefore(
+ this NotificationMessageBuilder builder,
+ Action callback)
+ {
+ return call =>
+ {
+ builder.Manager.Dismiss(builder.Message);
+ callback?.Invoke(builder.Message);
+ };
+ }
+
///
/// Attached the dismiss action before callback action.
///
diff --git a/Enterwell.Clients.Wpf.Notifications/Properties/AssemblyInfo.cs b/Enterwell.Clients.Wpf.Notifications/Properties/AssemblyInfo.cs
index cc4e554..d97e3f7 100644
--- a/Enterwell.Clients.Wpf.Notifications/Properties/AssemblyInfo.cs
+++ b/Enterwell.Clients.Wpf.Notifications/Properties/AssemblyInfo.cs
@@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Enterwell d.o.o.")]
[assembly: AssemblyProduct("Enterwell.Clients.Wpf.Notifications")]
-[assembly: AssemblyCopyright("Copyright © Enterwell d.o.o. 2017")]
+[assembly: AssemblyCopyright("Copyright © Enterwell d.o.o. 2017-2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -49,5 +49,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]