From fe9ed13cff3041f8d2e1c5988cd47fcb0ec664bd Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 27 May 2015 16:45:07 +0200 Subject: [PATCH] Install StyleCopAnalysers. And fix all warnings for the Perspex.Animation project. --- Perspex.Animation/Animatable.cs | 17 ++++++ Perspex.Animation/Animate.cs | 19 +++--- Perspex.Animation/Animation.cs | 48 +++++++-------- Perspex.Animation/AnimationExtensions.cs | 34 ++++++++--- Perspex.Animation/Animation`1.cs | 59 +++++++++++++++++++ Perspex.Animation/IEasing.cs | 20 +++++-- Perspex.Animation/IEasing`1.cs | 27 +++++++++ Perspex.Animation/LinearDoubleEasing.cs | 29 +++++++-- Perspex.Animation/LinearEasing.cs | 16 ++++- Perspex.Animation/Perspex.Animation.csproj | 5 ++ Perspex.Animation/PropertyTransition.cs | 40 ++++++++++++- Perspex.Animation/PropertyTransitions.cs | 5 +- Perspex.Animation/packages.config | 11 ++-- .../Perspex.Application.csproj | 3 + Perspex.Application/packages.config | 1 + Perspex.Base/Perspex.Base.csproj | 3 + Perspex.Base/packages.config | 1 + Perspex.Controls/Perspex.Controls.csproj | 3 + Perspex.Controls/packages.config | 1 + .../Perspex.Diagnostics.csproj | 3 + Perspex.Diagnostics/packages.config | 1 + Perspex.Input/Perspex.Input.csproj | 3 + Perspex.Input/packages.config | 1 + .../Perspex.Interactive.UnitTests.csproj | 3 + Perspex.Interactive.UnitTests/packages.config | 1 + .../Perspex.Interactivity.csproj | 3 + Perspex.Interactivity/packages.config | 1 + Perspex.Layout/Perspex.Layout.csproj | 3 + Perspex.Layout/packages.config | 1 + Perspex.SceneGraph/Animation/PageSlide.cs | 4 +- Perspex.SceneGraph/Perspex.SceneGraph.csproj | 3 + Perspex.SceneGraph/packages.config | 1 + Perspex.Styling/Perspex.Styling.csproj | 4 ++ Perspex.Styling/packages.config | 4 ++ .../Perspex.Themes.Default.csproj | 3 + Perspex.Themes.Default/packages.config | 1 + .../Perspex.Base.UnitTests.csproj | 3 + Tests/Perspex.Base.UnitTests/packages.config | 1 + .../Perspex.Controls.UnitTests.csproj | 3 + .../packages.config | 1 + .../Perspex.Direct2D1.UnitTests.csproj | 3 + .../packages.config | 1 + .../Perspex.Input.UnitTests.csproj | 3 + Tests/Perspex.Input.UnitTests/packages.config | 1 + .../Perspex.Layout.UnitTests.csproj | 3 + .../Perspex.Layout.UnitTests/packages.config | 1 + .../Perspex.Direct2D1.RenderTests.csproj | 3 + Tests/Perspex.RenderTests/packages.config | 1 + .../Perspex.SceneGraph.UnitTests.csproj | 3 + .../packages.config | 1 + .../Perspex.Styling.UnitTests.csproj | 3 + .../Perspex.Styling.UnitTests/packages.config | 1 + .../Perspex.Direct2D1.csproj | 3 + Windows/Perspex.Direct2D1/packages.config | 1 + Windows/Perspex.Win32/Perspex.Win32.csproj | 3 + Windows/Perspex.Win32/packages.config | 1 + 56 files changed, 358 insertions(+), 64 deletions(-) create mode 100644 Perspex.Animation/Animation`1.cs create mode 100644 Perspex.Animation/IEasing`1.cs create mode 100644 Perspex.Styling/packages.config diff --git a/Perspex.Animation/Animatable.cs b/Perspex.Animation/Animatable.cs index 26cd832020..ae5cd56604 100644 --- a/Perspex.Animation/Animatable.cs +++ b/Perspex.Animation/Animatable.cs @@ -9,10 +9,22 @@ namespace Perspex.Animation using System.Linq; using System.Reactive.Linq; + /// + /// Base class for control which can have property transitions. + /// public class Animatable : PerspexObject { + /// + /// The property transitions for the control. + /// private PropertyTransitions propertyTransitions; + /// + /// Gets or sets the property transitions for the control. + /// + /// + /// The property transitions for the control. + /// public PropertyTransitions PropertyTransitions { get @@ -31,6 +43,11 @@ namespace Perspex.Animation } } + /// + /// Reacts to a change in a value in order to animate the + /// change if a is set for the property.. + /// + /// The event args. protected override void OnPropertyChanged(PerspexPropertyChangedEventArgs e) { if (e.Priority != BindingPriority.Animation && this.propertyTransitions != null) diff --git a/Perspex.Animation/Animate.cs b/Perspex.Animation/Animate.cs index ecf8f4477f..98daa45e46 100644 --- a/Perspex.Animation/Animate.cs +++ b/Perspex.Animation/Animate.cs @@ -28,7 +28,7 @@ namespace Perspex.Animation private static readonly TimeSpan Tick = TimeSpan.FromSeconds(1.0 / FramesPerSecond); /// - /// Initializes the static class. + /// Initializes static members of the class. /// static Animate() { @@ -43,6 +43,9 @@ namespace Perspex.Animation /// /// The stopwatch used to track time. /// + /// + /// The stopwatch used to track time. + /// public static Stopwatch Stopwatch { get; @@ -53,10 +56,13 @@ namespace Perspex.Animation /// Gets the animation timer. /// /// - /// The animation timer ticks times per second. The - /// parameter passed to a subsciber is the time span since the animation system was + /// The animation timer ticks times per second. The + /// parameter passed to a subsciber is the time span since the animation system was /// initialized. /// + /// + /// The animation timer. + /// public static IObservable Timer { get; @@ -78,7 +84,7 @@ namespace Perspex.Animation public static IObservable GetTimer(TimeSpan duration) { var startTime = Stopwatch.Elapsed.Ticks; - var endTime = (startTime + duration.Ticks); + var endTime = startTime + duration.Ticks; return Timer .TakeWhile(x => x.Ticks < endTime) .Select(x => (x.Ticks - startTime) / (double)duration.Ticks) @@ -89,7 +95,6 @@ namespace Perspex.Animation /// /// Animates a . /// - /// The property type. /// The target object. /// The target property. /// The value of the property at the start of the animation. @@ -122,8 +127,8 @@ namespace Perspex.Animation /// An that can be used to track or stop the animation. public static Animation Property( PerspexObject target, - PerspexProperty property, - T start, + PerspexProperty property, + T start, T finish, IEasing easing, TimeSpan duration) diff --git a/Perspex.Animation/Animation.cs b/Perspex.Animation/Animation.cs index 2f4d8ffdc3..1afd8c02b2 100644 --- a/Perspex.Animation/Animation.cs +++ b/Perspex.Animation/Animation.cs @@ -13,50 +13,46 @@ namespace Perspex.Animation /// public class Animation : IObservable, IDisposable { + /// + /// The animation being tracked. + /// private IObservable inner; + /// + /// The disposable used to cancel the animation. + /// private IDisposable subscription; + /// + /// Initializes a new instance of the class. + /// + /// The animation observable being tracked. + /// A disposable used to cancel the animation. public Animation(IObservable inner, IDisposable subscription) { this.inner = inner; this.subscription = subscription; } + /// + /// Cancels the animation. + /// public void Dispose() { this.subscription.Dispose(); } + /// + /// Notifies the provider that an observer is to receive notifications. + /// + /// The observer. + /// + /// A reference to an interface that allows observers to stop receiving notifications + /// before the provider has finished sending them. + /// public IDisposable Subscribe(IObserver observer) { return this.inner.Subscribe(observer); } } - - /// - /// Tracks the progress of an animation. - /// - public class Animation : IObservable, IDisposable - { - private IObservable inner; - - private IDisposable subscription; - - public Animation(IObservable inner, IDisposable subscription) - { - this.inner = inner; - this.subscription = subscription; - } - - public void Dispose() - { - this.subscription.Dispose(); - } - - public IDisposable Subscribe(IObserver observer) - { - return this.inner.Subscribe(observer); - } - } } diff --git a/Perspex.Animation/AnimationExtensions.cs b/Perspex.Animation/AnimationExtensions.cs index affed391f9..f6b8ede055 100644 --- a/Perspex.Animation/AnimationExtensions.cs +++ b/Perspex.Animation/AnimationExtensions.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- @@ -8,21 +8,41 @@ namespace Perspex.Animation { using System; + /// + /// Defines animation extension methods. + /// public static class AnimationExtensions { + /// + /// Returns a new for the specified + /// using linear easing. + /// + /// The type of the . + /// The property to animate. + /// The animation duration in milliseconds. + /// + /// A that can be added to the + /// collection. + /// public static PropertyTransition Transition(this PerspexProperty property, int milliseconds) { return Transition(property, TimeSpan.FromMilliseconds(milliseconds)); } + /// + /// Returns a new for the specified + /// using linear easing. + /// + /// The type of the . + /// The property to animate. + /// The animation duration. + /// + /// A that can be added to the + /// collection. + /// public static PropertyTransition Transition(this PerspexProperty property, TimeSpan duration) { - return new PropertyTransition - { - Property = property, - Duration = duration, - Easing = LinearEasing.For(), - }; + return new PropertyTransition(property, duration, LinearEasing.For()); } } } diff --git a/Perspex.Animation/Animation`1.cs b/Perspex.Animation/Animation`1.cs new file mode 100644 index 0000000000..d986fd7436 --- /dev/null +++ b/Perspex.Animation/Animation`1.cs @@ -0,0 +1,59 @@ +// ----------------------------------------------------------------------- +// +// Copyright 2015 MIT Licence. See licence.md for more information. +// +// ----------------------------------------------------------------------- + +namespace Perspex.Animation +{ + using System; + + /// + /// Tracks the progress of an animation. + /// + /// The type of the value being animated./ + public class Animation : IObservable, IDisposable + { + /// + /// The animation being tracked. + /// + private IObservable inner; + + /// + /// The disposable used to cancel the animation. + /// + private IDisposable subscription; + + /// + /// Initializes a new instance of the class. + /// + /// The animation observable being tracked. + /// A disposable used to cancel the animation. + public Animation(IObservable inner, IDisposable subscription) + { + this.inner = inner; + this.subscription = subscription; + } + + /// + /// Cancels the animation. + /// + public void Dispose() + { + this.subscription.Dispose(); + } + + /// + /// Notifies the provider that an observer is to receive notifications. + /// + /// The observer. + /// + /// A reference to an interface that allows observers to stop receiving notifications + /// before the provider has finished sending them. + /// + public IDisposable Subscribe(IObserver observer) + { + return this.inner.Subscribe(observer); + } + } +} diff --git a/Perspex.Animation/IEasing.cs b/Perspex.Animation/IEasing.cs index a926cd7e87..f9dc0f85d5 100644 --- a/Perspex.Animation/IEasing.cs +++ b/Perspex.Animation/IEasing.cs @@ -1,18 +1,26 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- namespace Perspex.Animation { + /// + /// Defines the interface for easing functions. + /// public interface IEasing { + /// + /// Returns the value of the transition for the specified progress. + /// + /// The progress of the transition, from 0 to 1. + /// The start value of the transition. + /// The end value of the transition. + /// + /// A value between and as determined + /// by . + /// object Ease(double progress, object start, object finish); } - - public interface IEasing : IEasing - { - T Ease(double progress, T start, T finish); - } } diff --git a/Perspex.Animation/IEasing`1.cs b/Perspex.Animation/IEasing`1.cs new file mode 100644 index 0000000000..98d2c81743 --- /dev/null +++ b/Perspex.Animation/IEasing`1.cs @@ -0,0 +1,27 @@ +// ----------------------------------------------------------------------- +// +// Copyright 2014 MIT Licence. See licence.md for more information. +// +// ----------------------------------------------------------------------- + +namespace Perspex.Animation +{ + /// + /// Defines the interface for easing functions. + /// + /// The type of the property being transitioned. + public interface IEasing : IEasing + { + /// + /// Returns the value of the transition for the specified progress. + /// + /// The progress of the transition, from 0 to 1. + /// The start value of the transition. + /// The end value of the transition. + /// + /// A value between and as determined + /// by . + /// + T Ease(double progress, T start, T finish); + } +} diff --git a/Perspex.Animation/LinearDoubleEasing.cs b/Perspex.Animation/LinearDoubleEasing.cs index b3c55afbd0..ee1838ab73 100644 --- a/Perspex.Animation/LinearDoubleEasing.cs +++ b/Perspex.Animation/LinearDoubleEasing.cs @@ -1,21 +1,42 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- namespace Perspex.Animation { - using System; - + /// + /// Linearly eases a double value. + /// public class LinearDoubleEasing : IEasing { + /// + /// Returns the value of the transition for the specified progress. + /// + /// The progress of the transition, from 0 to 1. + /// The start value of the transition. + /// The end value of the transition. + /// + /// A value between and as determined + /// by . + /// public double Ease(double progress, double start, double finish) { return ((finish - start) * progress) + start; } - public object Ease(double progress, object start, object finish) + /// + /// Returns the value of the transition for the specified progress. + /// + /// The progress of the transition, from 0 to 1. + /// The start value of the transition. + /// The end value of the transition. + /// + /// A value between and as determined + /// by . + /// + object IEasing.Ease(double progress, object start, object finish) { return this.Ease(progress, (double)start, (double)finish); } diff --git a/Perspex.Animation/LinearEasing.cs b/Perspex.Animation/LinearEasing.cs index bddb5efc4c..0a20429a75 100644 --- a/Perspex.Animation/LinearEasing.cs +++ b/Perspex.Animation/LinearEasing.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- @@ -8,9 +8,21 @@ namespace Perspex.Animation { using System; + /// + /// Returns a linear for the specified type. + /// + /// + /// Unfortunately this class is needed as there's no way to create a true generic easing + /// function at compile time, as mathematical operators don't have an interface. + /// public static class LinearEasing { - public static LinearDoubleEasing For() + /// + /// A linear easing function for the specified type. + /// + /// The type. + /// An easing function. + public static IEasing For() { if (typeof(T) == typeof(double)) { diff --git a/Perspex.Animation/Perspex.Animation.csproj b/Perspex.Animation/Perspex.Animation.csproj index d00dc42aa3..ea2c28fa7c 100644 --- a/Perspex.Animation/Perspex.Animation.csproj +++ b/Perspex.Animation/Perspex.Animation.csproj @@ -41,10 +41,12 @@ + + @@ -69,6 +71,9 @@ + + +