From 2ecbaad9554ba931918ea379c511dbd03aa7dcfc Mon Sep 17 00:00:00 2001 From: Aleksandar Toplek Date: Sat, 9 Jun 2018 22:09:43 +0200 Subject: [PATCH 1/2] Renamed OverBadge to Above badge - marked INotificationAnimation interface public - left aligned header and message (instead of stretched) - added missing comments - updated readme and changelog - bumped version --- Changelog.md | 10 + .../App.xaml.cs | 12 +- .../MainWindow.xaml | 47 ++- .../MainWindow.xaml.cs | 23 +- .../ActionExtensions.cs | 27 -- .../ContentLocation.cs | 13 +- .../Controls/NotificationMessage.cs | 25 +- .../Controls/NotificationMessageContainer.cs | 26 +- ...Enterwell.Clients.Wpf.Notifications.csproj | 1 - .../INotificationAnimation.cs | 2 +- .../NotificationMessageBuilder.cs | 34 +- .../NotificationMessageBuilderLinq.cs | 54 ++-- .../NotificationMessageFactory.cs | 2 +- .../NotificationMessageManagerEventArgs.cs | 2 +- .../Properties/AssemblyInfo.cs | 4 +- .../Themes/Generic.xaml | 296 ++++++++++-------- Readme.md | 17 + 17 files changed, 309 insertions(+), 286 deletions(-) delete mode 100644 Enterwell.Clients.Wpf.Notifications/ActionExtensions.cs diff --git a/Changelog.md b/Changelog.md index 5d7a991..c43b70e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,16 @@ 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.4.0] - 2018-06-09 +### Added +- Added `WithAdditionalContent` feature + +### Changed +- `NotificationHeaderTextStyle` and `NotificationMessageTextStyle` are now aligned left horizontally (instead of stretched) + +### Fixed +- `INotificationAnimation` interface is now marked as public + ## [1.3.1] - 2018-05-30 ### Fixed - Fixed message header foreground not set by `SetForeground` method call. diff --git a/Enterwell.Clients.Wpf.Notifications.Sample/App.xaml.cs b/Enterwell.Clients.Wpf.Notifications.Sample/App.xaml.cs index 4317718..2c5da0a 100644 --- a/Enterwell.Clients.Wpf.Notifications.Sample/App.xaml.cs +++ b/Enterwell.Clients.Wpf.Notifications.Sample/App.xaml.cs @@ -1,17 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; - -namespace Enterwell.Clients.Wpf.Notifications.Sample +namespace Enterwell.Clients.Wpf.Notifications.Sample { /// /// Interaction logic for App.xaml /// - public partial class App : Application + public partial class App { } } diff --git a/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml b/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml index 20b757f..ff265ba 100644 --- a/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml +++ b/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml @@ -1,10 +1,10 @@ - - + - + + + + @@ -38,7 +41,7 @@ - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml.cs b/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml.cs index a77b7b0..c115374 100644 --- a/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml.cs +++ b/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.ObjectModel; -using System.Runtime.Serialization; using System.Windows; using System.Windows.Controls; using System.Windows.Media; -using Enterwell.Clients.Wpf.Notifications.Controls; namespace Enterwell.Clients.Wpf.Notifications.Sample { @@ -92,16 +89,11 @@ private void ButtonBaseInfoDelayOnClick(object sender, RoutedEventArgs e) private void ButtonBaseAdditionalContentOnClick(object sender, RoutedEventArgs e) { - Thickness margin = new Thickness(); - margin.Top = margin.Bottom = margin.Left = margin.Right = 5; this.Manager .CreateMessage() .Accent("#1751C3") - .Animates(true) - .AnimationInDuration(0.5) - .AnimationOutDuration(0.5) .Background("#333") - .Foreground("#000") + .Foreground("#333") .HasBadge("Info") .HasHeader("Header") .HasMessage("This is the message!") @@ -140,23 +132,12 @@ private void ButtonBaseAdditionalContentOnClick(object sender, RoutedEventArgs e HorizontalAlignment = HorizontalAlignment.Stretch, Background = Brushes.Orange }) - .WithAdditionalContent(ContentLocation.OverBadge, new Border + .WithAdditionalContent(ContentLocation.AboveBadge, new Border { Height = 40, Width = 40, Background = Brushes.Indigo }) - .WithOverlay(new ProgressBar - { - VerticalAlignment = VerticalAlignment.Bottom, - HorizontalAlignment = HorizontalAlignment.Stretch, - Height = 3, - BorderThickness = new Thickness(0), - Foreground = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255)), - Background = Brushes.Transparent, - IsIndeterminate = true, - IsHitTestVisible = false - }) .Dismiss().WithButton("Dismiss", button => { }) .Queue(); } diff --git a/Enterwell.Clients.Wpf.Notifications/ActionExtensions.cs b/Enterwell.Clients.Wpf.Notifications/ActionExtensions.cs deleted file mode 100644 index 51d89c3..0000000 --- a/Enterwell.Clients.Wpf.Notifications/ActionExtensions.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; - -namespace Enterwell.Clients.Wpf.Notifications -{ - /// - /// The extensions. - /// - internal static class ActionExtensions - { - /// - /// Invokes the specified action after first action was successfully invoked. - /// - /// The action data type. - /// The action data type. - /// The base action. - /// The after base action. - /// Returns new action that first calls baseAction and then afterBaseAction. - public static Action DoAfter(this Action baseAction, Action afterBaseAction) - { - return (data1, data2) => - { - baseAction?.Invoke(data1, data2); - afterBaseAction?.Invoke(data1, data2); - }; - } - } -} \ No newline at end of file diff --git a/Enterwell.Clients.Wpf.Notifications/ContentLocation.cs b/Enterwell.Clients.Wpf.Notifications/ContentLocation.cs index 25e3097..7b27230 100644 --- a/Enterwell.Clients.Wpf.Notifications/ContentLocation.cs +++ b/Enterwell.Clients.Wpf.Notifications/ContentLocation.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Enterwell.Clients.Wpf.Notifications +namespace Enterwell.Clients.Wpf.Notifications { + /// + /// The additional content location. + /// public enum ContentLocation { Top, @@ -13,6 +10,6 @@ public enum ContentLocation Left, Right, Main, - OverBadge + AboveBadge } } diff --git a/Enterwell.Clients.Wpf.Notifications/Controls/NotificationMessage.cs b/Enterwell.Clients.Wpf.Notifications/Controls/NotificationMessage.cs index db8a1e2..7d3622b 100644 --- a/Enterwell.Clients.Wpf.Notifications/Controls/NotificationMessage.cs +++ b/Enterwell.Clients.Wpf.Notifications/Controls/NotificationMessage.cs @@ -257,10 +257,7 @@ public double AnimationOutDuration /// /// The animatable element used for show/hide animations. /// - public UIElement AnimatableElement - { - get => this; - } + public UIElement AnimatableElement => this; /// /// The animation in. @@ -327,7 +324,7 @@ public DependencyProperty AnimationInDependencyProperty get { var property = (DependencyProperty)GetValue(AnimationInDependencyPropProperty); - return property ?? UIElement.OpacityProperty; + return property ?? OpacityProperty; } set => SetValue(AnimationInDependencyPropProperty, value); } @@ -340,7 +337,7 @@ public DependencyProperty AnimationOutDependencyProperty get { var property = (DependencyProperty)GetValue(AnimationOutDependencyPropProperty); - return property ?? UIElement.OpacityProperty; + return property ?? OpacityProperty; } set => SetValue(AnimationOutDependencyPropProperty, value); } @@ -376,7 +373,7 @@ public DependencyProperty AnimationOutDependencyProperty DependencyProperty.Register("AdditionalContentRight", typeof(object), typeof(NotificationMessage), new PropertyMetadata(null)); /// - /// The additional content center property. + /// The additional content main property. /// public static readonly DependencyProperty AdditionalContentMainProperty = DependencyProperty.Register("AdditionalContentMain", typeof(object), typeof(NotificationMessage), new PropertyMetadata(null)); @@ -400,8 +397,7 @@ public DependencyProperty AnimationOutDependencyProperty /// The instance containing the event data. private static void AccentBrushPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { - var @this = dependencyObject as NotificationMessage; - if (@this == null) + if (!(dependencyObject is NotificationMessage @this)) throw new NullReferenceException("Dependency object is not of valid type " + nameof(NotificationMessage)); if (@this.BadgeAccentBrush == null) @@ -446,8 +442,7 @@ private static void AccentBrushPropertyChangedCallback(DependencyObject dependen /// The instance containing the event data. private static void BadgeTextPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { - var @this = dependencyObject as NotificationMessage; - if (@this == null) + if (!(dependencyObject is NotificationMessage @this)) throw new NullReferenceException("Dependency object is not of valid type " + nameof(NotificationMessage)); @this.BadgeVisibility = dependencyPropertyChangedEventArgs.NewValue == null @@ -474,8 +469,7 @@ private static void BadgeTextPropertyChangedCallback(DependencyObject dependency /// The instance containing the event data. private static void HeaderPropertyChangesCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { - var @this = dependencyObject as NotificationMessage; - if (@this == null) + if (!(dependencyObject is NotificationMessage @this)) throw new NullReferenceException("Dependency object is not of valid type " + nameof(NotificationMessage)); @this.HeaderVisibility = dependencyPropertyChangedEventArgs.NewValue == null @@ -502,8 +496,7 @@ private static void HeaderPropertyChangesCallback(DependencyObject dependencyObj /// The instance containing the event data. private static void MessagePropertyChangesCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { - var @this = dependencyObject as NotificationMessage; - if (@this == null) + if (!(dependencyObject is NotificationMessage @this)) throw new NullReferenceException("Dependency object is not of valid type " + nameof(NotificationMessage)); @this.MessageVisibility = dependencyPropertyChangedEventArgs.NewValue == null @@ -576,7 +569,7 @@ public NotificationMessage() { this.Buttons = new ObservableCollection(); - //Setting the default text color, if not defined by user. + // Setting the default text color, if not defined by user. this.Foreground = new BrushConverter().ConvertFromString("#DDDDDD") as Brush; } } diff --git a/Enterwell.Clients.Wpf.Notifications/Controls/NotificationMessageContainer.cs b/Enterwell.Clients.Wpf.Notifications/Controls/NotificationMessageContainer.cs index 9b97e2c..8fe5606 100644 --- a/Enterwell.Clients.Wpf.Notifications/Controls/NotificationMessageContainer.cs +++ b/Enterwell.Clients.Wpf.Notifications/Controls/NotificationMessageContainer.cs @@ -1,7 +1,6 @@ using System; using System.Windows; using System.Windows.Controls; -using System.Windows.Media.Animation; namespace Enterwell.Clients.Wpf.Notifications.Controls { @@ -19,8 +18,8 @@ public class NotificationMessageContainer : ItemsControl /// public INotificationMessageManager Manager { - get { return (INotificationMessageManager)GetValue(ManagerProperty); } - set { SetValue(ManagerProperty, value); } + get => (INotificationMessageManager)this.GetValue(ManagerProperty); + set => this.SetValue(ManagerProperty, value); } /// @@ -34,11 +33,10 @@ public INotificationMessageManager Manager /// /// The dependency object. /// The instance containing the event data. - /// Dependency object is not of valid type " + nameof(NotificationMessageContainer) + /// Dependency object is not of valid type - expected NotificationMessageContainer. private static void ManagerPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { - var @this = dependencyObject as NotificationMessageContainer; - if (@this == null) + if (!(dependencyObject is NotificationMessageContainer @this)) throw new NullReferenceException("Dependency object is not of valid type " + nameof(NotificationMessageContainer)); if (dependencyPropertyChangedEventArgs.OldValue is INotificationMessageManager oldManager) @@ -80,12 +78,13 @@ private void ManagerOnOnMessageDismissed(object sender, NotificationMessageManag throw new InvalidOperationException( "Can't use both ItemsSource and Items collection at the same time."); - if (args.Message is INotificationAnimation) + if (args.Message is INotificationAnimation animatableMessage) { - var animatableMessage = args.Message as INotificationAnimation; var animation = animatableMessage.AnimationOut; - if (animatableMessage.Animates && animatableMessage.AnimatableElement != null - && animation != null && animatableMessage.AnimationOutDependencyProperty != null) + if (animation != null && + animatableMessage.Animates && + animatableMessage.AnimatableElement != null && + animatableMessage.AnimationOutDependencyProperty != null) { animation.Completed += (s, a) => this.RemoveMessage(args.Message); animatableMessage.AnimatableElement.BeginAnimation(animatableMessage.AnimationOutDependencyProperty, animation); @@ -103,7 +102,7 @@ private void ManagerOnOnMessageDismissed(object sender, NotificationMessageManag private void RemoveMessage(INotificationMessage message) { - this.Items?.Remove(message); + this.Items.Remove(message); } /// @@ -118,11 +117,10 @@ private void ManagerOnOnMessageQueued(object sender, NotificationMessageManagerE throw new InvalidOperationException( "Can't use both ItemsSource and Items collection at the same time."); - this.Items?.Add(args.Message); + this.Items.Add(args.Message); - if (args.Message is INotificationAnimation) + if (args.Message is INotificationAnimation animatableMessage) { - var animatableMessage = args.Message as INotificationAnimation; var animation = animatableMessage.AnimationIn; if (animatableMessage.Animates && animatableMessage.AnimatableElement != null && animation != null && animatableMessage.AnimationInDependencyProperty != null) diff --git a/Enterwell.Clients.Wpf.Notifications/Enterwell.Clients.Wpf.Notifications.csproj b/Enterwell.Clients.Wpf.Notifications/Enterwell.Clients.Wpf.Notifications.csproj index 8b6157c..130cdea 100644 --- a/Enterwell.Clients.Wpf.Notifications/Enterwell.Clients.Wpf.Notifications.csproj +++ b/Enterwell.Clients.Wpf.Notifications/Enterwell.Clients.Wpf.Notifications.csproj @@ -53,7 +53,6 @@ - diff --git a/Enterwell.Clients.Wpf.Notifications/INotificationAnimation.cs b/Enterwell.Clients.Wpf.Notifications/INotificationAnimation.cs index 2803df5..eadc83e 100644 --- a/Enterwell.Clients.Wpf.Notifications/INotificationAnimation.cs +++ b/Enterwell.Clients.Wpf.Notifications/INotificationAnimation.cs @@ -7,7 +7,7 @@ namespace Enterwell.Clients.Wpf.Notifications /// The animation properties for a notification message or some /// other item. /// - interface INotificationAnimation + public interface INotificationAnimation { /// /// Gets or sets whether the item animates in and out. diff --git a/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilder.cs b/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilder.cs index b13f1fe..b8a5f1d 100644 --- a/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilder.cs +++ b/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilder.cs @@ -31,7 +31,7 @@ public class NotificationMessageBuilder /// /// Creates the message. /// - /// Returns new instance of notification message builder tha tis used to create notification message. + /// Returns new instance of notification message builder that is used to create notification message. public static NotificationMessageBuilder CreateMessage() { return new NotificationMessageBuilder(); @@ -171,33 +171,33 @@ public void SetForeground(Brush brush) /// public void SetAnimates(bool animates) { - if (this.Message is INotificationAnimation) + if (this.Message is INotificationAnimation animation) { - ((INotificationAnimation)this.Message).Animates = animates; + animation.Animates = animates; } } /// /// Sets the duration for the animation in (in seconds). /// - /// + /// The in animation duration (in seconds). public void SetAnimationInDuration(double duration) { - if (this.Message is INotificationAnimation) + if (this.Message is INotificationAnimation animation) { - ((INotificationAnimation)this.Message).AnimationInDuration = duration; + animation.AnimationInDuration = duration; } } /// /// Sets the duration for the animation out (in seconds). /// - /// + /// The out animation duration (in seconds). public void SetAnimationOutDuration(double duration) { - if (this.Message is INotificationAnimation) + if (this.Message is INotificationAnimation animation) { - ((INotificationAnimation)this.Message).AnimationOutDuration = duration; + animation.AnimationOutDuration = duration; } } @@ -207,9 +207,9 @@ public void SetAnimationOutDuration(double duration) /// public void SetAnimationIn(AnimationTimeline animation) { - if (this.Message is INotificationAnimation) + if (this.Message is INotificationAnimation notificationAnimation) { - ((INotificationAnimation)this.Message).AnimationIn = animation; + notificationAnimation.AnimationIn = animation; } } @@ -219,9 +219,9 @@ public void SetAnimationIn(AnimationTimeline animation) /// public void SetAnimationOut(AnimationTimeline animation) { - if (this.Message is INotificationAnimation) + if (this.Message is INotificationAnimation notificationAnimation) { - ((INotificationAnimation)this.Message).AnimationOut = animation; + notificationAnimation.AnimationOut = animation; } } @@ -231,9 +231,9 @@ public void SetAnimationOut(AnimationTimeline animation) /// public void SetAnimationInDependencyProperty(DependencyProperty property) { - if (this.Message is INotificationAnimation) + if (this.Message is INotificationAnimation animation) { - ((INotificationAnimation)this.Message).AnimationInDependencyProperty = property; + animation.AnimationInDependencyProperty = property; } } @@ -243,9 +243,9 @@ public void SetAnimationInDependencyProperty(DependencyProperty property) /// public void SetAnimationOutDependencyProperty(DependencyProperty property) { - if (this.Message is INotificationAnimation) + if (this.Message is INotificationAnimation animation) { - ((INotificationAnimation)this.Message).AnimationOutDependencyProperty = property; + animation.AnimationOutDependencyProperty = property; } } diff --git a/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilderLinq.cs b/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilderLinq.cs index 53383f2..fca89be 100644 --- a/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilderLinq.cs +++ b/Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilderLinq.cs @@ -2,6 +2,8 @@ using System.Windows; using System.Windows.Media; using System.Windows.Media.Animation; +// ReSharper disable UnusedMember.Global +// ReSharper disable RedundantEmptySwitchSection namespace Enterwell.Clients.Wpf.Notifications { @@ -11,11 +13,11 @@ namespace Enterwell.Clients.Wpf.Notifications public static class NotificationMessageBuilderLinq { /// - /// Sets the notification mesage background. + /// Sets the notification message background. /// /// The builder. /// The background brush. - /// Returns the noitificaiton message builder. + /// Returns the notification message builder. public static NotificationMessageBuilder Background( this NotificationMessageBuilder builder, Brush backgroundBrush) @@ -26,11 +28,11 @@ public static NotificationMessageBuilder Background( } /// - /// Sets the notification mesage background. + /// Sets the notification message background. /// /// The builder. /// The background brush. - /// Returns the noitificaiton message builder. + /// Returns the notification message builder. public static NotificationMessageBuilder Background( this NotificationMessageBuilder builder, string backgroundBrush) @@ -42,11 +44,11 @@ public static NotificationMessageBuilder Background( } /// - /// Sets the notification mesage accent. + /// Sets the notification message accent. /// /// The builder. /// The accent brush. - /// Returns the noitificaiton message builder. + /// Returns the notification message builder. public static NotificationMessageBuilder Accent( this NotificationMessageBuilder builder, Brush accentBrush) @@ -57,11 +59,11 @@ public static NotificationMessageBuilder Accent( } /// - /// Sets the notification mesage accent. + /// Sets the notification message accent. /// /// The builder. /// The accent brush. - /// Returns the noitificaiton message builder. + /// Returns the notification message builder. public static NotificationMessageBuilder Accent( this NotificationMessageBuilder builder, string accentBrush) @@ -134,10 +136,10 @@ public static NotificationMessageBuilder CreateMessage( /// /// Marks next button to be dismiss. - /// This button will dismiss the noitification message when clicked. + /// This button will dismiss the notification message when clicked. /// /// The builder. - /// Returns the notiification message builder. + /// Returns the notification message builder. public static NotificationMessageBuilder.DismissNotificationMessage Dismiss( this NotificationMessageBuilder builder) { @@ -240,7 +242,7 @@ private static Action DismissBefore( /// The builder. /// The callback. /// - /// Returns the action that will call manager dismiss for noitification + /// Returns the action that will call manager dismiss for notification /// message in builder when button is clicked and then call the callback action. /// private static Action DismissBefore( @@ -255,7 +257,7 @@ private static Action DismissBefore( } /// - /// Sets the noitification message overlay. + /// Sets the notification message overlay. /// /// The builder. /// The overlay. @@ -270,7 +272,7 @@ public static NotificationMessageBuilder WithOverlay( } /// - /// Sets the noitification message top additional content. + /// Sets the notification message top additional content. /// /// The builder. /// The additional content. @@ -308,7 +310,7 @@ public static NotificationMessageBuilder WithAdditionalContent( builder.SetAdditionalContentMain(additionalContent); break; } - case ContentLocation.OverBadge: + case ContentLocation.AboveBadge: { builder.SetAdditionalContentOverBadge(additionalContent); break; @@ -326,7 +328,7 @@ public static NotificationMessageBuilder WithAdditionalContent( /// /// The builder. /// The foreground brush. - /// Returns the noitificaiton message builder. + /// Returns the notification message builder. public static NotificationMessageBuilder Foreground( this NotificationMessageBuilder builder, string foregroundBrush) @@ -342,7 +344,7 @@ public static NotificationMessageBuilder Foreground( /// /// The builder. /// Whether or not the message should animate. - /// + /// Returns the notification message builder. public static NotificationMessageBuilder Animates( this NotificationMessageBuilder builder, bool animates) @@ -357,7 +359,7 @@ public static NotificationMessageBuilder Animates( /// /// The builder. /// How long the message should animate in (in seconds). - /// + /// Returns the notification message builder. public static NotificationMessageBuilder AnimationInDuration( this NotificationMessageBuilder builder, double duration) @@ -372,7 +374,7 @@ public static NotificationMessageBuilder AnimationInDuration( /// /// The builder. /// How long the message should animate out (in seconds). - /// + /// Returns the notification message builder. public static NotificationMessageBuilder AnimationOutDuration( this NotificationMessageBuilder builder, double duration) @@ -386,8 +388,8 @@ public static NotificationMessageBuilder AnimationOutDuration( /// Sets the animation in for the message. /// /// The builder. - /// The message animation in. - /// + /// The animation time line. + /// Returns the notification message builder. public static NotificationMessageBuilder AnimationIn( this NotificationMessageBuilder builder, AnimationTimeline animation) @@ -401,8 +403,8 @@ public static NotificationMessageBuilder AnimationIn( /// Sets the animation out for the message. /// /// The builder. - /// The message animation out. - /// + /// The animation time line. + /// Returns the notification message builder. public static NotificationMessageBuilder AnimationOut( this NotificationMessageBuilder builder, AnimationTimeline animation) @@ -416,8 +418,8 @@ public static NotificationMessageBuilder AnimationOut( /// Sets the animation in dependency property for the message. /// /// The builder. - /// The animation in dependency property. - /// + /// The animation in dependency property. + /// Returns the notification message builder. public static NotificationMessageBuilder AnimationInDependencyProperty( this NotificationMessageBuilder builder, DependencyProperty property) @@ -431,8 +433,8 @@ public static NotificationMessageBuilder AnimationInDependencyProperty( /// Sets the animation out dependency property for the message. /// /// The builder. - /// The animation out dependency property. - /// + /// The animation out dependency property. + /// Returns the notification message builder. public static NotificationMessageBuilder AnimationOutDependencyProperty( this NotificationMessageBuilder builder, DependencyProperty property) diff --git a/Enterwell.Clients.Wpf.Notifications/NotificationMessageFactory.cs b/Enterwell.Clients.Wpf.Notifications/NotificationMessageFactory.cs index 3281d92..9378288 100644 --- a/Enterwell.Clients.Wpf.Notifications/NotificationMessageFactory.cs +++ b/Enterwell.Clients.Wpf.Notifications/NotificationMessageFactory.cs @@ -3,7 +3,7 @@ namespace Enterwell.Clients.Wpf.Notifications { /// - /// The noitification message factory. + /// The notification message factory. /// /// public class NotificationMessageFactory : INotificationMessageFactory diff --git a/Enterwell.Clients.Wpf.Notifications/NotificationMessageManagerEventArgs.cs b/Enterwell.Clients.Wpf.Notifications/NotificationMessageManagerEventArgs.cs index 2a78063..13f7ab0 100644 --- a/Enterwell.Clients.Wpf.Notifications/NotificationMessageManagerEventArgs.cs +++ b/Enterwell.Clients.Wpf.Notifications/NotificationMessageManagerEventArgs.cs @@ -3,7 +3,7 @@ namespace Enterwell.Clients.Wpf.Notifications { /// - /// The notificaiton message manager event arguments. + /// The notification message manager event arguments. /// /// public class NotificationMessageManagerEventArgs : EventArgs diff --git a/Enterwell.Clients.Wpf.Notifications/Properties/AssemblyInfo.cs b/Enterwell.Clients.Wpf.Notifications/Properties/AssemblyInfo.cs index 8e89c65..b1da2fd 100644 --- a/Enterwell.Clients.Wpf.Notifications/Properties/AssemblyInfo.cs +++ b/Enterwell.Clients.Wpf.Notifications/Properties/AssemblyInfo.cs @@ -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.3.1.0")] -[assembly: AssemblyFileVersion("1.3.1.0")] +[assembly: AssemblyVersion("1.4.0.0")] +[assembly: AssemblyFileVersion("1.4.0.0")] diff --git a/Enterwell.Clients.Wpf.Notifications/Themes/Generic.xaml b/Enterwell.Clients.Wpf.Notifications/Themes/Generic.xaml index c21b405..1663931 100644 --- a/Enterwell.Clients.Wpf.Notifications/Themes/Generic.xaml +++ b/Enterwell.Clients.Wpf.Notifications/Themes/Generic.xaml @@ -1,7 +1,8 @@ - + #333333 #666666 @@ -17,6 +18,13 @@ + + @@ -41,25 +51,28 @@ - - - + + + @@ -85,28 +98,29 @@ - - - + + + - @@ -120,105 +134,116 @@ - - - - - - - - - + + + + + + + + + - - + + - - + + - + - - + + - - + + - + @@ -232,14 +257,15 @@ - + @@ -260,18 +286,20 @@ - + - + diff --git a/Readme.md b/Readme.md index 0e1df72..a7d1465 100644 --- a/Readme.md +++ b/Readme.md @@ -116,6 +116,23 @@ manager.CreateMessage() The `WithOverlay` allows you to set custom overlay content. In this example a progress bar is placed on the bottom of notification control. Notice the `IsHitTextVisible` is set to `false` so that notification message buttons don't lose focus due to overlay control being over the bottom part of the buttons. +### Custom additional content for notification + +```c# +manager.CreateMessage() + .Accent("#F15B19") + .Background("#F15B19") + .HasHeader("Lost connection to server") + .HasMessage("Reconnecting...") + .WithAdditionalContent(ContentLocation.Main, new CheckBox + { + Margin = new Thickness(16), + HorizontalAlignment = HorizontalAlignment.Right, + Content = "Don't show again" + }) + .Queue(); +``` + ### Multiple notification The `NotificationMessageContainer` has build-in support for showing multiple notifications at the same time. New notifications will show at the bottom of the message stack. From 27046b2dfcecc0016dd3f7767debd5b6b7957541 Mon Sep 17 00:00:00 2001 From: Aleksandar Toplek Date: Sat, 9 Jun 2018 22:30:17 +0200 Subject: [PATCH 2/2] Fixed sample, added image --- .../MainWindow.xaml | 31 ---------------- Readme.md | 35 +++++++++++++----- ...reNotificationMessageAdditionalContent.PNG | Bin 0 -> 5465 bytes 3 files changed, 25 insertions(+), 41 deletions(-) create mode 100644 docs/images/CaptureNotificationMessageAdditionalContent.PNG diff --git a/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml b/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml index ff265ba..6478fbc 100644 --- a/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml +++ b/Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml @@ -101,34 +101,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Readme.md b/Readme.md index a7d1465..9ee681f 100644 --- a/Readme.md +++ b/Readme.md @@ -118,21 +118,36 @@ The `WithOverlay` allows you to set custom overlay content. In this example a pr ### Custom additional content for notification +![Notification message with additional content - checkbox at the bottom](docs/images/CaptureNotificationMessageAdditionalContent.PNG) + ```c# manager.CreateMessage() - .Accent("#F15B19") - .Background("#F15B19") - .HasHeader("Lost connection to server") - .HasMessage("Reconnecting...") - .WithAdditionalContent(ContentLocation.Main, new CheckBox - { - Margin = new Thickness(16), - HorizontalAlignment = HorizontalAlignment.Right, - Content = "Don't show again" - }) + .Accent("#1751C3") + .Background("#333") + .HasBadge("Info") + .HasHeader("Update available") + .HasMessage("Update will be installed on next application restart.") + .Dismiss().WithButton("Update now", button => { }) + .Dismiss().WithButton("Later", button => { }) + .WithAdditionalContent(ContentLocation.Bottom, + new Border + { + BorderThickness = new Thickness(0,1,0,0), + BorderBrush = new SolidColorBrush(Color.FromArgb(128, 28, 28, 28)), + Child = new CheckBox + { + Margin = new Thickness(12, 8, 12, 8), + HorizontalAlignment = HorizontalAlignment.Left, + Content = "Don't show again" + } + }) .Queue(); ``` +In this example a custom "Don't show again" checkbox is located at the bottom of the message. + +You can add additional content to following locations: `Top, Bottom, Left, Right, Main, AboveBadge`. + ### Multiple notification The `NotificationMessageContainer` has build-in support for showing multiple notifications at the same time. New notifications will show at the bottom of the message stack. diff --git a/docs/images/CaptureNotificationMessageAdditionalContent.PNG b/docs/images/CaptureNotificationMessageAdditionalContent.PNG new file mode 100644 index 0000000000000000000000000000000000000000..771483105d5a523563693014bc87acdbbc1b6dde GIT binary patch literal 5465 zcmZ`-c|4Te+rN_}TS<8A<*_AEglwgZDEppW_As`LeTgC>(qfFUX5aTIGnVAh5SoM; znnALZZ4_C?`kv|eyzlS#&ucz&&vEW^UFV!@{a#m+v7rt-3qK14LF_kmVWtqo-~+~? z%uL{EWKa_eewdu~bYRc{{gdBT`W(z0^VhY$2SFTN^zR|OUzsbIJQ{SO%7remiB zWM&7Mh!AvY?k4P-dFYqr@fc45k6iq(+CZvXmr`(Xk-;$BMdYz^#5w-N9D4@t;u)6n znU9;!GMNQGVv0jfRQJ|bbDnX%%Y3cuEN>*m^zTtO4vq(9xK8a)@wR4h*oVa6{PGBr z>bDtVqCt#qa~sVh>&B)|Xzmq-taLYguq$mZ?%VCP9n{(FtsQj*t~bHUHrC*X#;>z# z>~S~Ff#L8yCv;w3DK{80({Fq`&%lU1+#-`*RAAWf|!%{Tt}3xg1QdF!SOkN2pH?Z+_Q#w+woEK2Ef3VR`S z#XNbTx7a}#*IPXqp69n^Bzj#NWH)OaHd&$jFE!%)V{qrtNvd#Lk$mjd}(FDyG zw~C8y%cv63hNV#t44dJjm}M2F^QTzm;Wr9R@ECbi%FG(=$OBW+^b=&vdZbq?nkC1p zV|;B(NKZ8Vsj-xK0EJNrNEeQZ!cO;B_^lQ6=~%k96`S^Q76rCs!$digx}Bf(&58-9 z^}T(2-v#9=e|A3TOMMF8<>5dtA&05T+cK8sO{=ul+Zn~@982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