Browse Source

Added simple property transition animation.

Animation's a bit choppy though!
pull/16/head
Steven Kirk 12 years ago
parent
commit
fc4d5ce32a
  1. 48
      Perspex.Animation/Animatable.cs
  2. 55
      Perspex.Animation/Animate.cs
  3. 28
      Perspex.Animation/AnimationExtensions.cs
  4. 18
      Perspex.Animation/IEasing.cs
  5. 23
      Perspex.Animation/LinearDoubleEasing.cs
  6. 27
      Perspex.Animation/LinearEasing.cs
  7. 99
      Perspex.Animation/Perspex.Animation.csproj
  8. 30
      Perspex.Animation/Properties/AssemblyInfo.cs
  9. 19
      Perspex.Animation/PropertyTransition.cs
  10. 12
      Perspex.Animation/PropertyTransitions.cs
  11. 8
      Perspex.Animation/packages.config
  12. 42
      Perspex.Base/PerspexObject.cs
  13. 9
      Perspex.Base/PerspexPropertyChangedEventArgs.cs
  14. 4
      Perspex.Controls.UnitTests/Perspex.Controls.UnitTests.csproj
  15. 5
      Perspex.Controls/Control.cs
  16. 4
      Perspex.Controls/Perspex.Controls.csproj
  17. 4
      Perspex.Diagnostics/Perspex.Diagnostics.csproj
  18. 4
      Perspex.Layout.UnitTests/Perspex.Layout.UnitTests.csproj
  19. 4
      Perspex.Themes.Default/Perspex.Themes.Default.csproj
  20. 6
      Perspex.sln
  21. 55
      TestApplication/Program.cs
  22. 4
      TestApplication/TestApplication.csproj
  23. 4
      Windows/Perspex.Direct2D1.RenderTests/Perspex.Direct2D1.RenderTests.csproj
  24. 4
      Windows/Perspex.Win32/Perspex.Win32.csproj

48
Perspex.Animation/Animatable.cs

@ -0,0 +1,48 @@
// -----------------------------------------------------------------------
// <copyright file="Animatable.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Animation
{
using System.Linq;
using System.Reactive.Linq;
using Perspex.Input;
public class Animatable : InputElement
{
private PropertyTransitions propertyTransitions;
public PropertyTransitions PropertyTransitions
{
get
{
if (this.propertyTransitions == null)
{
this.propertyTransitions = new PropertyTransitions();
}
return this.propertyTransitions;
}
set
{
this.propertyTransitions = value;
}
}
protected override void OnPropertyChanged(PerspexPropertyChangedEventArgs e)
{
if (e.Priority != BindingPriority.Animation && this.propertyTransitions != null)
{
var match = this.propertyTransitions.FirstOrDefault(x => x.Property == e.Property);
if (match != null)
{
Animate.Property(this, e.Property, e.OldValue, e.NewValue, match.Easing, match.Duration);
}
}
}
}
}

55
Perspex.Animation/Animate.cs

@ -0,0 +1,55 @@
// -----------------------------------------------------------------------
// <copyright file="Animate.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Animation
{
using System;
using System.Linq;
using System.Reactive.Linq;
using Perspex.Input;
using Perspex.Threading;
public static class Animate
{
private const int FramesPerSecond = 30;
private static readonly TimeSpan Tick = TimeSpan.FromSeconds(1.0 / FramesPerSecond);
public static IDisposable Property(
PerspexObject target,
PerspexProperty property,
object start,
object finish,
IEasing easing,
TimeSpan duration,
double repeats = 1)
{
var startTime = Environment.TickCount;
var runningTime = (double)duration.TotalMilliseconds;
var endTime = Environment.TickCount + (runningTime * repeats);
var o = Observable.Interval(Tick, PerspexScheduler.Instance)
.Select(_ => Environment.TickCount)
.TakeWhile(tick => tick < endTime)
.Select(tick => easing.Ease((tick - startTime) / runningTime, start, finish))
.StartWith(start)
.Concat(Observable.Return(finish));
return target.Bind(property, o, BindingPriority.Animation);
}
public static IDisposable Property<T>(
PerspexObject target,
PerspexProperty<T> property,
T start,
T finish,
IEasing easing,
TimeSpan duration)
{
return Property(target, (PerspexProperty)property, start, finish, easing, duration);
}
}
}

