Mesen2/UI/Debugger/Utilities/GridLengthConverter.cs
2023-01-25 16:03:56 -05:00

27 lines
661 B
C#

using Avalonia.Controls;
using Avalonia.Data.Converters;
using System;
namespace Mesen.Debugger.Utilities
{
public class GridLengthConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
{
if(value is double val && targetType == typeof(GridLength)) {
return new GridLength(val, GridUnitType.Pixel);
}
throw new Exception("unsupported");
}
public object ConvertBack(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
{
if(value is GridLength s) {
return s.Value;
}
return 0.0;
}
}
}