Skip to content

Commit

Permalink
fixed #25
Browse files Browse the repository at this point in the history
  • Loading branch information
UmutComlekci committed Oct 14, 2018
1 parent 10f951c commit 60e2350
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 69 deletions.
4 changes: 4 additions & 0 deletions Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ public MainWindow()
{
this.InitializeComponent();
this.DataContext = this;
Manager.OnMessageDismissed += Manager_OnMessageDismissed;
}

private void Manager_OnMessageDismissed(object sender, NotificationMessageManagerEventArgs args)
{
}

private void ButtonBaseErrorOnClick(object sender, RoutedEventArgs e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ private static void ManagerPropertyChangedCallback(DependencyObject dependencyOb
{
if (!(dependencyObject is NotificationMessageContainer @this))
throw new NullReferenceException("Dependency object is not of valid type " + nameof(NotificationMessageContainer));

if (dependencyPropertyChangedEventArgs.OldValue is INotificationMessageManager oldManager)
@this.DetachManagerEvents(oldManager);

if (dependencyPropertyChangedEventArgs.NewValue is INotificationMessageManager newManager)
@this.AttachManagerEvents(newManager);
}
Expand Down Expand Up @@ -78,26 +78,7 @@ 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 animatableMessage)
{
var animation = animatableMessage.AnimationOut;
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);
}
else
{
this.RemoveMessage(args.Message);
}
}
else
{
this.RemoveMessage(args.Message);
}
this.RemoveMessage(args.Message);
}

private void RemoveMessage(INotificationMessage message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,28 +231,7 @@ private static Action<INotificationMessage> DismissBefore(
{
return call =>
{
if (builder.Message is INotificationAnimation animatableMessage)
{
var animation = animatableMessage.AnimationOut;
if (animation != null &&
animatableMessage.Animates &&
animatableMessage.AnimatableElement != null &&
animatableMessage.AnimationOutDependencyProperty != null)
{
animation.Completed += (s, a) =>
{
builder.Manager.Dismiss(builder.Message);
};
}
else
{
builder.Manager.Dismiss(builder.Message);
}
}
else
{
builder.Manager.Dismiss(builder.Message);
}
builder.Manager.Dismiss(builder.Message);
callback?.Invoke(builder.Message);
};
}
Expand All @@ -272,28 +251,7 @@ private static Action<INotificationMessageButton> DismissBefore(
{
return button =>
{
if (builder.Message is INotificationAnimation animatableMessage)
{
var animation = animatableMessage.AnimationOut;
if (animation != null &&
animatableMessage.Animates &&
animatableMessage.AnimatableElement != null &&
animatableMessage.AnimationOutDependencyProperty != null)
{
animation.Completed += (s, a) =>
{
builder.Manager.Dismiss(builder.Message);
};
}
else
{
builder.Manager.Dismiss(builder.Message);
}
}
else
{
builder.Manager.Dismiss(builder.Message);
}
builder.Manager.Dismiss(builder.Message);
callback?.Invoke(button);
};
}
Expand Down Expand Up @@ -360,11 +318,11 @@ public static NotificationMessageBuilder WithAdditionalContent(
default:
{ break; }
}


return builder;
}

/// <summary>
/// Sets the foreground brush.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,29 @@ public void Dismiss(INotificationMessage message)

this.queuedMessages.Remove(message);

this.TriggerMessageDismissed(message);
if (message is INotificationAnimation animatableMessage)
{
var animation = animatableMessage.AnimationOut;
if (animation != null &&
animatableMessage.Animates &&
animatableMessage.AnimatableElement != null &&
animatableMessage.AnimationOutDependencyProperty != null)
{
animation.Completed += (s, a) =>
{
this.TriggerMessageDismissed(message);
};
animatableMessage.AnimatableElement.BeginAnimation(animatableMessage.AnimationOutDependencyProperty, animation);
}
else
{
this.TriggerMessageDismissed(message);
}
}
else
{
this.TriggerMessageDismissed(message);
}
}

/// <summary>
Expand Down

0 comments on commit 60e2350

Please sign in to comment.