28
Perspex.Animation/AnimationExtensions.cs

@ -0,0 +1,28 @@
// -----------------------------------------------------------------------
// <copyright file="PropertyTransition.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Animation
{
using System;
public static class AnimationExtensions
{
public static PropertyTransition Transition<T>(this PerspexProperty<T> property, int milliseconds)
{
return Transition(property, TimeSpan.FromMilliseconds(milliseconds));
}
public static PropertyTransition Transition<T>(this PerspexProperty<T> property, TimeSpan duration)
{
return new PropertyTransition
{
Property = property,
Duration = duration,
Easing = LinearEasing.For<T>(),
};
}
}
}

18
Perspex.Animation/IEasing.cs

@ -0,0 +1,18 @@
// -----------------------------------------------------------------------
// <copyright file="PropertyTransition.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Animation
{
public interface IEasing
{
object Ease(double progress, object start, object finish);
}
public interface IEasing<T> : IEasing
{
T Ease(double progress, T start, T finish);
}
}

23
Perspex.Animation/LinearDoubleEasing.cs

@ -0,0 +1,23 @@
// -----------------------------------------------------------------------
// <copyright file="PropertyTransition.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Animation
{
using System;
public class LinearDoubleEasing : IEasing<double>
{
public double Ease(double progress, double start, double finish)
{
return ((finish - start) * progress) + start;
}
public object Ease(double progress, object start, object finish)
{
return this.Ease(progress, (double)start, (double)finish);
}
}
}

27
Perspex.Animation/LinearEasing.cs

@ -0,0 +1,27 @@
// -----------------------------------------------------------------------
// <copyright file="PropertyTransition.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Animation
{
using System;
public static class LinearEasing
{
public static LinearDoubleEasing For<T>()
{
if (typeof(T) == typeof(double))
{
return new LinearDoubleEasing();
}
else
{
throw new NotSupportedException(string.Format(
"Don't know how to create a LinearEasing for type '{0}'.",
typeof(T).FullName));
}
}
}
}

99
Perspex.Animation/Perspex.Animation.csproj

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D211E587-D8BC-45B9-95A4-F297C8FA5200}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Perspex.Animation</RootNamespace>
<AssemblyName>Perspex.Animation</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<ProjectReference Include="..\Perspex.Base\Perspex.Base.csproj">
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project>
<Name>Perspex.Base</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Input\Perspex.Input.csproj">
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project>
<Name>Perspex.Input</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Interactivity\Perspex.Interactivity.csproj">
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project>
<Name>Perspex.Interactivity</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Layout\Perspex.Layout.csproj">
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project>
<Name>Perspex.Layout</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.SceneGraph\Perspex.SceneGraph.csproj">
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project>
<Name>Perspex.SceneGraph</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Styling\Perspex.Styling.csproj">
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project>
<Name>Perspex.Styling</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Animate.cs" />
<Compile Include="Animatable.cs" />
<Compile Include="AnimationExtensions.cs" />
<Compile Include="LinearEasing.cs" />
<Compile Include="LinearDoubleEasing.cs" />
<Compile Include="IEasing.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PropertyTransitions.cs" />
<Compile Include="PropertyTransition.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Reactive.Core">
<HintPath>..\packages\Rx-Core.2.2.5\lib\portable-windows8+net45+wp8\System.Reactive.Core.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Interfaces">
<HintPath>..\packages\Rx-Interfaces.2.2.5\lib\portable-windows8+net45+wp8\System.Reactive.Interfaces.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Linq">
<HintPath>..\packages\Rx-Linq.2.2.5\lib\portable-windows8+net45+wp8\System.Reactive.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.PlatformServices">
<HintPath>..\packages\Rx-PlatformServices.2.2.5\lib\portable-windows8+net45+wp8\System.Reactive.PlatformServices.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

