diff --git a/samples/XamlTestApplication/Views/MainWindow.paml b/samples/XamlTestApplication/Views/MainWindow.paml index 2c4525eb13..0f37faa54c 100644 --- a/samples/XamlTestApplication/Views/MainWindow.paml +++ b/samples/XamlTestApplication/Views/MainWindow.paml @@ -3,8 +3,11 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Perspex Test Application" Height="350" Width="525" SizeToContent="WidthAndHeight" > - - + + + + + diff --git a/src/Markup/Perspex.Markup.Xaml/Context/PerspexWiringContext.cs b/src/Markup/Perspex.Markup.Xaml/Context/PerspexWiringContext.cs index 4da18ba27f..b2ab8c06ae 100644 --- a/src/Markup/Perspex.Markup.Xaml/Context/PerspexWiringContext.cs +++ b/src/Markup/Perspex.Markup.Xaml/Context/PerspexWiringContext.cs @@ -1,6 +1,7 @@ // Copyright (c) The Perspex Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -86,6 +87,7 @@ namespace Perspex.Markup.Xaml.Context new TypeConverterRegistration(typeof(RowDefinitions), new RowDefinitionsTypeConverter()), new TypeConverterRegistration(typeof(Thickness), new ThicknessTypeConverter()), new TypeConverterRegistration(typeof(Selector), new SelectorTypeConverter()), + new TypeConverterRegistration(typeof(TimeSpan), new TimeSpanTypeConverter()), }; typeConverterProvider.AddAll(converters); diff --git a/src/Markup/Perspex.Markup.Xaml/Converters/TimeSpanTypeConverter.cs b/src/Markup/Perspex.Markup.Xaml/Converters/TimeSpanTypeConverter.cs new file mode 100644 index 0000000000..54920c7242 --- /dev/null +++ b/src/Markup/Perspex.Markup.Xaml/Converters/TimeSpanTypeConverter.cs @@ -0,0 +1,41 @@ +// Copyright (c) The Perspex Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using System; +using System.Globalization; +using OmniXaml.TypeConversion; +using Perspex.Media; + +namespace Perspex.Markup.Xaml.Converters +{ + public class TimeSpanTypeConverter : ITypeConverter + { + public bool CanConvertFrom(IXamlTypeConverterContext context, Type sourceType) + { + return sourceType == typeof(string); + } + + public bool CanConvertTo(IXamlTypeConverterContext context, Type destinationType) + { + return false; + } + + public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value) + { + var valueStr = (string)value; + if (!valueStr.Contains(":")) + { + // shorthand seconds format (ie. "0.25") + var secs = double.Parse(valueStr); + return TimeSpan.FromSeconds(secs); + } + + return TimeSpan.Parse(valueStr); + } + + public object ConvertTo(IXamlTypeConverterContext context, CultureInfo culture, object value, Type destinationType) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj b/src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj index 243e7b5e5a..2bce8946ac 100644 --- a/src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj +++ b/src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj @@ -48,6 +48,7 @@ + diff --git a/src/Perspex.SceneGraph/Animation/CrossFade.cs b/src/Perspex.SceneGraph/Animation/CrossFade.cs index d2dd1b800b..4f3486c06a 100644 --- a/src/Perspex.SceneGraph/Animation/CrossFade.cs +++ b/src/Perspex.SceneGraph/Animation/CrossFade.cs @@ -13,6 +13,13 @@ namespace Perspex.Animation /// public class CrossFade : IPageTransition { + /// + /// Initializes a new instance of the class. + /// + public CrossFade() + { + } + /// /// Initializes a new instance of the class. /// @@ -25,7 +32,7 @@ namespace Perspex.Animation /// /// Gets the duration of the animation. /// - public TimeSpan Duration { get; } + public TimeSpan Duration { get; set; } /// /// Starts the animation. diff --git a/src/Perspex.SceneGraph/Animation/PageSlide.cs b/src/Perspex.SceneGraph/Animation/PageSlide.cs index db6863db35..cf145286fc 100644 --- a/src/Perspex.SceneGraph/Animation/PageSlide.cs +++ b/src/Perspex.SceneGraph/Animation/PageSlide.cs @@ -14,6 +14,13 @@ namespace Perspex.Animation /// public class PageSlide : IPageTransition { + /// + /// Initializes a new instance of the class. + /// + public PageSlide() + { + } + /// /// Initializes a new instance of the class. /// @@ -26,7 +33,7 @@ namespace Perspex.Animation /// /// Gets the duration of the animation. /// - public TimeSpan Duration { get; } + public TimeSpan Duration { get; set; } /// /// Starts the animation.