Show last change date permanently in the header. Latest value is highlighted

This commit is contained in:
Daniel Schick 2024-09-20 12:24:59 +02:00
parent ed6f5ab648
commit 90d32a26f1
4 changed files with 183 additions and 18 deletions

View File

@ -624,7 +624,7 @@ namespace BreCalClient
{
ShipcallControl sc = new()
{
Height = 135,
Height = 145,
ShipcallControlModel = scm
};
sc.EditTimesRequested += Sc_EditTimesRequested;

View File

@ -20,12 +20,12 @@
<ColumnDefinition Width=".15*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="32" />
<RowDefinition Height="42" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" >
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
<RowDefinition Height="42"/>
<RowDefinition Height=".125*"/>
<RowDefinition Height=".125*"/>
<RowDefinition Height=".125*"/>
@ -92,19 +92,60 @@
</Viewbox>
</Grid>
<Label Grid.Row="0" Grid.Column="1" Grid.RowSpan="1" FontSize="12" Content="- / -" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
<Grid Grid.Row="0" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="14" />
</Grid.RowDefinitions>
<Label Padding="0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="1" FontSize="13" Content="- / -" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Name="labelAgent" PreviewMouseUp="labelAgent_PreviewMouseUp"/>
<Label Grid.Row="0" Grid.Column="2" Grid.RowSpan="1" FontSize="12" Content="- / -" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
<Label Name="labelLastChangeAgency" FontSize="9" Padding="0" VerticalContentAlignment="Center" Grid.Row="1" Foreground="WhiteSmoke" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" HorizontalContentAlignment="Center" />
</Grid>
<Grid Grid.Row="0" Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="14" />
</Grid.RowDefinitions>
<Label Padding="0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="1" FontSize="13" Content="- / -" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Name="labelMooring" PreviewMouseUp="labelMooring_PreviewMouseUp"/>
<Label Grid.Row="0" Grid.Column="3" Grid.RowSpan="1" FontSize="12" Content="- / -" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
<Label Name="labelLastChangeMooring" FontSize="9" Padding="0" VerticalContentAlignment="Center" Grid.Row="1" Foreground="WhiteSmoke" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" HorizontalContentAlignment="Center" />
</Grid>
<Grid Grid.Row="0" Grid.Column="3">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="14" />
</Grid.RowDefinitions>
<Label Padding="0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="1" FontSize="13" Content="- / -" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Name="labelPortAuthority" PreviewMouseUp="labelPortAuthority_PreviewMouseUp"/>
<Label Grid.Row="0" Grid.Column="4" Grid.RowSpan="1" FontSize="12" Content="- / -" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
<Label Name="labelLastChangePortAuthority" FontSize="9" Padding="0" VerticalContentAlignment="Center" Grid.Row="1" Foreground="WhiteSmoke" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" HorizontalContentAlignment="Center" />
</Grid>
<Grid Grid.Row="0" Grid.Column="4">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="14" />
</Grid.RowDefinitions>
<Label Padding="0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="1" FontSize="13" Content="- / -" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Name="labelPilot" PreviewMouseUp="labelPilot_PreviewMouseUp"/>
<Label Grid.Row="0" Grid.Column="5" Grid.RowSpan="1" FontSize="12" Content="- / -" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
<Label Name="labelLastChangePilot" FontSize="9" Padding="0" VerticalContentAlignment="Center" Grid.Row="1" Foreground="WhiteSmoke" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" HorizontalContentAlignment="Center" />
</Grid>
<Grid Grid.Row="0" Grid.Column="5">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="14" />
</Grid.RowDefinitions>
<Label Padding="0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="1" FontSize="13" Content="- / -" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Name="labelTug" PreviewMouseUp="labelTug_PreviewMouseUp"/>
<Label Grid.Row="0" Grid.Column="6" Grid.RowSpan="1" FontSize="12" Content="- / -" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
<Label Name="labelLastChangeTug" FontSize="9" Padding="0" VerticalContentAlignment="Center" Grid.Row="1" Foreground="WhiteSmoke" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" HorizontalContentAlignment="Center" />
</Grid>
<Grid Grid.Row="0" Grid.Column="6">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="14" />
</Grid.RowDefinitions>
<Label Padding="0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="1" FontSize="13" Content="- / -" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Name="labelTerminal" PreviewMouseUp="labelTerminal_PreviewMouseUp"/>
<Label Name="labelLastChangeTerminal" FontSize="9" Padding="0" VerticalContentAlignment="Center" Grid.Row="1" Foreground="WhiteSmoke" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" HorizontalContentAlignment="Center" />
</Grid>
<!-- AGENCY -->
<Border Grid.Row="2" Grid.Column="1" BorderThickness="1, 0, 0, 0" BorderBrush="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" Padding="3,0,0,0">

View File

@ -316,6 +316,7 @@ namespace BreCalClient
{
this.textBlockHarbour.Text = ((ShipcallControlModel != null) && (ShipcallControlModel.Shipcall != null) && BreCalLists.PortLookupDict.ContainsKey(ShipcallControlModel.Shipcall.PortId)) ?
BreCalLists.PortLookupDict[ShipcallControlModel.Shipcall.PortId].Name : "";
Extensions.ParticipantType? lastToUpdate = this.ShipcallControlModel?.LastParticipantTypeToUpdate();
Times? agencyTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY);
if (agencyTimes != null)
@ -324,6 +325,19 @@ namespace BreCalClient
this.labelAgencyETAETDValue.Content = agencyTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival);
this.textBlockAgencyRemarks.Text = agencyTimes.Remarks.TruncateDots(50);
this.textBlockAgencyBerthRemarks.Text = agencyTimes.BerthInfo.TruncateDots(50);
DateTime? lc = this.ShipcallControlModel?.GetLastChangeForType(Extensions.ParticipantType.AGENCY);
this.labelLastChangeAgency.Content = lc.HasValue ? lc.Value.ToString("dd.MM.yyyy HH:mm") : string.Empty;
Grid.SetRowSpan(this.labelAgent, 1);
if(lastToUpdate == Extensions.ParticipantType.AGENCY)
{
this.labelLastChangeAgency.Foreground = Brushes.Pink;
this.labelLastChangeAgency.FontWeight = FontWeights.DemiBold;
}
else
{
this.labelLastChangeAgency.Foreground = Brushes.WhiteSmoke;
this.labelLastChangeAgency.FontWeight = FontWeights.Normal;
}
}
else
{
@ -332,6 +346,7 @@ namespace BreCalClient
this.labelAgencyETAETDValue.Content = "- / -";
this.textBlockAgencyRemarks.Text = "";
this.textBlockAgencyBerthRemarks.Text = "";
Grid.SetRowSpan(this.labelAgent, 2);
}
Times? mooringTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.MOORING);
@ -355,12 +370,26 @@ namespace BreCalClient
labelTimesMooringATD.Content = mooringTimes.Atd.Value.ToString("dd.MM.yyyy HH:mm");
}
DateTime? lc = this.ShipcallControlModel?.GetLastChangeForType(Extensions.ParticipantType.MOORING);
this.labelLastChangeMooring.Content = lc.HasValue ? lc.Value.ToString("dd.MM.yyyy HH:mm") : string.Empty;
Grid.SetRowSpan(this.labelMooring, 1);
if (lastToUpdate == Extensions.ParticipantType.MOORING)
{
this.labelLastChangeMooring.Foreground = Brushes.Pink;
this.labelLastChangeMooring.FontWeight = FontWeights.DemiBold;
}
else
{
this.labelLastChangeMooring.Foreground = Brushes.WhiteSmoke;
this.labelLastChangeMooring.FontWeight = FontWeights.Normal;
}
}
else
{
this.labelMooringETAETDValue.Content = "- / ";
this.textBlockMooringRemarks.Text = "";
this.imageMooringLocked.Visibility = Visibility.Hidden;
Grid.SetRowSpan(this.labelMooring, 2);
}
Times? portAuthorityTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PORT_ADMINISTRATION);
@ -374,12 +403,27 @@ namespace BreCalClient
{
labelPortAuthorityLockTime.Content = portAuthorityTimes.LockTime.Value.ToString("dd.MM.yyyy HH:mm");
}
DateTime? lc = this.ShipcallControlModel?.GetLastChangeForType(Extensions.ParticipantType.PORT_ADMINISTRATION);
this.labelLastChangePortAuthority.Content = lc.HasValue ? lc.Value.ToString("dd.MM.yyyy HH:mm") : string.Empty;
Grid.SetRowSpan(this.labelPortAuthority, 1);
if (lastToUpdate == Extensions.ParticipantType.PORT_ADMINISTRATION)
{
this.labelLastChangePortAuthority.Foreground = Brushes.Pink;
this.labelLastChangePortAuthority.FontWeight = FontWeights.DemiBold;
}
else
{
this.labelLastChangePortAuthority.Foreground = Brushes.WhiteSmoke;
this.labelLastChangePortAuthority.FontWeight = FontWeights.Normal;
}
}
else
{
this.labelPortAuthorityETAETDValue.Content = "- / -";
this.textBlockPortAuthorityRemarks.Text = "";
this.imagePortAuthorityLocked.Visibility = Visibility.Hidden;
Grid.SetRowSpan(this.labelPortAuthority, 2);
}
Times? pilotTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PILOT);
@ -388,12 +432,27 @@ namespace BreCalClient
this.labelPilotETAETDValue.Content = pilotTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival);
this.textBlockPilotRemarks.Text = pilotTimes.Remarks.TruncateDots(50);
this.imagePilotLocked.Visibility = (pilotTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden;
DateTime? lc = this.ShipcallControlModel?.GetLastChangeForType(Extensions.ParticipantType.PILOT);
this.labelLastChangePilot.Content = lc.HasValue ? lc.Value.ToString("dd.MM.yyyy HH:mm") : string.Empty;
Grid.SetRowSpan(this.labelPilot, 1);
if (lastToUpdate == Extensions.ParticipantType.PILOT)
{
this.labelLastChangePilot.Foreground = Brushes.Pink;
this.labelLastChangePilot.FontWeight = FontWeights.DemiBold;
}
else
{
this.labelLastChangePilot.Foreground = Brushes.WhiteSmoke;
this.labelLastChangePilot.FontWeight = FontWeights.Normal;
}
}
else
{
this.labelPilotETAETDValue.Content = "- / -";
this.textBlockPilotRemarks.Text = "";
this.imagePilotLocked.Visibility = Visibility.Hidden;
Grid.SetRowSpan(this.labelPilot, 2);
}
Times? tugTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.TUG);
@ -402,12 +461,27 @@ namespace BreCalClient
this.labelTugETAETDValue.Content = tugTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival);
this.textBlockTugRemarks.Text = tugTimes.Remarks.TruncateDots(50);
this.imageTugLocked.Visibility = (tugTimes.EtaBerthFixed ?? false) ? Visibility.Visible : Visibility.Hidden;
DateTime? lc = this.ShipcallControlModel?.GetLastChangeForType(Extensions.ParticipantType.TUG);
this.labelLastChangeTug.Content = lc.HasValue ? lc.Value.ToString("dd.MM.yyyy HH:mm") : string.Empty;
Grid.SetRowSpan(this.labelTug, 1);
if (lastToUpdate == Extensions.ParticipantType.TUG)
{
this.labelLastChangeTug.Foreground = Brushes.Pink;
this.labelLastChangeTug.FontWeight = FontWeights.DemiBold;
}
else
{
this.labelLastChangeTug.Foreground = Brushes.WhiteSmoke;
this.labelLastChangeTug.FontWeight = FontWeights.Normal;
}
}
else
{
this.labelTugETAETDValue.Content = "- / -";
this.textBlockTugRemarks.Text = "";
this.imageTugLocked.Visibility = Visibility.Hidden;
Grid.SetRowSpan(this.labelTug, 2);
}
this.rowDefinitionTerminalBerth.Height = (this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival) ? new(14) : new(0);
@ -421,6 +495,19 @@ namespace BreCalClient
this.labelOperationsStart.Content = terminalTimes.DisplayTime(this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival);
this.textBlockTerminalRemarks.Text = terminalTimes.Remarks.TruncateDots(40);
this.textBlockTerminalBerthRemarks.Text = terminalTimes.BerthInfo.TruncateDots(40);
DateTime? lc = this.ShipcallControlModel?.GetLastChangeForType(Extensions.ParticipantType.TERMINAL);
this.labelLastChangeTerminal.Content = lc.HasValue ? lc.Value.ToString("dd.MM.yyyy HH:mm") : string.Empty;
Grid.SetRowSpan(this.labelTerminal, 1);
if (lastToUpdate == Extensions.ParticipantType.TERMINAL)
{
this.labelLastChangeTerminal.Foreground = Brushes.Pink;
this.labelLastChangeTerminal.FontWeight = FontWeights.DemiBold;
}
else
{
this.labelLastChangeTerminal.Foreground = Brushes.WhiteSmoke;
this.labelLastChangeTerminal.FontWeight = FontWeights.Normal;
}
}
else
{
@ -428,6 +515,7 @@ namespace BreCalClient
this.labelOperationsStart.Content = "";
this.textBlockTerminalRemarks.Text = "";
this.textBlockTerminalBerthRemarks.Text = "";
Grid.SetRowSpan(this.labelTerminal, 2);
}
}

View File

@ -309,6 +309,42 @@ namespace BreCalClient
return true;
}
public DateTime? GetLastChangeForType(Extensions.ParticipantType type)
{
DateTime? lastChange = null;
Times? times = GetTimesForParticipantType(type);
if(times != null)
{
if (times.Modified.HasValue) lastChange = times.Modified.Value;
else lastChange = times.Created;
}
return lastChange;
}
public Extensions.ParticipantType? LastParticipantTypeToUpdate()
{
Extensions.ParticipantType? last = null;
DateTime min = DateTime.MinValue;
foreach(Times times in this.Times)
{
if (times.Modified.HasValue)
{
if (times.Modified.Value > min)
{
min = times.Modified.Value;
last = (Extensions.ParticipantType)times.ParticipantType;
continue;
}
}
if(times.Created > min)
{
min = times.Created;
last = (Extensions.ParticipantType)times.ParticipantType;
}
}
return last;
}
#endregion
#region helper