123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- using System.Globalization;
- using System.Linq;
- using System.Windows;
- using System.Windows.Data;
- namespace Compdfkit_Tools.Common
- {
- public class AndMultiBoolValueConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- if (values != null && values.All(v => v is bool boolValue))
- {
- return values.Cast<bool>().All(v => v);
- }
- return DependencyProperty.UnsetValue;
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- return Enumerable.Repeat(DependencyProperty.UnsetValue, targetTypes.Length).ToArray();
- }
- }
-
- public class OrMultiBoolValueConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- if (values != null && values.All(v => v is bool boolValue))
- {
- return values.Cast<bool>().Any(v => v);
- }
- return DependencyProperty.UnsetValue;
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- return Enumerable.Repeat(DependencyProperty.UnsetValue, targetTypes.Length).ToArray();
- }
- }
- }
|