fixed wrong offset of evaluation lights (traffic) due to erroneous cast to int

This commit is contained in:
Daniel Schick 2024-05-02 09:09:24 +02:00
parent 29618fbf93
commit db0bcea485
2 changed files with 12 additions and 23 deletions

View File

@ -228,13 +228,13 @@ namespace BreCalClient
switch(this.ShipcallControlModel?.LightMode)
{
case ShipcallControlModel.TrafficLightMode.GREEN:
case EvaluationType.Green:
this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/check.png"));
break;
case ShipcallControlModel.TrafficLightMode.YELLOW:
case EvaluationType.Yellow:
this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/sign_warning.png"));
break;
case ShipcallControlModel.TrafficLightMode.RED:
case EvaluationType.Red:
this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/delete2.png"));
break;
default:
@ -251,13 +251,12 @@ namespace BreCalClient
else
{
if (this.ShipcallControlModel?.Shipcall?.Evaluation != null)
{
ShipcallControlModel.TrafficLightMode resultColor = (ShipcallControlModel.TrafficLightMode)(this.ShipcallControlModel?.Shipcall?.Evaluation ?? 0); // der nullable Operator hier ist so doof, die VS validation blickts einfach nicht
this.Background = resultColor switch
{
this.Background = this.ShipcallControlModel.LightMode switch
{
// ShipcallControlModel.TrafficLightMode.GREEN => this.Background = Brushes.LightGreen,
ShipcallControlModel.TrafficLightMode.YELLOW => Brushes.LightYellow,
ShipcallControlModel.TrafficLightMode.RED => new SolidColorBrush(Color.FromArgb(200, 255, 100, 100)),
EvaluationType.Yellow => Brushes.LightYellow,
EvaluationType.Red => new SolidColorBrush(Color.FromArgb(200, 255, 100, 100)),
_ => Brushes.Transparent,
};
}

View File

@ -16,17 +16,7 @@ namespace BreCalClient
public class ShipcallControlModel
{
#region Enumerations
public enum TrafficLightMode
{
OFF,
GREEN,
YELLOW,
RED,
RED_YELLOW,
ALL
};
#region Enumerations
[Flags]
public enum StatusFlags
@ -74,20 +64,20 @@ namespace BreCalClient
}
}
public TrafficLightMode LightMode
public EvaluationType LightMode
{
get
{
TrafficLightMode tlm = TrafficLightMode.OFF;
EvaluationType elm = EvaluationType.Undefined;
if (this.Shipcall != null)
{
if(this.Shipcall.Evaluation.HasValue)
{
tlm = (TrafficLightMode)this.Shipcall.Evaluation;
elm = this.Shipcall.Evaluation.Value;
}
}
return tlm;
return elm;
}
}