forked from amkovkov/GranuSightSoftware2
comprehensive update
1) remove unused components: camera view (due it causes segmentation faults), compute resources and all related, illuminator controller (due in useless without camera view), image storage service, temperature and humidity service 2) database schema - reduce tables references, features storing in records themselves in compressed form, add records creation and editing date and time, add separator comment column 3) analysis - rework of pipeline and ui, now database storing only raw data and all display values calculated from it 4) lights service - add reconnection if disconnected 5) add width and height command line arguments 6) fix some typos and other issues
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using System.Globalization;
|
||||
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace GSS2.UI.Core.Converters;
|
||||
|
||||
public class LessThanOrEqualConverter : IValueConverter
|
||||
{
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is null && parameter is null)
|
||||
return true;
|
||||
|
||||
if (value is null || parameter is null)
|
||||
return false;
|
||||
|
||||
var valueType = value.GetType();
|
||||
var paramType = parameter.GetType();
|
||||
|
||||
if (valueType == paramType)
|
||||
{
|
||||
var lessThanOrEqual = valueType.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
|
||||
.FirstOrDefault(m => m.Name.EndsWith("op_LessThanOrEqual"));
|
||||
if (lessThanOrEqual is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return lessThanOrEqual.Invoke(null, [value, parameter]);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
if (parameter is string ps)
|
||||
return value switch
|
||||
{
|
||||
byte v => byte.TryParse(ps, out var p) && v <= p,
|
||||
short v => short.TryParse(ps, out var p) && v <= p,
|
||||
ushort v => ushort.TryParse(ps, out var p) && v <= p,
|
||||
int v => int.TryParse(ps, out var p) && v <= p,
|
||||
uint v => uint.TryParse(ps, out var p) && v <= p,
|
||||
long v => long.TryParse(ps, out var p) && v <= p,
|
||||
ulong v => ulong.TryParse(ps, out var p) && v <= p,
|
||||
float v => float.TryParse(ps, out var p) && v <= p,
|
||||
double v => double.TryParse(ps, out var p) && v <= p,
|
||||
decimal v => decimal.TryParse(ps, out var p) && v <= p,
|
||||
_ => false
|
||||
};
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user