30
Perspex.Animation/Properties/AssemblyInfo.cs

@ -0,0 +1,30 @@
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Perspex.Animation")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Perspex.Animation")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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")]

19
Perspex.Animation/PropertyTransition.cs

@ -0,0 +1,19 @@
// -----------------------------------------------------------------------
// <copyright file="PropertyTransition.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Animation
{
using System;
public class PropertyTransition
{
public PerspexProperty Property { get; set; }
public TimeSpan Duration { get; set; }
public IEasing Easing { get; set; }
}
}

12
Perspex.Animation/PropertyTransitions.cs

@ -0,0 +1,12 @@
// -----------------------------------------------------------------------
// <copyright file="PropertyTransitions.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Animation
{
public class PropertyTransitions : PerspexList<PropertyTransition>
{
}
}

8
Perspex.Animation/packages.config

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Rx-Core" version="2.2.5" targetFramework="portable-net45+win" />
<package id="Rx-Interfaces" version="2.2.5" targetFramework="portable-net45+win" />
<package id="Rx-Linq" version="2.2.5" targetFramework="portable-net45+win" />
<package id="Rx-Main" version="2.2.5" targetFramework="portable-net45+win" />
<package id="Rx-PlatformServices" version="2.2.5" targetFramework="portable-net45+win" />
</packages>

42
Perspex.Base/PerspexObject.cs

@ -20,6 +20,11 @@ namespace Perspex
/// </summary>
public enum BindingPriority
{
/// <summary>
/// A value that comes from an animation.
/// </summary>
Animation = -1,
/// <summary>
/// A local value.
/// </summary>
@ -89,11 +94,16 @@ namespace Perspex
{
foreach (var p in this.GetAllValues())
{
var priority = p.PriorityValue != null ?
(BindingPriority)p.PriorityValue.ValuePriority :
BindingPriority.LocalValue;
var e = new PerspexPropertyChangedEventArgs(
this,
p.Property,
PerspexProperty.UnsetValue,
p.CurrentValue);
p.CurrentValue,
priority);
p.Property.NotifyInitialized(e);
}
@ -149,7 +159,7 @@ namespace Perspex
if (!object.Equals(i.Value, newValue))
{
this.RaisePropertyChanged(i.Property, i.Value, newValue);
this.RaisePropertyChanged(i.Property, i.Value, newValue, BindingPriority.LocalValue);
}
}
@ -664,6 +674,14 @@ namespace Perspex
});
}
/// <summary>
/// Called when a perspex property changes on the object.
/// </summary>
/// <param name="e">The event arguments.</param>
protected virtual void OnPropertyChanged(PerspexPropertyChangedEventArgs e)
{
}
/// <summary>
/// Creates a <see cref="PriorityValue"/> for a <see cref="PerspexProperty"/>.
/// </summary>
@ -691,7 +709,7 @@ namespace Perspex
if (!object.Equals(oldValue, newValue))
{
this.RaisePropertyChanged(property, oldValue, newValue);
this.RaisePropertyChanged(property, oldValue, newValue, (BindingPriority)result.ValuePriority);
this.Log().Debug(
"Value of {0}.{1} (#{2:x8}) changed from {3} to {4}",
@ -737,7 +755,7 @@ namespace Perspex
if (e.Property.Inherits && !this.IsSet(e.Property))
{
this.RaisePropertyChanged(e.Property, e.OldValue, e.NewValue);
this.RaisePropertyChanged(e.Property, e.OldValue, e.NewValue, BindingPriority.LocalValue);
}
}
@ -747,11 +765,23 @@ namespace Perspex
/// <param name="property">The property that has changed.</param>
/// <param name="oldValue">The old property value.</param>
/// <param name="newValue">The new property value.</param>
private void RaisePropertyChanged(PerspexProperty property, object oldValue, object newValue)
/// <param name="priority">The priority of the binding that produced the value.</param>
private void RaisePropertyChanged(
PerspexProperty property,
object oldValue,
object newValue,
BindingPriority priority)
{
Contract.Requires<NullReferenceException>(property != null);
PerspexPropertyChangedEventArgs e = new PerspexPropertyChangedEventArgs(this, property, oldValue, newValue);
PerspexPropertyChangedEventArgs e = new PerspexPropertyChangedEventArgs(
this,
property,
oldValue,
newValue,
priority);
this.OnPropertyChanged(e);
property.NotifyChanged(e);
if (this.PropertyChanged != null)

9
Perspex.Base/PerspexPropertyChangedEventArgs.cs

@ -15,12 +15,14 @@ namespace Perspex
PerspexObject sender,
PerspexProperty property,
object oldValue,
object newValue)
object newValue,
BindingPriority priority)
{
this.Sender = sender;
this.Property = property;
this.OldValue = oldValue;
this.NewValue = newValue;
this.Priority = priority;
}
/// <summary>
@ -43,5 +45,10 @@ namespace Perspex
/// Gets the new value of the property.
/// </summary>
public object NewValue { get; private set; }
/// <summary>
/// Gets the priority of the binding that produced the value.
/// </summary>
public BindingPriority Priority { get; private set; }
}
}

4
Perspex.Controls.UnitTests/Perspex.Controls.UnitTests.csproj

@ -72,6 +72,10 @@
<Compile Include="TestRoot.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Perspex.Animation\Perspex.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Perspex.Animation</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Base\Perspex.Base.csproj">
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project>
<Name>Perspex.Base</Name>

5
Perspex.Controls/Control.cs

@ -7,9 +7,8 @@
namespace Perspex.Controls
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using Perspex.Animation;
using Perspex.Input;
using Perspex.Interactivity;
using Perspex.Media;
@ -17,7 +16,7 @@ namespace Perspex.Controls
using Perspex.Styling;
using Splat;
public class Control : InputElement, IStyleable, IStyleHost
public class Control : Animatable, IStyleable, IStyleHost
{
public static readonly PerspexProperty<Brush> BackgroundProperty =
PerspexProperty.Register<Control, Brush>("Background");

4
Perspex.Controls/Perspex.Controls.csproj

@ -124,6 +124,10 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Perspex.Animation\Perspex.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Perspex.Animation</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Base\Perspex.Base.csproj">
<Project>{B09B78D8-9B26-48B0-9149-D64A2F120F3F}</Project>
<Name>Perspex.Base</Name>

4
Perspex.Diagnostics/Perspex.Diagnostics.csproj

@ -36,6 +36,10 @@
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<ProjectReference Include="..\Perspex.Animation\Perspex.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Perspex.Animation</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Base\Perspex.Base.csproj">
<Project>{B09B78D8-9B26-48B0-9149-D64A2F120F3F}</Project>
<Name>Perspex.Base</Name>

4
Perspex.Layout.UnitTests/Perspex.Layout.UnitTests.csproj

@ -67,6 +67,10 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Perspex.Animation\Perspex.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Perspex.Animation</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Base\Perspex.Base.csproj">
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project>
<Name>Perspex.Base</Name>

4
Perspex.Themes.Default/Perspex.Themes.Default.csproj

@ -36,6 +36,10 @@
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<ProjectReference Include="..\Perspex.Animation\Perspex.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Perspex.Animation</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Base\Perspex.Base.csproj">
<Project>{B09B78D8-9B26-48B0-9149-D64A2F120F3F}</Project>
<Name>Perspex.Base</Name>

6
Perspex.sln

@ -57,6 +57,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NGenerics", "NGenerics\NGen
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Layout.UnitTests", "Perspex.Layout.UnitTests\Perspex.Layout.UnitTests.csproj", "{DB070A10-BF39-4752-8456-86E9D5928478}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Animation", "Perspex.Animation\Perspex.Animation.csproj", "{D211E587-D8BC-45B9-95A4-F297C8FA5200}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -154,6 +156,10 @@ Global
{DB070A10-BF39-4752-8456-86E9D5928478}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB070A10-BF39-4752-8456-86E9D5928478}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB070A10-BF39-4752-8456-86E9D5928478}.Release|Any CPU.Build.0 = Release|Any CPU
{D211E587-D8BC-45B9-95A4-F297C8FA5200}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D211E587-D8BC-45B9-95A4-F297C8FA5200}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D211E587-D8BC-45B9-95A4-F297C8FA5200}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D211E587-D8BC-45B9-95A4-F297C8FA5200}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

