6 changed files with 68 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 RectTypeConverter : TypeConverter |
||||
|
{ |
||||
|
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) |
||||
|
{ |
||||
|
return sourceType == typeof(string); |
||||
|
} |
||||
|
|
||||
|
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) |
||||
|
{ |
||||
|
return Rect.Parse((string)value, culture); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using System.Globalization; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Avalonia.Visuals.UnitTests.Media |
||||
|
{ |
||||
|
public class RectTests |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void Parse_Parses() |
||||
|
{ |
||||
|
var rect = Rect.Parse("1,2 3,-4", CultureInfo.CurrentCulture); |
||||
|
var expected = new Rect(1, 2, 3, -4); |
||||
|
Assert.Equal(expected, rect); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue