Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ $RECYCLE.BIN/
Network Trash Folder
Temporary Items
.apdisk
*.suo
1.0/WPFNotification/.vs/WPFNotification/v14/.suo
Binary file modified 1.0/WPFNotification/.vs/WPFNotification/v14/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion 1.0/WPFNotification/WPFNotification/App.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ namespace WPFNotification.Converters
{
public class EmptyStringConverter : BaseConverter, IValueConverter
{
public EmptyStringConverter()
{ }
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
Expand All @@ -19,6 +17,5 @@ public object ConvertBack(object value, Type targetType,
{
throw new NotImplementedException();
}

}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WPFNotification.Core.Configuration
namespace WPFNotification.Core.Configuration
{
/// <summary>
/// Enum that represent the notification window Directions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,35 +59,35 @@ public sealed class FadeBehavior : Behavior<FrameworkElement>
/// </summary>
public TimeSpan BeginTime
{
get { return (TimeSpan)this.GetValue(BeginTimeProperty); }
set { this.SetValue(BeginTimeProperty, value); }
get { return (TimeSpan)GetValue(BeginTimeProperty); }
set { SetValue(BeginTimeProperty, value); }
}

/// <summary>
/// Gets or sets the duration.
/// </summary>
public TimeSpan Duration
{
get { return (TimeSpan)this.GetValue(DurationProperty); }
set { this.SetValue(DurationProperty, value); }
get { return (TimeSpan)GetValue(DurationProperty); }
set { SetValue(DurationProperty, value); }
}

/// <summary>
/// Gets or sets a value indicating whether is animating on is visible changed.
/// </summary>
public bool IsAnimatingOnIsVisibleChanged
{
get { return (bool)this.GetValue(IsAnimatingOnIsVisibleChangedProperty); }
set { this.SetValue(IsAnimatingOnIsVisibleChangedProperty, value); }
get { return (bool)GetValue(IsAnimatingOnIsVisibleChangedProperty); }
set { SetValue(IsAnimatingOnIsVisibleChangedProperty, value); }
}

/// <summary>
/// Gets or sets a value indicating whether is animating on loaded.
/// </summary>
public bool IsAnimatingOnLoaded
{
get { return (bool)this.GetValue(IsAnimatingOnLoadedProperty); }
set { this.SetValue(IsAnimatingOnLoadedProperty, value); }
get { return (bool)GetValue(IsAnimatingOnLoadedProperty); }
set { SetValue(IsAnimatingOnLoadedProperty, value); }
}

#endregion
Expand All @@ -99,31 +99,31 @@ public bool IsAnimatingOnLoaded
/// </summary>
public void FadeIn()
{
Storyboard storyboard = GetFadeInStoryboard(this.BeginTime, this.Duration);
Storyboard storyboard = GetFadeInStoryboard(BeginTime, Duration);
EventHandler eventHandler = null;
eventHandler = (sender, e) =>
{
storyboard.Completed -= eventHandler;
this.OnFadeInCompleted(this, EventArgs.Empty);
OnFadeInCompleted(this, EventArgs.Empty);
};
storyboard.Completed += eventHandler;
storyboard.Begin(this.AssociatedObject);
storyboard.Begin(AssociatedObject);
}

/// <summary>
/// The fade out.
/// </summary>
public void FadeOut()
{
Storyboard storyboard = GetFadeOutStoryboard(this.BeginTime, this.Duration);
Storyboard storyboard = GetFadeOutStoryboard(BeginTime, Duration);
EventHandler eventHandler = null;
eventHandler = (sender, e) =>
{
storyboard.Completed -= eventHandler;
this.OnFadeOutCompleted(this, EventArgs.Empty);
OnFadeOutCompleted(this, EventArgs.Empty);
};
storyboard.Completed += eventHandler;
storyboard.Begin(this.AssociatedObject);
storyboard.Begin(AssociatedObject);
}

#endregion
Expand All @@ -137,8 +137,8 @@ protected override void OnAttached()
{
base.OnAttached();

this.AssociatedObject.IsVisibleChanged += this.OnIsVisibleChanged;
this.AssociatedObject.Loaded += this.OnLoaded;
AssociatedObject.IsVisibleChanged += OnIsVisibleChanged;
AssociatedObject.Loaded += OnLoaded;
}

/// <summary>
Expand All @@ -148,8 +148,8 @@ protected override void OnDetaching()
{
base.OnDetaching();

this.AssociatedObject.IsVisibleChanged -= this.OnIsVisibleChanged;
this.AssociatedObject.Loaded -= this.OnLoaded;
AssociatedObject.IsVisibleChanged -= OnIsVisibleChanged;
AssociatedObject.Loaded -= OnLoaded;
}

#endregion
Expand All @@ -164,22 +164,24 @@ protected override void OnDetaching()
/// <returns> The <see cref="Storyboard"/>. </returns>
private static Storyboard GetFadeInStoryboard(TimeSpan beginTime, TimeSpan duration)
{
DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();
animation.FillBehavior = FillBehavior.HoldEnd;
DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames
{
FillBehavior = FillBehavior.HoldEnd
};
animation.KeyFrames.Add(
new SplineDoubleKeyFrame()
new SplineDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(new TimeSpan()),
Value = 0
});
animation.KeyFrames.Add(
new SplineDoubleKeyFrame()
new SplineDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(beginTime),
Value = 0
});
animation.KeyFrames.Add(
new SplineDoubleKeyFrame()
new SplineDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(beginTime + duration),
Value = 1
Expand All @@ -200,16 +202,18 @@ private static Storyboard GetFadeInStoryboard(TimeSpan beginTime, TimeSpan durat
/// <returns> The <see cref="Storyboard"/>. </returns>
private static Storyboard GetFadeOutStoryboard(TimeSpan beginTime, TimeSpan duration)
{
DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();
animation.FillBehavior = FillBehavior.HoldEnd;
DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames
{
FillBehavior = FillBehavior.HoldEnd
};
animation.KeyFrames.Add(
new SplineDoubleKeyFrame()
new SplineDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(beginTime),
Value = 1
});
animation.KeyFrames.Add(
new SplineDoubleKeyFrame()
new SplineDoubleKeyFrame
{
KeySpline = new KeySpline(0.5, 0, 1, 0.75),
KeyTime = KeyTime.FromTimeSpan(beginTime + duration),
Expand All @@ -234,12 +238,8 @@ private static Storyboard GetFadeOutStoryboard(TimeSpan beginTime, TimeSpan dura
/// <param name="e"> The e. </param>
private void OnFadeInCompleted(object sender, EventArgs e)
{
EventHandler eventHandler = this.FadeInCompleted;

if (eventHandler != null)
{
eventHandler(sender, e);
}
EventHandler eventHandler = FadeInCompleted;
eventHandler?.Invoke(sender, e);
}

/// <summary>
Expand All @@ -249,12 +249,8 @@ private void OnFadeInCompleted(object sender, EventArgs e)
/// <param name="e"> The e. </param>
private void OnFadeOutCompleted(object sender, EventArgs e)
{
EventHandler eventHandler = this.FadeOutCompleted;

if (eventHandler != null)
{
eventHandler(sender, e);
}
EventHandler eventHandler = FadeOutCompleted;
eventHandler?.Invoke(sender, e);
}

/// <summary>
Expand All @@ -264,11 +260,11 @@ private void OnFadeOutCompleted(object sender, EventArgs e)
/// <param name="e"> The e. </param>
private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (this.IsAnimatingOnIsVisibleChanged)
if (IsAnimatingOnIsVisibleChanged)
{
if (this.AssociatedObject.Visibility == Visibility.Visible)
if (AssociatedObject.Visibility == Visibility.Visible)
{
this.FadeIn();
FadeIn();
}

// this.FadeOut();
Expand All @@ -282,9 +278,9 @@ private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArg
/// <param name="e"> The e. </param>
private void OnLoaded(object sender, RoutedEventArgs e)
{
if (this.IsAnimatingOnLoaded)
if (IsAnimatingOnLoaded)
{
this.FadeIn();
FadeIn();
}
}

Expand Down
Loading