mirror of
https://github.com/SourMesen/Mesen2.git
synced 2025-04-02 10:21:44 -04:00
27 lines
661 B
C#
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;
|
|
}
|
|
}
|
|
}
|