Fix for traffic light status

This commit is contained in:
Daniel Schick 2024-05-02 09:09:24 +02:00
parent 45db6daffe
commit 707ffd0d59
2 changed files with 26 additions and 45 deletions

View File

@ -228,14 +228,14 @@ namespace BreCalClient
switch(this.ShipcallControlModel?.LightMode) switch(this.ShipcallControlModel?.LightMode)
{ {
case ShipcallControlModel.TrafficLightMode.GREEN: case EvaluationType.Green:
this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/check.png")); this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/check.png"));
break; break;
case ShipcallControlModel.TrafficLightMode.YELLOW: case EvaluationType.Yellow:
this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/sign_warning.png")); this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/sign_warning.png"));
break; break;
case ShipcallControlModel.TrafficLightMode.RED: case EvaluationType.Red:
this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/delete2.png")); this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/delete2.png"));
break; break;
default: default:
break; break;
@ -252,22 +252,13 @@ namespace BreCalClient
{ {
if (this.ShipcallControlModel?.Shipcall?.Evaluation != null) 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 = this.ShipcallControlModel.LightMode switch
switch (resultColor)
{ {
//case ShipcallControlModel.TrafficLightMode.GREEN: // ShipcallControlModel.TrafficLightMode.GREEN => this.Background = Brushes.LightGreen,
// this.Background = Brushes.LightGreen; EvaluationType.Yellow => Brushes.LightYellow,
// break; EvaluationType.Red => new SolidColorBrush(Color.FromArgb(200, 255, 100, 100)),
case ShipcallControlModel.TrafficLightMode.YELLOW: _ => Brushes.Transparent,
this.Background = Brushes.LightYellow; };
break;
case ShipcallControlModel.TrafficLightMode.RED:
this.Background = new SolidColorBrush(Color.FromArgb(200, 255, 100, 100));
break;
default:
this.Background = Brushes.Transparent;
break;
}
} }
} }
@ -337,19 +328,19 @@ namespace BreCalClient
this.textBlockDraft.Text = ""; this.textBlockDraft.Text = "";
} }
Times? mooringTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.MOORING); Times? mooringTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.MOORING);
if (mooringTimes != null) if (mooringTimes != null)
{ {
this.labelMooringETAETDValue.Content = mooringTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival); this.labelMooringETAETDValue.Content = mooringTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival);
this.textBlockMooringRemarks.Text = mooringTimes.Remarks.TruncateDots(50); this.textBlockMooringRemarks.Text = mooringTimes.Remarks.TruncateDots(50);
this.imageMooringLocked.Visibility = (mooringTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden; this.imageMooringLocked.Visibility = (mooringTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden;
if(mooringTimes.Ata.HasValue) if(mooringTimes.Ata.HasValue)
{ {
if(!ataAdded) if(!ataAdded)
{ {
ataRowDefinition.Height = new GridLength(15); ataRowDefinition.Height = new GridLength(15);
labelTimesMooringATA.Content = mooringTimes.Ata.Value.ToString("dd.MM.yyyy HH:mm"); labelTimesMooringATA.Content = mooringTimes.Ata.Value.ToString("dd.MM.yyyy HH:mm");
@ -379,7 +370,7 @@ namespace BreCalClient
if (portAuthorityTimes != null) if (portAuthorityTimes != null)
{ {
this.labelPortAuthorityETAETDValue.Content = portAuthorityTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival); this.labelPortAuthorityETAETDValue.Content = portAuthorityTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival);
this.textBlockPortAuthorityRemarks.Text = portAuthorityTimes.Remarks.TruncateDots(50); this.textBlockPortAuthorityRemarks.Text = portAuthorityTimes.Remarks.TruncateDots(50);
this.imagePortAuthorityLocked.Visibility = (portAuthorityTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden; this.imagePortAuthorityLocked.Visibility = (portAuthorityTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden;
if(portAuthorityTimes.LockTime.HasValue) if(portAuthorityTimes.LockTime.HasValue)
{ {
@ -402,7 +393,7 @@ namespace BreCalClient
if (pilotTimes != null) if (pilotTimes != null)
{ {
this.labelPilotETAETDValue.Content = pilotTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival); this.labelPilotETAETDValue.Content = pilotTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival);
this.textBlockPilotRemarks.Text = pilotTimes.Remarks.TruncateDots(50); this.textBlockPilotRemarks.Text = pilotTimes.Remarks.TruncateDots(50);
this.imagePilotLocked.Visibility = (pilotTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden; this.imagePilotLocked.Visibility = (pilotTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden;
} }
else else
@ -416,7 +407,7 @@ namespace BreCalClient
if (tugTimes != null) if (tugTimes != null)
{ {
this.labelTugETAETDValue.Content = tugTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival); this.labelTugETAETDValue.Content = tugTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival);
this.textBlockTugRemarks.Text = tugTimes.Remarks.TruncateDots(50); this.textBlockTugRemarks.Text = tugTimes.Remarks.TruncateDots(50);
this.imageTugLocked.Visibility = (tugTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden; this.imageTugLocked.Visibility = (tugTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden;
} }
else else
@ -431,7 +422,7 @@ namespace BreCalClient
{ {
this.labelTerminalBerth.Content = this.ShipcallControlModel?.GetBerthText(terminalTimes); this.labelTerminalBerth.Content = this.ShipcallControlModel?.GetBerthText(terminalTimes);
this.labelOperationsStart.Content = terminalTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival); this.labelOperationsStart.Content = terminalTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival);
this.textBlockTerminalRemarks.Text = terminalTimes.Remarks.TruncateDots(40); this.textBlockTerminalRemarks.Text = terminalTimes.Remarks.TruncateDots(40);
this.textBlockTerminalBerthRemarks.Text = terminalTimes.BerthInfo.TruncateDots(40); this.textBlockTerminalBerthRemarks.Text = terminalTimes.BerthInfo.TruncateDots(40);
} }
else else
@ -454,7 +445,7 @@ namespace BreCalClient
#endregion #endregion
#region event handler #region event handler
private void buttonEditShipcall_Click(object? sender, RoutedEventArgs? e) private void buttonEditShipcall_Click(object? sender, RoutedEventArgs? e)
{ {

View File

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