From 3010d783f1ef08c127d465c0428acf4168eb4293 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Thu, 6 Apr 2023 09:44:38 +0200 Subject: [PATCH] =?UTF-8?q?Gelb=20einf=C3=A4rben=20der=20Zeile=20der=20Mel?= =?UTF-8?q?deklasse=20im=20Overview,=20wenn=20PAS=20und=20Passagier=20Anza?= =?UTF-8?q?hl=20>=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OverViewDetailControl.xaml | 13 +++-- ENI2/ENI2.csproj | 1 + ENI2/Util/CutoffConverter.cs | 49 +++++++++++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 ENI2/Util/CutoffConverter.cs diff --git a/ENI2/DetailViewControls/OverViewDetailControl.xaml b/ENI2/DetailViewControls/OverViewDetailControl.xaml index bb384509..8a06b9d0 100644 --- a/ENI2/DetailViewControls/OverViewDetailControl.xaml +++ b/ENI2/DetailViewControls/OverViewDetailControl.xaml @@ -8,6 +8,7 @@ xmlns:enictrl="clr-namespace:ENI2.Controls" xmlns:p="clr-namespace:ENI2.Properties" xmlns:util="clr-namespace:ENI2.Util" + xmlns:data="clr-namespace:bsmd.database;assembly=bsmd.database" xmlns:local="clr-namespace:ENI2.DetailViewControls" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="800"> @@ -147,6 +148,13 @@ + + + + + + + @@ -160,10 +168,7 @@ - - + diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj index 1cc369c0..544d357d 100644 --- a/ENI2/ENI2.csproj +++ b/ENI2/ENI2.csproj @@ -436,6 +436,7 @@ + diff --git a/ENI2/Util/CutoffConverter.cs b/ENI2/Util/CutoffConverter.cs new file mode 100644 index 00000000..b19c5570 --- /dev/null +++ b/ENI2/Util/CutoffConverter.cs @@ -0,0 +1,49 @@ +// Copyright (c) 2023- schick Informatik +// Description: Simple converter to check if a numeric value is greater than a specific value. This can +// be used by datatriggers in XAML +// + +using System; +using System.Collections; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace ENI2.Util +{ + public class CutoffConverter : MarkupExtension, IValueConverter + { + + #region MarkupExtension implementation + + private static CutoffConverter _converter = null; + public override object ProvideValue(IServiceProvider serviceProvider) + { + if (_converter == null) + { + _converter = new CutoffConverter(); + } + return _converter; + } + + #endregion + + #region IValueConverter implementation + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is ICollection collection) + return collection.Count > Cutoff; + return ((int)value) > Cutoff; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + + #endregion + + public int Cutoff { get; set; } + } +}