45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Windows.Data;
|
|
using System.Windows.Media;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
|
|
namespace BeWo.Converter
|
|
{
|
|
public class BoolScaleTransformConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
return ((bool)value) ? new ScaleTransform { ScaleX = 1, ScaleY = 1 } : new ScaleTransform { ScaleX = 0, ScaleY = 0 };
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
public class UserRightTypeConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if(!(value is IEnumerable<UserRightType> iEnumerable))
|
|
{
|
|
return value;
|
|
}
|
|
|
|
var userRights = iEnumerable.ToList();
|
|
userRights.Remove(UserRightType.None);
|
|
|
|
return userRights.Select(right => EnumTranslations.UserRightType2Translations.Single(right2Translation => right2Translation.Key == right)).OrderBy(right2Translation => right2Translation.Value).ToDictionary(right2Translation => right2Translation.Key, right2Translation => right2Translation.Value);
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
} |