2026-06-05 13:44:39 +09:00

72 lines
2.2 KiB
C#

/*
* Copyright (c) 2022 LG Electronics Inc.
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
*/
using Aurora;
using Aurora.View;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace AuroraUIComponent.UIConverter
{
/// <summary>
/// Bool Logic And 연산자 컨버터
/// </summary>
public class BoolAndConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.All(x => (x is bool boolValue && boolValue is true) || (x is string sValue && sValue.ToUpper() == "TRUE"))) {
return true;
}
return false;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class BoolOrConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.Any(x => (x is bool boolValue && boolValue is true) || (x is string sValue && sValue.ToUpper() == "TRUE"))) {
return true;
}
return false;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class TransBoolConverter : BoolConverter
{
public new object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var ret = base.Convert(value, targetType, parameter, culture);
if (ret != null && ret is string strValue) {
return ApplicationExt.FindStrToken(Application.Current, strValue);
} else {
return ret;
}
}
public new object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return base.ConvertBack(value, targetType, parameter, culture);
}
}
}