diff --git a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml index 318c7ac..a8854bb 100644 --- a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml +++ b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml @@ -8,16 +8,16 @@ xmlns:db="clr-namespace:BreCalClient;assembly=BreCalClient" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" Left="{local:SettingBinding W1Left}" Top="{local:SettingBinding W1Top}" - Title="{x:Static p:Resources.textEditShipcall}" Height="403" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico"> + Title="{x:Static p:Resources.textEditShipcall}" Height="403" Width="900" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico"> - - - + + + diff --git a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml index 5e954f4..b806217 100644 --- a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml +++ b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml @@ -8,13 +8,13 @@ xmlns:db="clr-namespace:BreCalClient;assembly=BreCalClient" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" Left="{local:SettingBinding W1Left}" Top="{local:SettingBinding W1Top}" - Title="{x:Static p:Resources.textEditShipcall}" Height="375" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico"> + Title="{x:Static p:Resources.textEditShipcall}" Height="375" Width="900" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico"> - - - + + + diff --git a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml index 28baa88..ecdd5e7 100644 --- a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml +++ b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml @@ -8,12 +8,12 @@ xmlns:db="clr-namespace:BreCalClient;assembly=BreCalClient" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" Left="{local:SettingBinding W1Left}" Top="{local:SettingBinding W1Top}" - Title="{x:Static p:Resources.textEditShipcall}" Height="490" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico"> + Title="{x:Static p:Resources.textEditShipcall}" Height="490" Width="900" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico"> - - - + + + diff --git a/src/BreCalClient/EditTimesControl.xaml b/src/BreCalClient/EditTimesControl.xaml index a551c21..e933d2e 100644 --- a/src/BreCalClient/EditTimesControl.xaml +++ b/src/BreCalClient/EditTimesControl.xaml @@ -8,11 +8,11 @@ xmlns:db="clr-namespace:BreCalClient;assembly=BreCalClient" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" Left="{local:SettingBinding W1Left}" Top="{local:SettingBinding W1Top}" - Title="{x:Static p:Resources.textEditTimes}" Height="331" Width="400" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico"> + Title="{x:Static p:Resources.textEditTimes}" Height="331" Width="500" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico"> - - + + diff --git a/src/BreCalClient/EditTimesTerminalControl.xaml b/src/BreCalClient/EditTimesTerminalControl.xaml index e1c9fb9..a253626 100644 --- a/src/BreCalClient/EditTimesTerminalControl.xaml +++ b/src/BreCalClient/EditTimesTerminalControl.xaml @@ -7,11 +7,11 @@ xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:local="clr-namespace:BreCalClient" mc:Ignorable="d" Left="{local:SettingBinding W1Left}" Top="{local:SettingBinding W1Top}" - Title="{x:Static p:Resources.textEditTimes}" Loaded="Window_Loaded" Height="295" Width="400" > + Title="{x:Static p:Resources.textEditTimes}" Loaded="Window_Loaded" Height="295" Width="500" > - - + + diff --git a/src/BreCalClient/Extensions.cs b/src/BreCalClient/Extensions.cs index 1030478..22b6d3d 100644 --- a/src/BreCalClient/Extensions.cs +++ b/src/BreCalClient/Extensions.cs @@ -3,8 +3,10 @@ // using BreCalClient.misc.Model; +using Newtonsoft.Json.Linq; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; namespace BreCalClient { @@ -82,6 +84,68 @@ namespace BreCalClient return value[..maxLength]; } + public static string DisplayTime(this Times times, bool isArrival) + { + if (isArrival) + { + if(times.ParticipantType == (int) ParticipantType.TERMINAL) + { + if(times.OperationsStart.HasValue) + { + string result = times.OperationsStart.Value.ToString("dd.MM.yyyy HH:mm"); + if (times.EtaIntervalEnd.HasValue) result += " - " + times.EtaIntervalEnd.Value.ToString("HH:mm"); + return result; + } + else + { + return "- / -"; + } + } + else + { + if(times.EtaBerth.HasValue) + { + string result = times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm"); + if (times.EtaIntervalEnd.HasValue) result += " - " + times.EtaIntervalEnd.Value.ToString("HH:mm"); + return result; + } + else + { + return "- / -"; + } + } + } + else + { + if (times.ParticipantType == (int)ParticipantType.TERMINAL) + { + if(times.OperationsEnd.HasValue) + { + string result = times.OperationsEnd.Value.ToString("dd.MM.yyyy HH:mm"); + if (times.EtdIntervalEnd.HasValue) result += " - " + times.EtdIntervalEnd.Value.ToString("HH:mm"); + return result; + } + else + { + return "- / -"; + } + } + else + { + if(times.EtdBerth.HasValue) + { + string result = times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm"); + if (times.EtdIntervalEnd.HasValue) result += " - " + times.EtdIntervalEnd.Value.ToString("HH:mm"); + return result; + } + else + { + return "- / -"; + } + } + } + } + #endregion } diff --git a/src/BreCalClient/ShipcallControl.xaml.cs b/src/BreCalClient/ShipcallControl.xaml.cs index d31a4b7..5739b7c 100644 --- a/src/BreCalClient/ShipcallControl.xaml.cs +++ b/src/BreCalClient/ShipcallControl.xaml.cs @@ -309,14 +309,10 @@ namespace BreCalClient Times? agencyTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY); if (agencyTimes != null) { - this.labelAgencyBerth.Content = this.ShipcallControlModel?.GetBerthText(agencyTimes); - this.labelAgencyETAETDValue.Content = agencyTimes.EtaBerth.HasValue ? agencyTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; + this.labelAgencyBerth.Content = this.ShipcallControlModel?.GetBerthText(agencyTimes); + this.labelAgencyETAETDValue.Content = agencyTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival); this.textBlockAgencyRemarks.Text = agencyTimes.Remarks; this.textBlockAgencyBerthRemarks.Text = agencyTimes.BerthInfo; - if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival) - { - this.labelAgencyETAETDValue.Content = agencyTimes.EtdBerth.HasValue ? agencyTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; - } this.textBlockDraft.Text = ShipcallControlModel?.Shipcall?.Draft?.ToString("N2"); } else @@ -334,12 +330,8 @@ namespace BreCalClient if (mooringTimes != null) { - this.labelMooringETAETDValue.Content = mooringTimes.EtaBerth.HasValue ? mooringTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; - this.textBlockMooringRemarks.Text = mooringTimes.Remarks; - if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival) - { - this.labelMooringETAETDValue.Content = mooringTimes.EtdBerth.HasValue ? mooringTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; - } + this.labelMooringETAETDValue.Content = mooringTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival); + this.textBlockMooringRemarks.Text = mooringTimes.Remarks; this.imageMooringLocked.Visibility = (mooringTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden; if(mooringTimes.Ata.HasValue) @@ -374,12 +366,8 @@ namespace BreCalClient Times? portAuthorityTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PORT_ADMINISTRATION); if (portAuthorityTimes != null) { - this.labelPortAuthorityETAETDValue.Content = portAuthorityTimes.EtaBerth.HasValue ? portAuthorityTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; - this.textBlockPortAuthorityRemarks.Text = portAuthorityTimes.Remarks; - if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival) - { - this.labelPortAuthorityETAETDValue.Content = portAuthorityTimes.EtdBerth.HasValue ? portAuthorityTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; - } + this.labelPortAuthorityETAETDValue.Content = portAuthorityTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival); + this.textBlockPortAuthorityRemarks.Text = portAuthorityTimes.Remarks; this.imagePortAuthorityLocked.Visibility = (portAuthorityTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden; } else @@ -392,12 +380,8 @@ namespace BreCalClient Times? pilotTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PILOT); if (pilotTimes != null) { - this.labelPilotETAETDValue.Content = pilotTimes.EtaBerth.HasValue ? pilotTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; - this.textBlockPilotRemarks.Text = pilotTimes.Remarks; - if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival) - { - this.labelPilotETAETDValue.Content = pilotTimes.EtdBerth.HasValue ? pilotTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; - } + this.labelPilotETAETDValue.Content = pilotTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival); + this.textBlockPilotRemarks.Text = pilotTimes.Remarks; this.imagePilotLocked.Visibility = (pilotTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden; } else @@ -410,12 +394,8 @@ namespace BreCalClient Times? tugTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.TUG); if (tugTimes != null) { - this.labelTugETAETDValue.Content = tugTimes.EtaBerth.HasValue ? tugTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; - this.textBlockTugRemarks.Text = tugTimes.Remarks; - if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival) - { - this.labelTugETAETDValue.Content = tugTimes.EtdBerth.HasValue ? tugTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; - } + this.labelTugETAETDValue.Content = tugTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival); + this.textBlockTugRemarks.Text = tugTimes.Remarks; this.imageTugLocked.Visibility = (tugTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden; } else @@ -429,12 +409,8 @@ namespace BreCalClient if (terminalTimes != null) { this.labelTerminalBerth.Content = this.ShipcallControlModel?.GetBerthText(terminalTimes); - this.labelOperationsStart.Content = terminalTimes.OperationsStart.HasValue ? terminalTimes.OperationsStart.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; - this.textBlockTerminalRemarks.Text = terminalTimes.Remarks; - if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival) - { - this.labelOperationsStart.Content = terminalTimes.OperationsEnd.HasValue ? terminalTimes.OperationsEnd.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; - } + this.labelOperationsStart.Content = terminalTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival); + this.textBlockTerminalRemarks.Text = terminalTimes.Remarks; this.textBlockTerminalBerthRemarks.Text = terminalTimes.BerthInfo; } else