79 lines
2.4 KiB
C#
79 lines
2.4 KiB
C#
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;
|
|
using System.Windows.Markup;
|
|
using System.Windows.Media;
|
|
|
|
using C4IT.Logging;
|
|
|
|
namespace FasdDesktopUi.Basics.Converter
|
|
{
|
|
public class BoolOrToVisibilityConverter : IMultiValueConverter
|
|
{
|
|
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
foreach (var value in values)
|
|
{
|
|
if (value is bool boolValue && boolValue)
|
|
return Visibility.Visible;
|
|
}
|
|
return Visibility.Collapsed;
|
|
}
|
|
|
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
public class BooleanToBrushConverter : MarkupExtension, IValueConverter
|
|
{
|
|
public Object TrueValue { get; set; } = new SolidColorBrush(Colors.LightGray);
|
|
public Object FalseValue { get; set; } = new SolidColorBrush(Colors.Blue);
|
|
|
|
public object Convert(
|
|
object value, Type targetType, object parameter,
|
|
CultureInfo culture)
|
|
{
|
|
if (!(value is bool))
|
|
return FalseValue;
|
|
|
|
return (bool)value ? TrueValue :
|
|
FalseValue;
|
|
}
|
|
|
|
public object ConvertBack(
|
|
object value, Type targetType, object parameter,
|
|
CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override object ProvideValue(IServiceProvider serviceProvider)
|
|
{
|
|
return this;
|
|
}
|
|
}
|
|
|
|
public class WebView2PathConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
var _webViewConfigPath = cLogManagerFile.GetDefaultPath(false, SubFolder: "WebViewData");
|
|
_webViewConfigPath = System.IO.Path.GetDirectoryName(_webViewConfigPath);
|
|
return _webViewConfigPath;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
}
|