6 changed files with 71 additions and 1 deletions
@ -0,0 +1,23 @@ |
|||
// Copyright (c) The Avalonia 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; |
|||
|
|||
namespace Avalonia.Markup.Xaml.Converters |
|||
{ |
|||
using System.ComponentModel; |
|||
|
|||
public class MatrixTypeConverter : TypeConverter |
|||
{ |
|||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) |
|||
{ |
|||
return sourceType == typeof(string); |
|||
} |
|||
|
|||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) |
|||
{ |
|||
return Matrix.Parse((string)value, culture); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System.Globalization; |
|||
using Xunit; |
|||
|
|||
namespace Avalonia.Visuals.UnitTests.Media |
|||
{ |
|||
public class MatrixTests |
|||
{ |
|||
[Fact] |
|||
public void Parse_Parses() |
|||
{ |
|||
var matrix = Matrix.Parse("1,2,3,-4,5 6", CultureInfo.CurrentCulture); |
|||
var expected = new Matrix(1, 2, 3, -4, 5, 6); |
|||
Assert.Equal(expected, matrix); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue