committed by
GitHub
12 changed files with 121 additions and 28 deletions
@ -1,7 +1,7 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="SkiaSharp" Version="2.88.1-preview.108" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.1-preview.108" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.1-preview.108" /> |
|||
<PackageReference Include="SkiaSharp" Version="2.88.1" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.1" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.1" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -0,0 +1,34 @@ |
|||
using System; |
|||
using System.Globalization; |
|||
using Avalonia; |
|||
using Avalonia.Data.Converters; |
|||
|
|||
namespace ControlCatalog.Converter; |
|||
|
|||
public class HexConverter : IValueConverter |
|||
{ |
|||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
|||
{ |
|||
var str = value?.ToString(); |
|||
if (str == null) |
|||
return AvaloniaProperty.UnsetValue; |
|||
if (int.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int x)) |
|||
return (decimal)x; |
|||
return AvaloniaProperty.UnsetValue; |
|||
|
|||
} |
|||
|
|||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
|||
{ |
|||
try |
|||
{ |
|||
if (value is decimal d) |
|||
return ((int)d).ToString("X8"); |
|||
return AvaloniaProperty.UnsetValue; |
|||
} |
|||
catch |
|||
{ |
|||
return AvaloniaProperty.UnsetValue; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue