60 lines
2.3 KiB
C#
60 lines
2.3 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
using System.Windows.Media;
|
|
using BeWo.Scheduler.ViewModel;
|
|
|
|
using DevExpress.XtraScheduler;
|
|
|
|
namespace BeWo.Scheduler.View
|
|
{
|
|
public class EmployeeBrushConverter : IMultiValueConverter
|
|
{
|
|
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
var farbe = Color.FromRgb(192, 255, 208);
|
|
var gradientCollection = new GradientStopCollection { new GradientStop(farbe, 1) };
|
|
|
|
if(values[2] is bool b && b == false)
|
|
{
|
|
return gradientCollection;
|
|
}
|
|
|
|
try
|
|
{
|
|
if(!(values[1] is CustomFieldCollection customViewInfo))
|
|
{
|
|
return new LinearGradientBrush(new GradientStopCollection { new GradientStop(farbe, 1) }, new Point(.5, 0), new Point(.5, 1));
|
|
}
|
|
|
|
var customFieldStorage = (CustomFieldStorage) customViewInfo[nameof(CustomFieldStorage)];
|
|
|
|
var aptEmployees = customFieldStorage.EmployeeList;
|
|
var ersteller = customFieldStorage.Originator;
|
|
|
|
if(aptEmployees.Count > 0)
|
|
{
|
|
var firstEmployeeInList = aptEmployees.First(f => f.Employee.EmployeeColor != null);
|
|
gradientCollection = new GradientStopCollection { new GradientStop(firstEmployeeInList.Employee.FilterableBrush.Color, 1) };
|
|
}
|
|
else if(!string.IsNullOrEmpty(ersteller.EmployeeColor))
|
|
{
|
|
gradientCollection = new GradientStopCollection {new GradientStop(ersteller.FilterableBrush.Color, 1)};
|
|
}
|
|
|
|
return new LinearGradientBrush(gradientCollection, new Point(.5, 0), new Point(.5, 1));
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return new LinearGradientBrush(new GradientStopCollection { new GradientStop(farbe, 1) }, new Point(.5, 0), new Point(.5, 1));
|
|
}
|
|
}
|
|
|
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
} |