From 707ffd0d59e5c48039100bbc1d059fac99e3e57a Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Thu, 2 May 2024 09:09:24 +0200 Subject: [PATCH] Fix for traffic light status --- src/BreCalClient/ShipcallControl.xaml.cs | 51 ++++++++++-------------- src/BreCalClient/ShipcallControlModel.cs | 20 +++------- 2 files changed, 26 insertions(+), 45 deletions(-) diff --git a/src/BreCalClient/ShipcallControl.xaml.cs b/src/BreCalClient/ShipcallControl.xaml.cs index 42bbac0..ea960cb 100644 --- a/src/BreCalClient/ShipcallControl.xaml.cs +++ b/src/BreCalClient/ShipcallControl.xaml.cs @@ -228,14 +228,14 @@ namespace BreCalClient switch(this.ShipcallControlModel?.LightMode) { - case ShipcallControlModel.TrafficLightMode.GREEN: - this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/check.png")); + case EvaluationType.Green: + this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/check.png")); break; - case ShipcallControlModel.TrafficLightMode.YELLOW: - this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/sign_warning.png")); + case EvaluationType.Yellow: + this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/sign_warning.png")); break; - case ShipcallControlModel.TrafficLightMode.RED: - this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/delete2.png")); + case EvaluationType.Red: + this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/delete2.png")); break; default: break; @@ -252,22 +252,13 @@ namespace BreCalClient { 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 - switch (resultColor) + this.Background = this.ShipcallControlModel.LightMode switch { - //case ShipcallControlModel.TrafficLightMode.GREEN: - // this.Background = Brushes.LightGreen; - // break; - case ShipcallControlModel.TrafficLightMode.YELLOW: - 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; - } + // ShipcallControlModel.TrafficLightMode.GREEN => this.Background = Brushes.LightGreen, + EvaluationType.Yellow => Brushes.LightYellow, + EvaluationType.Red => new SolidColorBrush(Color.FromArgb(200, 255, 100, 100)), + _ => Brushes.Transparent, + }; } } @@ -337,19 +328,19 @@ namespace BreCalClient this.textBlockDraft.Text = ""; } - Times? mooringTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.MOORING); + Times? mooringTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.MOORING); if (mooringTimes != null) { 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; if(mooringTimes.Ata.HasValue) { - if(!ataAdded) - { + if(!ataAdded) + { ataRowDefinition.Height = new GridLength(15); labelTimesMooringATA.Content = mooringTimes.Ata.Value.ToString("dd.MM.yyyy HH:mm"); @@ -379,7 +370,7 @@ namespace BreCalClient if (portAuthorityTimes != null) { 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; if(portAuthorityTimes.LockTime.HasValue) { @@ -402,7 +393,7 @@ namespace BreCalClient if (pilotTimes != null) { 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; } else @@ -416,7 +407,7 @@ namespace BreCalClient if (tugTimes != null) { 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; } else @@ -431,7 +422,7 @@ namespace BreCalClient { this.labelTerminalBerth.Content = this.ShipcallControlModel?.GetBerthText(terminalTimes); 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); } else @@ -454,7 +445,7 @@ namespace BreCalClient #endregion - #region event handler + #region event handler private void buttonEditShipcall_Click(object? sender, RoutedEventArgs? e) { diff --git a/src/BreCalClient/ShipcallControlModel.cs b/src/BreCalClient/ShipcallControlModel.cs index 08c83b6..5b2a2b6 100644 --- a/src/BreCalClient/ShipcallControlModel.cs +++ b/src/BreCalClient/ShipcallControlModel.cs @@ -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; } }