55
TestApplication/Program.cs

@ -1,6 +1,7 @@
using System;
using System.Reactive.Linq;
using Perspex;
using Perspex.Animation;
using Perspex.Controls;
using Perspex.Controls.Primitives;
using Perspex.Controls.Shapes;
@ -8,6 +9,7 @@ using Perspex.Diagnostics;
using Perspex.Layout;
using Perspex.Media;
using Perspex.Media.Imaging;
using Perspex.Styling;
using Perspex.Threading;
#if PERSPEX_GTK
using Perspex.Gtk;
@ -438,6 +440,8 @@ namespace TestApplication
private static TabItem AnimationsTab()
{
Rectangle rect1;
Rectangle rect2;
Button button1;
var result = new TabItem
{
@ -447,6 +451,12 @@ namespace TestApplication
ColumnDefinitions = new ColumnDefinitions
{
new ColumnDefinition(1, GridUnitType.Star),
new ColumnDefinition(1, GridUnitType.Star),
},
RowDefinitions = new RowDefinitions
{
new RowDefinition(1, GridUnitType.Star),
new RowDefinition(GridLength.Auto),
},
Children = new Controls
{
@ -459,15 +469,52 @@ namespace TestApplication
Fill = Brushes.Crimson,
RenderTransform = new RotateTransform(),
}),
(rect2 = new Rectangle
{
Width = 100,
Height = 100,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Fill = Brushes.Coral,
RenderTransform = new RotateTransform(),
PropertyTransitions = new PropertyTransitions
{
Rectangle.WidthProperty.Transition(1000),
Rectangle.HeightProperty.Transition(1000),
},
[Grid.ColumnProperty] = 1,
}),
(button1 = new Button
{
HorizontalAlignment = HorizontalAlignment.Center,
Content = "Animate",
[Grid.ColumnProperty] = 1,
[Grid.RowProperty] = 1,
}),
},
},
};
Observable.Interval(TimeSpan.FromMilliseconds(10), PerspexScheduler.Instance)
.Subscribe(x =>
button1.Click += (s, e) =>
{
if (rect2.Width == 100)
{
rect2.Width = rect2.Height = 400;
}
else
{
((RotateTransform)rect1.RenderTransform).Angle = x;
});
rect2.Width = rect2.Height = 100;
}
};
Animate.Property(
(PerspexObject)rect1.RenderTransform,
RotateTransform.AngleProperty,
0.0,
360.0,
new LinearDoubleEasing(),
TimeSpan.FromSeconds(4),
double.PositiveInfinity);
return result;
}

4
TestApplication/TestApplication.csproj

@ -76,6 +76,10 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Perspex.Animation\Perspex.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Perspex.Animation</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Application\Perspex.Application.csproj">
<Project>{799A7BB5-3C2C-48B6-85A7-406A12C420DA}</Project>
<Name>Perspex.Application</Name>

4
Windows/Perspex.Direct2D1.RenderTests/Perspex.Direct2D1.RenderTests.csproj

@ -68,6 +68,10 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Perspex.Animation\Perspex.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Perspex.Animation</Name>
</ProjectReference>
<ProjectReference Include="..\..\Perspex.Base\Perspex.Base.csproj">
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project>
<Name>Perspex.Base</Name>

4
Windows/Perspex.Win32/Perspex.Win32.csproj

@ -69,6 +69,10 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Perspex.Animation\Perspex.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Perspex.Animation</Name>
</ProjectReference>
<ProjectReference Include="..\..\Perspex.Base\Perspex.Base.csproj">
<Project>{B09B78D8-9B26-48B0-9149-D64A2F120F3F}</Project>
<Name>Perspex.Base</Name>

Loading…
Cancel
Save