Edit dialogs agent WIP

This commit is contained in:
Daniel Schick 2023-09-28 11:56:20 +02:00
parent e7680afcd4
commit 92a504b668
16 changed files with 622 additions and 482 deletions

View File

@ -0,0 +1,123 @@
// Copyright (c) 2023 schick Informatik
// Description: Static lists used everywhere
//
using BreCalClient.misc.Model;
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace BreCalClient
{
public static class BreCalLists
{
#region Fields
private static readonly List<Participant> aList = new();
private static readonly List<Participant> mList = new();
private static readonly List<Participant> pList = new();
private static readonly List<Participant> tList = new();
private static readonly List<Participant> terList = new();
private static List<Berth> _berths = new();
private static List<Participant> _participants = new();
private static List<Ship> _ships = new();
private readonly static ConcurrentDictionary<int, Ship> _shipLookupDict = new();
private readonly static ConcurrentDictionary<int, Berth> _berthLookupDict = new();
private readonly static Dictionary<int, Participant> _participantLookupDict = new();
#endregion
#region Properties
public static ConcurrentDictionary<int, Ship> ShipLookupDict { get { return _shipLookupDict; } }
public static ConcurrentDictionary<int, Berth> BerthLookupDict { get { return _berthLookupDict; } }
public static Dictionary<int, Participant> ParticipantLookupDict { get { return _participantLookupDict; } }
/// <summary>
/// Participants that are agents
/// </summary>
public static List<Participant> Participants_Agent { get { return aList; } }
/// <summary>
/// Participants that are mooring companies
/// </summary>
public static List<Participant> Participants_Mooring { get { return mList; } }
/// <summary>
/// Participants that are pilots
/// </summary>
public static List<Participant> Participants_Pilot { get { return pList; } }
/// <summary>
/// Participants that are tug shipping companies
/// </summary>
public static List<Participant> Participants_Tug { get { return tList; } }
/// <summary>
/// Participants that are terminals
/// </summary>
public static List<Participant> Participants_Terminal { get { return terList; } }
/// <summary>
/// All participants
/// </summary>
public static List<Participant> Participants { get { return _participants; } }
/// <summary>
/// All berths
/// </summary>
public static List<Berth> Berths { get { return _berths; } }
/// <summary>
/// All ships
/// </summary>
public static List<Ship> Ships { get { return _ships; } }
#endregion
#region methods
internal static void InitializeParticipants(List<Participant> participants)
{
_participants = participants;
aList.Clear();
mList.Clear();
pList.Clear();
tList.Clear();
terList.Clear();
foreach (Participant p in participants)
{
_participantLookupDict[p.Id] = p;
if (p.IsTypeFlagSet(Extensions.ParticipantType.AGENCY)) aList.Add(p);
if (p.IsTypeFlagSet(Extensions.ParticipantType.MOORING)) mList.Add(p);
if (p.IsTypeFlagSet(Extensions.ParticipantType.PILOT)) pList.Add(p);
if (p.IsTypeFlagSet(Extensions.ParticipantType.TUG)) tList.Add(p);
if (p.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL)) terList.Add(p);
}
}
internal static void InitializeBerths(List<Berth> berths)
{
foreach (var berth in berths)
_berthLookupDict[berth.Id] = berth;
_berths = berths;
}
internal static void InitializeShips(List<Ship> ships)
{
foreach (var ship in ships)
_shipLookupDict[ship.Id] = ship;
_ships = ships;
}
#endregion
}
}

View File

@ -8,7 +8,7 @@
xmlns:db="clr-namespace:BreCalClient;assembly=BreCalClient"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="{x:Static p:Resources.textEditShipcall}" Height="466" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico">
Title="{x:Static p:Resources.textEditShipcall}" Height="214" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico">
<Window.Resources>
<local:BoolToIndexConverter x:Key="boolToIndexConverter" />
</Window.Resources>
@ -26,135 +26,73 @@
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Label Content="{x:Static p:Resources.textShip}" Grid.Column="0" Grid.Row="0" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textType}" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right" />
<Label Content="ETA" Grid.Column="0" Grid.Row="2" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textVoyage}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right"/>
<Label Content="ETD" Grid.Column="0" Grid.Row="4" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textArrivalTerminal}" Grid.Column="0" Grid.Row="5" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textDepartureTerminal}" Grid.Column="0" Grid.Row="6" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textTugRequired}" Grid.Column="1" Grid.Row="7" />
<Label Content="{x:Static p:Resources.textPilotRequired}" Grid.Column="1" Grid.Row="8" />
<Label Content="{x:Static p:Resources.textPierside}" Grid.Column="0" Grid.Row="9" HorizontalContentAlignment="Right" />
<Label Content="{x:Static p:Resources.textBunkering}" Grid.Column="1" Grid.Row="10" />
<Label Content="{x:Static p:Resources.textReplenishingTerminal}" Grid.Column="1" Grid.Row="11" />
<Label Content="{x:Static p:Resources.textReplenishingLock}" Grid.Column="1" Grid.Row="12" />
<Label Content="{x:Static p:Resources.textDraft}" Grid.Column="0" Grid.Row="13" HorizontalContentAlignment="Right" />
<ComboBox x:Name="comboBoxShip" Margin="2" Grid.Column="1" Grid.Row="0" SelectionChanged="comboBoxShip_SelectionChanged" SelectedValuePath="Id">
<ComboBox.ItemTemplate>
<DataTemplate>
<!--Border-->
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} ({1})">
<Binding Path="Name" />
<Binding Path="Imo" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} ({1})">
<Binding Path="Name" />
<Binding Path="Imo" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<!--/Border-->
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ComboBox x:Name="comboBoxCategories" Grid.Column="1" Margin="2" Grid.Row="1" SelectedValuePath="Key"/>
<xctk:DateTimePicker x:Name="datePickerETA" Grid.Column="1" Grid.Row="2" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/>
<TextBox x:Name="textBoxVoyage" Grid.Column="1" Grid.Row="3" Margin="2" VerticalContentAlignment="Center" />
<xctk:DateTimePicker x:Name="datePickerETD" Grid.Column="1" Grid.Row="4" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/>
<ComboBox Name="comboBoxArrivalBerth" Grid.Column="1" Grid.Row="5" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearValue}" Name="contextMenuItemArrivalBerth" Click="contextMenuItemArrivalBerth_Click" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<ComboBox Name="comboBoxDepartureBerth" Grid.Column="1" Grid.Row="6" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearValue}" Name="contextMenuItemDepartureBerth" Click="contextMenuItemDepartureBerth_Click" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<CheckBox x:Name="checkBoxTugRequired" Grid.Column="0" Grid.Row="7" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,4,0" />
<CheckBox x:Name="checkBoxPilotRequired" Grid.Column="0" Grid.Row="8" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,4,0" />
<ComboBox x:Name="comboBoxPierside" Grid.Column="1" Grid.Row="9" Margin="2" >
<ComboBoxItem Content="{x:Static p:Resources.textNotRotated}" />
<ComboBoxItem Content="{x:Static p:Resources.textRotated}" />
</ComboBox>
<CheckBox x:Name="checkBoxBunkering" Grid.Column="0" Grid.Row="10" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,4,0" />
<CheckBox x:Name="checkBoxReplenishingTerminal" Grid.Column="0" Grid.Row="11" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,4,0" />
<CheckBox x:Name="checkBoxReplenishingLock" Grid.Column="0" Grid.Row="12" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,4,0" />
<xctk:DoubleUpDown x:Name="doubleUpDownDraft" Grid.Column="1" Grid.Row="13" Margin="2" FormatString="N2" Minimum="0" />
<Label Content="IMO" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right"/>
<xctk:IntegerUpDown x:Name="integerUpDownIMO" IsReadOnly="True" Margin="2" Grid.Column="1" Grid.Row="1" />
<Label Content="{x:Static p:Resources.textCallsign}" Grid.Column="0" Grid.Row="2" HorizontalContentAlignment="Right"/>
<TextBox x:Name="textBoxCallsign" IsReadOnly="True" Grid.Column="1" Grid.Row="2" Margin="2" />
<Label Content="{x:Static p:Resources.textLength}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right"/>
<xctk:DoubleUpDown x:Name="doubleUpDownLength" Margin="2" Grid.Column="1" Grid.Row="3" FormatString="N2" IsReadOnly="True" />
<Label Content="{x:Static p:Resources.textWidth}" Grid.Column="0" Grid.Row="4" HorizontalContentAlignment="Right"/>
<xctk:DoubleUpDown x:Name="doubleUpDownWidth" Margin="2" Grid.Column="1" Grid.Row="4" FormatString="N2" IsReadOnly="True" />
<Label Content="{x:Static p:Resources.textType}" Grid.Column="2" Grid.Row="0" HorizontalContentAlignment="Right" />
<Label Content="ETA" Grid.Column="2" Grid.Row="2" HorizontalContentAlignment="Right"/>
<Label Content="ETD" Grid.Column="2" Grid.Row="3" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textParticipants}" FontWeight="DemiBold" Grid.Column="3" Grid.Row="0" />
<Label Content="{x:Static p:Resources.textAgency}" Grid.Column="2" Grid.Row="1" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textMooring}" Grid.Column="2" Grid.Row="2" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textPilot}" Grid.Column="2" Grid.Row="3" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textTug}" Grid.Column="2" Grid.Row="4" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textTerminal}" Grid.Column="2" Grid.Row="5" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textTidalWindow}" FontWeight="DemiBold" Grid.Column="3" Grid.Row="6" />
<Label Content="{x:Static p:Resources.textFrom}" Grid.Column="2" Grid.Row="7" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textTo}" Grid.Column="2" Grid.Row="8" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textRainSensitiveCargo}" Grid.Column="3" Grid.Row="9" />
<Label Content="{x:Static p:Resources.textRecommendedTugs}" Grid.Column="2" Grid.Row="10" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textAnchored}" Grid.Column="3" Grid.Row="11" />
<Label Content="{x:Static p:Resources.textMooredLock}" Grid.Column="3" Grid.Row="12" />
<Label Content="{x:Static p:Resources.textCancelled}" Grid.Column="3" Grid.Row="13" />
<ComboBox x:Name="comboBoxCategories" Grid.Column="3" Margin="2" Grid.Row="0" SelectedValuePath="Key" SelectionChanged="comboBoxCategories_SelectionChanged"/>
<xctk:DateTimePicker x:Name="datePickerETA" Grid.Column="3" Grid.Row="2" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm" IsEnabled="False"/>
<xctk:DateTimePicker x:Name="datePickerETD" Grid.Column="3" Grid.Row="3" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm" IsEnabled="False"/>
<Label Content="{x:Static p:Resources.textBerth}" Grid.Column="2" Grid.Row="1" HorizontalContentAlignment="Right"/>
<Grid Grid.Row="1" Grid.Column="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".5*" />
<ColumnDefinition Width=".5*" />
</Grid.ColumnDefinitions>
<ComboBox Name="comboBoxAgency" Grid.Column="3" Grid.Row="1" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id" SelectionChanged="comboBoxAgency_SelectionChanged">
<ComboBox Name="comboBoxArrivalBerth" Grid.Column="0" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearValue}" Name="contextMenuItemArrivalBerth" Click="contextMenuItemArrivalBerth_Click" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<ComboBox Name="comboBoxDepartureBerth" Grid.Column="1" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearValue}" Name="contextMenuItemDepartureBerth" Click="contextMenuItemDepartureBerth_Click" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
</Grid>
<Label Content="{x:Static p:Resources.textAgency}" Grid.Column="2" Grid.Row="4" HorizontalContentAlignment="Right"/>
<ComboBox Name="comboBoxAgency" Grid.Column="3" Grid.Row="4" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id" SelectionChanged="comboBoxAgency_SelectionChanged">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearAssignment}" Name="contextMenuItemClearAgency" Click="contextMenuItemClearAgency_Click" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<ComboBox Name="comboBoxMooring" Grid.Column="3" Grid.Row="2" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearAssignment}" Name="contextMenuItemClearMooring" Click="contextMenuItemClearMooring_Click" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<ComboBox Name="comboBoxPilot" Grid.Column="3" Grid.Row="3" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearAssignment}" Name="contextMenuItemClearPilot" Click="contextMenuItemClearPilot_Click" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<ComboBox Name="comboBoxTug" Grid.Column="3" Grid.Row="4" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearAssignment}" Name="contextMenuItemClearTug" Click="contextMenuItemClearTug_Click" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<ComboBox Name="comboBoxTerminal" Grid.Column="3" Grid.Row="5" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearAssignment}" Name="contextMenuItemClearTerminal" Click="contextMenuItemClearTerminal_Click" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<xctk:DateTimePicker Name="datePickerTidalWindowFrom" Grid.Column="3" Grid.Row="7" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/>
<xctk:DateTimePicker Name="datePickerTidalWindowTo" Grid.Column="3" Grid.Row="8" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/>
<CheckBox x:Name="checkBoxRainsensitiveCargo" Grid.Column="2" Grid.Row="9" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,4,0" />
<xctk:IntegerUpDown x:Name="integerUpDownRecommendedTugs" Grid.Column="3" Grid.Row="10" Minimum="0" Margin="2" />
<CheckBox x:Name="checkBoxAnchored" Grid.Column="2" Grid.Row="11" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,4,0" />
<CheckBox x:Name="checkBoxMooredLock" Grid.Column="2" Grid.Row="12" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,4,0" />
<CheckBox x:Name="checkBoxCanceled" Grid.Column="2" Grid.Row="13" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,4,0" />
<Label x:Name="labelBSMDGranted" Grid.Row="14" Grid.Column="1" Grid.ColumnSpan="2" Content="{x:Static p:Resources.textBSMDGranted}" Visibility="Hidden" FontWeight="DemiBold" />
<StackPanel Grid.Row="14" Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Right">

View File

@ -26,21 +26,6 @@ namespace BreCalClient
public ShipcallControlModel ShipcallModel { get; set; } = new ();
/// <summary>
/// All participants
/// </summary>
public List<Participant> Participants { get; set; } = new();
/// <summary>
/// All berths
/// </summary>
public List<Berth> Berths { get; set; } = new();
/// <summary>
/// All ships
/// </summary>
public List<Ship> Ships { get; set; } = new();
public Ship? SelectedShip {
get
{
@ -54,31 +39,12 @@ namespace BreCalClient
private void Window_Loaded(object sender, RoutedEventArgs e)
{
List<Participant> aList = new();
List<Participant> mList = new();
List<Participant> pList = new();
List<Participant> tList = new();
List<Participant> terList = new();
this.comboBoxAgency.ItemsSource = BreCalLists.Participants_Agent;
foreach(Participant p in Participants)
{
if (p.IsTypeFlagSet(Extensions.ParticipantType.AGENCY)) aList.Add(p);
if (p.IsTypeFlagSet(Extensions.ParticipantType.MOORING)) mList.Add(p);
if (p.IsTypeFlagSet(Extensions.ParticipantType.PILOT)) pList.Add(p);
if (p.IsTypeFlagSet(Extensions.ParticipantType.TUG)) tList.Add(p);
if (p.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL)) terList.Add(p);
}
this.comboBoxAgency.ItemsSource = aList;
this.comboBoxMooring.ItemsSource = mList;
this.comboBoxPilot.ItemsSource = pList;
this.comboBoxTug.ItemsSource = tList;
this.comboBoxTerminal.ItemsSource = terList;
this.comboBoxShip.ItemsSource = Ships;
this.comboBoxShip.ItemsSource = BreCalLists.Ships;
this.comboBoxCategories.ItemsSource = Enum.GetValues(typeof(Extensions.TypeEnum));
this.comboBoxArrivalBerth.ItemsSource = this.Berths;
this.comboBoxDepartureBerth.ItemsSource = this.Berths;
this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
if (this.ShipcallModel.Shipcall == null) this.ShipcallModel.Shipcall = new();
this.CopyToControls();
@ -102,6 +68,21 @@ namespace BreCalClient
private void comboBoxShip_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
this.buttonOK.IsEnabled = this.comboBoxShip.SelectedItem != null;
if (this.comboBoxShip.SelectedItem != null)
{
Ship? ship = this.comboBoxShip.SelectedItem as Ship;
this.integerUpDownIMO.Value = ship?.Imo;
this.textBoxCallsign.Text = ship?.Callsign;
this.doubleUpDownLength.Value = ship?.Length;
this.doubleUpDownWidth.Value = ship?.Width;
}
else
{
this.integerUpDownIMO.Value = null;
this.textBoxCallsign.Text = string.Empty;
this.doubleUpDownLength.Value = null;
this.doubleUpDownWidth.Value = null;
}
}
private void comboBoxAgency_SelectionChanged(object sender, SelectionChangedEventArgs e)
@ -117,31 +98,7 @@ namespace BreCalClient
{
this.comboBoxAgency.SelectedIndex = -1;
this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.AGENCY);
}
private void contextMenuItemClearMooring_Click(object sender, RoutedEventArgs e)
{
this.comboBoxMooring.SelectedIndex = -1;
this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.MOORING);
}
private void contextMenuItemClearPilot_Click(object sender, RoutedEventArgs e)
{
this.comboBoxPilot.SelectedIndex = -1;
this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.PILOT);
}
private void contextMenuItemClearTug_Click(object sender, RoutedEventArgs e)
{
this.comboBoxTug.SelectedIndex = -1;
this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.TUG);
}
private void contextMenuItemClearTerminal_Click(object sender, RoutedEventArgs e)
{
this.comboBoxTerminal.SelectedIndex = -1;
this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.TERMINAL);
}
}
private void contextMenuItemArrivalBerth_Click(object sender, RoutedEventArgs e)
{
@ -154,6 +111,31 @@ namespace BreCalClient
this.comboBoxDepartureBerth.SelectedIndex -= 1;
}
private void comboBoxCategories_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
TypeEnum? type = this.comboBoxCategories.SelectedItem as TypeEnum?;
if(type != null)
{
switch (type)
{
case TypeEnum.Incoming:
this.datePickerETA.IsEnabled = true;
this.datePickerETD.IsEnabled = false;
this.datePickerETD.Value = null;
break;
case TypeEnum.Outgoing:
this.datePickerETA.IsEnabled = false;
this.datePickerETD.IsEnabled = true;
this.datePickerETA.Value = null;
break;
case TypeEnum.Shifting:
this.datePickerETA.IsEnabled = true;
this.datePickerETD.IsEnabled = true;
break;
}
}
}
#endregion
#region private methods
@ -163,30 +145,15 @@ namespace BreCalClient
if (this.ShipcallModel.Shipcall != null)
{
this.ShipcallModel.Shipcall.Type = (int)this.comboBoxCategories.SelectedItem;
this.ShipcallModel.Shipcall.Eta = this.datePickerETA.Value ?? DateTime.Now;
this.ShipcallModel.Shipcall.Voyage = this.textBoxVoyage.Text.Trim();
this.ShipcallModel.Shipcall.Eta = this.datePickerETA.Value ?? DateTime.Now;
this.ShipcallModel.Shipcall.Etd = this.datePickerETD.Value ?? DateTime.Now.AddDays(1);
this.ShipcallModel.Shipcall.Anchored = this.checkBoxAnchored.IsChecked;
this.ShipcallModel.Shipcall.ShipId = ((Ship)this.comboBoxShip.SelectedItem).Id;
this.ShipcallModel.Ship = (Ship)this.comboBoxShip.SelectedItem;
this.ShipcallModel.Shipcall.ArrivalBerthId = (this.comboBoxArrivalBerth.SelectedItem != null) ? ((Berth)this.comboBoxArrivalBerth.SelectedItem).Id : null;
this.ShipcallModel.Shipcall.DepartureBerthId = (this.comboBoxDepartureBerth.SelectedItem != null) ? ((Berth)this.comboBoxDepartureBerth.SelectedItem).Id : null;
this.ShipcallModel.Shipcall.Bunkering = this.checkBoxBunkering.IsChecked;
this.ShipcallModel.Shipcall.Canceled = this.checkBoxCanceled.IsChecked;
this.ShipcallModel.Shipcall.Draft = (float?)this.doubleUpDownDraft.Value;
this.ShipcallModel.Shipcall.MooredLock = this.checkBoxMooredLock.IsChecked;
this.ShipcallModel.Shipcall.RainSensitiveCargo = this.checkBoxRainsensitiveCargo.IsChecked;
this.ShipcallModel.Shipcall.PilotRequired = this.checkBoxPilotRequired.IsChecked;
this.ShipcallModel.Shipcall.ReplenishingLock = this.checkBoxReplenishingLock.IsChecked;
this.ShipcallModel.Shipcall.ReplenishingTerminal = this.checkBoxReplenishingTerminal.IsChecked;
this.ShipcallModel.Shipcall.RecommendedTugs = this.integerUpDownRecommendedTugs.Value;
this.ShipcallModel.Shipcall.TidalWindowFrom = this.datePickerTidalWindowFrom.Value;
this.ShipcallModel.Shipcall.TidalWindowTo = this.datePickerTidalWindowTo.Value;
this.ShipcallModel.Shipcall.TugRequired = this.checkBoxTugRequired.IsChecked;
if (this.comboBoxPierside.SelectedIndex >= 0)
{
this.ShipcallModel.Shipcall.PierSide = (this.comboBoxPierside.SelectedIndex == 0) ? true : false;
}
// remove all and add selected participants
this.ShipcallModel.Shipcall.Participants.Clear();
@ -199,31 +166,9 @@ namespace BreCalClient
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.AGENCY] = participant;
}
participant = (Participant?)this.comboBoxMooring.SelectedItem;
if (participant != null)
{
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.MOORING] = participant;
}
participant = (Participant?)this.comboBoxPilot.SelectedItem;
if (participant != null)
{
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PILOT] = participant;
}
participant = (Participant?)this.comboBoxTerminal.SelectedItem;
if (participant != null) {
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TERMINAL] = participant;
}
participant = (Participant?)this.comboBoxTug.SelectedItem;
if (participant != null) {
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TUG] = participant;
}
// BSMD and port authority are always added
foreach (Participant p in Participants)
foreach (Participant p in BreCalLists.Participants)
{
if (p.Type == (int)Extensions.ParticipantType.PORT_ADMINISTRATION)
{
@ -247,43 +192,17 @@ namespace BreCalClient
this.comboBoxCategories.SelectedItem = (Extensions.TypeEnum)this.ShipcallModel.Shipcall.Type;
if (this.ShipcallModel.Shipcall.Eta != DateTime.MinValue)
this.datePickerETA.Value = this.ShipcallModel.Shipcall.Eta;
this.textBoxVoyage.Text = this.ShipcallModel.Shipcall.Voyage;
this.datePickerETD.Value = this.ShipcallModel.Shipcall.Etd;
this.checkBoxAnchored.IsChecked = this.ShipcallModel.Shipcall.Anchored;
// this.textBoxVoyage.Text = this.ShipcallModel.Shipcall.Voyage;
this.datePickerETD.Value = this.ShipcallModel.Shipcall.Etd;
this.comboBoxShip.SelectedValue = this.ShipcallModel.Shipcall.ShipId;
this.comboBoxArrivalBerth.SelectedValue = this.ShipcallModel.Shipcall.ArrivalBerthId;
this.comboBoxDepartureBerth.SelectedValue = this.ShipcallModel.Shipcall.DepartureBerthId;
this.checkBoxBunkering.IsChecked = this.ShipcallModel.Shipcall.Bunkering;
this.checkBoxCanceled.IsChecked = this.ShipcallModel.Shipcall.Canceled;
this.doubleUpDownDraft.Value = this.ShipcallModel.Shipcall.Draft;
this.checkBoxMooredLock.IsChecked = this.ShipcallModel.Shipcall.MooredLock;
this.checkBoxRainsensitiveCargo.IsChecked = this.ShipcallModel.Shipcall.RainSensitiveCargo;
this.checkBoxPilotRequired.IsChecked = this.ShipcallModel.Shipcall.PilotRequired;
this.checkBoxReplenishingLock.IsChecked = this.ShipcallModel.Shipcall.ReplenishingLock;
this.checkBoxReplenishingTerminal.IsChecked = this.ShipcallModel.Shipcall.ReplenishingTerminal;
this.integerUpDownRecommendedTugs.Value = this.ShipcallModel.Shipcall.RecommendedTugs;
this.datePickerTidalWindowFrom.Value = this.ShipcallModel.Shipcall.TidalWindowFrom;
this.datePickerTidalWindowTo.Value = this.ShipcallModel.Shipcall.TidalWindowTo;
this.checkBoxTugRequired.IsChecked = this.ShipcallModel.Shipcall.TugRequired;
if (this.ShipcallModel.Shipcall.PierSide.HasValue)
{
if (this.ShipcallModel.Shipcall.PierSide.Value) this.comboBoxPierside.SelectedIndex = 0;
else this.comboBoxPierside.SelectedIndex = 1;
}
if (this.ShipcallModel.Shipcall.Participants == null) this.ShipcallModel.Shipcall.Participants = new();
// Hier wird noch ein Problem vergessen: Wenn ein Participant mehrere Types gleichzeitig ist und es einen weitere Participant mit diesem Type gibt
// müsste der "einzelne" Participant für die Rolle ausgewählt werden. (Angenommen ein Test-Teilnehmer hat "alle" Rollen..)
foreach (int participant_id in this.ShipcallModel.Shipcall.Participants)
{
if (((List<Participant>)this.comboBoxAgency.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxAgency.SelectedValue = participant_id;
if (((List<Participant>)this.comboBoxMooring.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxMooring.SelectedValue = participant_id;
if (((List<Participant>)this.comboBoxPilot.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxPilot.SelectedValue = participant_id;
if (((List<Participant>)this.comboBoxTerminal.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTerminal.SelectedValue = participant_id;
if (((List<Participant>)this.comboBoxTug.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTug.SelectedValue = participant_id;
}
}
}
@ -299,7 +218,7 @@ namespace BreCalClient
if (this.comboBoxAgency.SelectedIndex >= 0)
{
int agencyParticipantId = (int)this.comboBoxAgency.SelectedValue;
Participant? p = this.Participants.Find(x => x.Id == agencyParticipantId);
Participant? p = BreCalLists.Participants.Find(x => x.Id == agencyParticipantId);
if (p != null)
{
if(p.IsFlagSet(ParticipantFlag.ALLOW_BSMD) && isBsmd)
@ -312,30 +231,11 @@ namespace BreCalClient
this.comboBoxAgency.IsEnabled = isBsmd;
this.comboBoxArrivalBerth.IsEnabled = isBsmd || isAgency;
this.comboBoxCategories.IsEnabled = isBsmd;
this.comboBoxDepartureBerth.IsEnabled = isBsmd || isAgency;
this.checkBoxAnchored.IsEnabled = isAgency;
this.checkBoxBunkering.IsEnabled = isAgency;
this.checkBoxCanceled.IsEnabled = isBsmd || isAgency;
this.checkBoxMooredLock.IsEnabled = isAgency;
this.checkBoxPilotRequired.IsEnabled = isAgency;
this.checkBoxRainsensitiveCargo.IsEnabled = isAgency;
this.checkBoxReplenishingLock.IsEnabled = isAgency;
this.checkBoxReplenishingTerminal.IsEnabled = isAgency;
this.checkBoxTugRequired.IsEnabled = isAgency;
this.comboBoxMooring.IsEnabled = isBsmd;
this.comboBoxPierside.IsEnabled = isAgency;
this.comboBoxPilot.IsEnabled = isAgency;
this.comboBoxShip.IsEnabled = isBsmd;
this.comboBoxMooring.IsEnabled = isAgency;
this.comboBoxTerminal.IsEnabled = isAgency;
this.comboBoxTug.IsEnabled = isAgency;
this.comboBoxDepartureBerth.IsEnabled = isBsmd || isAgency;
this.comboBoxShip.IsEnabled = isBsmd;
this.datePickerETA.IsEnabled = isAgency || isBsmd;
this.datePickerETD.IsEnabled = isAgency;
this.textBoxVoyage.IsEnabled = isAgency;
this.datePickerTidalWindowFrom.IsEnabled = isAgency;
this.datePickerTidalWindowTo.IsEnabled = isAgency;
this.integerUpDownRecommendedTugs.IsEnabled = isAgency;
this.doubleUpDownDraft.IsEnabled = isAgency || isBsmd;
this.labelBSMDGranted.Visibility = editRightGrantedForBSMD ? Visibility.Visible : Visibility.Hidden;
}

View File

@ -8,7 +8,7 @@
xmlns:db="clr-namespace:BreCalClient;assembly=BreCalClient"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="{x:Static p:Resources.textEditShipcall}" Height="366" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico">
Title="{x:Static p:Resources.textEditShipcall}" Height="375" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico">
<Window.Resources>
<local:BoolToIndexConverter x:Key="boolToIndexConverter" />
</Window.Resources>

View File

@ -1,10 +1,12 @@
// Copyright (c) 2023 schick Informatik
// Description:
// Description: Input control for incoming shipcalls
//
using BreCalClient.misc.Model;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -22,7 +24,7 @@ namespace BreCalClient
/// <summary>
/// Interaction logic for EditTimesAgencyIncomingControl.xaml
/// </summary>
public partial class EditTimesAgencyIncomingControl : Window
public partial class EditTimesAgencyIncomingControl : Window, IEditShipcallTimesControl
{
#region Construction
@ -39,13 +41,24 @@ namespace BreCalClient
public Times Times { get; set; } = new();
/// <summary>
/// All berths
/// </summary>
public List<Berth> Berths { get; set; } = new();
#endregion
#region event handler
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.comboBoxMooring.ItemsSource = BreCalLists.Participants_Mooring;
this.comboBoxPilot.ItemsSource = BreCalLists.Participants_Pilot;
this.comboBoxTug.ItemsSource = BreCalLists.Participants_Tug;
this.comboBoxTerminal.ItemsSource = BreCalLists.Participants_Terminal;
this.comboBoxArrivalBerth.ItemsSource = this.Berths;
this.CopyToControls();
}
private void buttonOK_Click(object sender, RoutedEventArgs e)
@ -67,39 +80,137 @@ namespace BreCalClient
private void CopyToModel()
{
if (this.ShipcallModel.Shipcall != null)
{
this.Times.EtaBerth = this.datePickerETA.Value;
this.ShipcallModel.Shipcall.ArrivalBerthId = (int) this.comboBoxArrivalBerth.SelectedItem;
if (this.comboBoxPierside.SelectedIndex >= 0)
{
this.ShipcallModel.Shipcall.PierSide = (this.comboBoxPierside.SelectedIndex == 0) ? true : false;
}
this.Times.BerthInfo = this.textBoxBerthRemarks.Text.Trim();
this.ShipcallModel.Shipcall.Draft = (float?)this.doubleUpDownDraft.Value;
this.ShipcallModel.Shipcall.TidalWindowFrom = this.datePickerTidalWindowFrom.Value;
this.ShipcallModel.Shipcall.TidalWindowTo = this.datePickerTidalWindowTo.Value;
this.ShipcallModel.Shipcall.Canceled = this.checkBoxCanceled.IsChecked;
this.ShipcallModel.Shipcall.Anchored = this.checkBoxAnchored.IsChecked;
this.ShipcallModel.Shipcall.TugRequired = this.checkBoxTugRequired.IsChecked;
this.ShipcallModel.Shipcall.RecommendedTugs = this.integerUpDownRecommendedTugs.Value;
this.ShipcallModel.Shipcall.PilotRequired = this.checkBoxPilotRequired.IsChecked;
this.ShipcallModel.Shipcall.MooredLock = this.checkBoxMooredLock.IsChecked;
this.ShipcallModel.Shipcall.Bunkering = this.checkBoxBunkering.IsChecked;
this.ShipcallModel.Shipcall.ReplenishingTerminal = this.checkBoxReplenishingTerminal.IsChecked;
this.ShipcallModel.Shipcall.ReplenishingLock = this.checkBoxReplenishingLock.IsChecked;
Participant? participant = (Participant?)this.comboBoxMooring.SelectedItem;
if (participant != null)
{
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.MOORING] = participant;
}
participant = (Participant?)this.comboBoxPilot.SelectedItem;
if (participant != null)
{
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PILOT] = participant;
}
participant = (Participant?)this.comboBoxTerminal.SelectedItem;
if (participant != null)
{
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TERMINAL] = participant;
}
participant = (Participant?)this.comboBoxTug.SelectedItem;
if (participant != null)
{
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TUG] = participant;
}
}
}
private void CopyToControls()
{
if (this.ShipcallModel == null) return;
if (this.ShipcallModel.Shipcall != null)
{
if(this.Times.EtaBerth.HasValue)
{
this.datePickerETA.Value = this.Times.EtaBerth.Value;
}
else
{
// if not set through times use value of BSMD entry
if (this.ShipcallModel.Shipcall.Eta != DateTime.MinValue)
this.datePickerETA.Value = this.ShipcallModel.Shipcall.Eta;
}
if (this.ShipcallModel.Shipcall.ArrivalBerthId.HasValue)
this.comboBoxArrivalBerth.SelectedItem = this.ShipcallModel.Shipcall.ArrivalBerthId;
if (this.ShipcallModel.Shipcall.PierSide.HasValue)
{
if (this.ShipcallModel.Shipcall.PierSide.Value) this.comboBoxPierside.SelectedIndex = 0;
else this.comboBoxPierside.SelectedIndex = 1;
}
this.textBoxBerthRemarks.Text = this.Times.BerthInfo;
this.doubleUpDownDraft.Value = this.ShipcallModel.Shipcall.Draft;
this.datePickerTidalWindowFrom.Value = this.ShipcallModel.Shipcall.TidalWindowFrom;
this.datePickerTidalWindowTo.Value = this.ShipcallModel.Shipcall.TidalWindowTo;
this.checkBoxCanceled.IsChecked = this.ShipcallModel.Shipcall.Canceled;
this.checkBoxAnchored.IsChecked = this.ShipcallModel.Shipcall.Anchored;
this.checkBoxTugRequired.IsChecked = this.ShipcallModel.Shipcall.TugRequired;
this.integerUpDownRecommendedTugs.Value = this.ShipcallModel.Shipcall.RecommendedTugs;
this.checkBoxPilotRequired.IsChecked = this.ShipcallModel.Shipcall.PilotRequired;
this.checkBoxMooredLock.IsChecked = this.ShipcallModel.Shipcall.MooredLock;
this.checkBoxBunkering.IsChecked = this.ShipcallModel.Shipcall.Bunkering;
this.checkBoxReplenishingLock.IsChecked = this.ShipcallModel.Shipcall.ReplenishingLock;
this.checkBoxReplenishingTerminal.IsChecked = this.ShipcallModel.Shipcall.ReplenishingTerminal;
foreach (int participant_id in this.ShipcallModel.Shipcall.Participants)
{
if (((List<Participant>)this.comboBoxMooring.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxMooring.SelectedValue = participant_id;
if (((List<Participant>)this.comboBoxPilot.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxPilot.SelectedValue = participant_id;
if (((List<Participant>)this.comboBoxTerminal.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTerminal.SelectedValue = participant_id;
if (((List<Participant>)this.comboBoxTug.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTug.SelectedValue = participant_id;
}
}
}
#endregion
private void contextMenuItemArrivalBerth_Click(object sender, RoutedEventArgs e)
{
this.comboBoxArrivalBerth.SelectedIndex = -1;
this.ShipcallModel.Berth = "";
}
private void contextMenuItemClearTug_Click(object sender, RoutedEventArgs e)
{
this.comboBoxTug.SelectedIndex = -1;
this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.TUG);
}
private void contextMenuItemClearPilot_Click(object sender, RoutedEventArgs e)
{
this.comboBoxPilot.SelectedIndex = -1;
this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.PILOT);
}
private void contextMenuItemClearMooring_Click(object sender, RoutedEventArgs e)
{
this.comboBoxMooring.SelectedIndex = -1;
this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.MOORING);
}
private void contextMenuItemClearTerminal_Click(object sender, RoutedEventArgs e)
{
this.comboBoxTerminal.SelectedIndex = -1;
this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.TERMINAL);
}
}
}

View File

@ -8,7 +8,7 @@
xmlns:db="clr-namespace:BreCalClient;assembly=BreCalClient"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="{x:Static p:Resources.textEditShipcall}" Height="366" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico">
Title="{x:Static p:Resources.textEditShipcall}" Height="375" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.2*"/>

View File

@ -1,5 +1,5 @@
// Copyright (c) 2023 schick Informatik
// Description:
// Description: Input control for outgoing shipcalls
//
using BreCalClient.misc.Model;
@ -22,7 +22,7 @@ namespace BreCalClient
/// <summary>
/// Interaction logic for EditTimesAgencyOutgoingControl.xaml
/// </summary>
public partial class EditTimesAgencyOutgoingControl : Window
public partial class EditTimesAgencyOutgoingControl : Window, IEditShipcallTimesControl
{
#region Construction

View File

@ -8,7 +8,7 @@
xmlns:db="clr-namespace:BreCalClient;assembly=BreCalClient"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="{x:Static p:Resources.textEditShipcall}" Height="534" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico">
Title="{x:Static p:Resources.textEditShipcall}" Height="460" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.2*"/>
@ -32,9 +32,7 @@
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.Column="0">
@ -55,21 +53,15 @@
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<Label Content="{x:Static p:Resources.textPierside}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right" />
<ComboBox x:Name="comboBoxPierside" Grid.Column="1" Grid.Row="3" Margin="2" >
<ComboBoxItem Content="{x:Static p:Resources.textNotRotated}" />
<ComboBoxItem Content="{x:Static p:Resources.textRotated}" />
</ComboBox>
<Label Content="{x:Static p:Resources.textBerthRemarks}" Grid.Column="0" Grid.Row="4" HorizontalContentAlignment="Right" />
<TextBox x:Name="textBoxBerthRemarks" Grid.Column="1" Grid.Row="4" Margin="2" Grid.RowSpan="2" VerticalContentAlignment="Top" />
<Label Content="{x:Static p:Resources.textDraft}" Grid.Column="0" Grid.Row="6" HorizontalContentAlignment="Right" />
<xctk:DoubleUpDown x:Name="doubleUpDownDraft" Grid.Column="1" Grid.Row="6" Margin="2" FormatString="N2" Minimum="0" />
<Label Content="{x:Static p:Resources.textTidalWindow}" FontWeight="DemiBold" Grid.Column="0" Grid.Row="7" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textFrom}" Grid.Column="0" Grid.Row="8" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textTo}" Grid.Column="0" Grid.Row="9" HorizontalContentAlignment="Right"/>
<xctk:DateTimePicker Name="datePickerTidalWindowFrom" Grid.Column="1" Grid.Row="8" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/>
<xctk:DateTimePicker Name="datePickerTidalWindowTo" Grid.Column="1" Grid.Row="9" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/>
<Grid Grid.Row="10" Grid.Column="0">
<Label Content="{x:Static p:Resources.textDraft}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right" />
<xctk:DoubleUpDown x:Name="doubleUpDownDraft" Grid.Column="1" Grid.Row="3" Margin="2" FormatString="N2" Minimum="0" />
<Label Content="{x:Static p:Resources.textTidalWindow}" FontWeight="DemiBold" Grid.Column="0" Grid.Row="4" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textFrom}" Grid.Column="0" Grid.Row="5" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textTo}" Grid.Column="0" Grid.Row="6" HorizontalContentAlignment="Right"/>
<xctk:DateTimePicker Name="datePickerTidalWindowFrom" Grid.Column="1" Grid.Row="5" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/>
<xctk:DateTimePicker Name="datePickerTidalWindowTo" Grid.Column="1" Grid.Row="6" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/>
<Grid Grid.Row="7" Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
@ -77,25 +69,25 @@
<Label Grid.Column="0" Grid.Row="0" Content="{x:Static p:Resources.textShiftingTo}" FontWeight="DemiBold"/>
<Image Margin="2" Grid.Column="1" Source="Resources/arrow_right_green.png" />
</Grid>
<Label Content="ETA" Grid.Column="0" Grid.Row="11" HorizontalContentAlignment="Right"/>
<xctk:DateTimePicker x:Name="datePickerETA" Grid.Column="1" Grid.Row="11" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/>
<Label Content="{x:Static p:Resources.textBerth}" Grid.Column="0" Grid.Row="12" HorizontalContentAlignment="Right"/>
<ComboBox Name="comboBoxArrivalBerth" Grid.Column="1" Grid.Row="2" Margin="12" DisplayMemberPath="Name" SelectedValuePath="Id">
<Label Content="ETA" Grid.Column="0" Grid.Row="8" HorizontalContentAlignment="Right"/>
<xctk:DateTimePicker x:Name="datePickerETA" Grid.Column="1" Grid.Row="8" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/>
<Label Content="{x:Static p:Resources.textBerth}" Grid.Column="0" Grid.Row="9" HorizontalContentAlignment="Right"/>
<ComboBox Name="comboBoxArrivalBerth" Grid.Column="1" Grid.Row="9" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearValue}" Name="contextMenuItemArrivalBerth" Click="contextMenuItemArrivalBerth_Click" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<Label Content="{x:Static p:Resources.textPierside}" Grid.Column="0" Grid.Row="13" HorizontalContentAlignment="Right" />
<ComboBox x:Name="comboBoxPiersideArrival" Grid.Column="1" Grid.Row="13" Margin="2" >
<Label Content="{x:Static p:Resources.textPierside}" Grid.Column="0" Grid.Row="10" HorizontalContentAlignment="Right" />
<ComboBox x:Name="comboBoxPiersideArrival" Grid.Column="1" Grid.Row="10" Margin="2" >
<ComboBoxItem Content="{x:Static p:Resources.textNotRotated}" />
<ComboBoxItem Content="{x:Static p:Resources.textRotated}" />
</ComboBox>
<Label Content="{x:Static p:Resources.textBerthRemarks}" Grid.Column="0" Grid.Row="14" HorizontalContentAlignment="Right" />
<TextBox x:Name="textBoxBerthRemarksArrival" Grid.Column="1" Grid.Row="14" Margin="2" Grid.RowSpan="2" VerticalContentAlignment="Top" />
<Label Content="{x:Static p:Resources.textCancelled}" Grid.Column="0" Grid.Row="16" HorizontalContentAlignment="Right" />
<CheckBox x:Name="checkBoxCanceled" Grid.Column="1" Grid.Row="16" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,4,0" />
<Label Content="{x:Static p:Resources.textBerthRemarks}" Grid.Column="0" Grid.Row="11" HorizontalContentAlignment="Right" />
<TextBox x:Name="textBoxBerthRemarksArrival" Grid.Column="1" Grid.Row="11" Margin="2" Grid.RowSpan="2" VerticalContentAlignment="Top" />
<Label Content="{x:Static p:Resources.textCancelled}" Grid.Column="0" Grid.Row="13" HorizontalContentAlignment="Right" />
<CheckBox x:Name="checkBoxCanceled" Grid.Column="1" Grid.Row="13" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,4,0" />
<Label Content="{x:Static p:Resources.textTugRequired}" Grid.Column="2" Grid.Row="1" HorizontalContentAlignment="Right"/>
@ -153,7 +145,7 @@
<StackPanel Grid.Row="17" Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Right">
<StackPanel Grid.Row="14" Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Width= "80" Margin="2" Content="{x:Static p:Resources.textOK}" x:Name="buttonOK" Click="buttonOK_Click" IsEnabled="False" />
<Button Width="80" Margin="2" Content="{x:Static p:Resources.textCancel}" x:Name="buttonCancel" Click="buttonCancel_Click"/>
</StackPanel>

View File

@ -1,5 +1,5 @@
// Copyright (c) 2023 schick Informatik
// Description:
// Description: Input control for shifting operations
//
using BreCalClient.misc.Model;
@ -23,7 +23,7 @@ namespace BreCalClient
/// <summary>
/// Interaction logic for EditTimesAgencyShiftingControl.xaml
/// </summary>
public partial class EditTimesAgencyShiftingControl : Window
public partial class EditTimesAgencyShiftingControl : Window, IEditShipcallTimesControl
{
#region Construction

View File

@ -1,9 +1,9 @@
using BreCalClient.misc.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// Copyright (c) 2023 schick Informatik
// Description: Interfaces to simplify dialog handling
//
using BreCalClient.misc.Model;
namespace BreCalClient
{
@ -14,4 +14,10 @@ namespace BreCalClient
bool? ShowDialog();
}
internal interface IEditShipcallTimesControl : IEditTimesControl
{
ShipcallControlModel ShipcallModel { get; set; }
}
}

View File

@ -2,19 +2,19 @@
// Description: Bremen calling main window
//
using BreCalClient.misc.Api;
using BreCalClient.misc.Client;
using BreCalClient.misc.Model;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using log4net;
using BreCalClient.misc.Api;
using BreCalClient.misc.Client;
using BreCalClient.misc.Model;
using static BreCalClient.Extensions;
namespace BreCalClient
@ -24,7 +24,7 @@ namespace BreCalClient
/// </summary>
public partial class MainWindow : Window
{
private ILog _log = LogManager.GetLogger(typeof(MainWindow));
private readonly ILog _log = LogManager.GetLogger(typeof(MainWindow));
private const int SHIPCALL_UPDATE_INTERVAL_SECONDS = 30;
@ -33,19 +33,9 @@ namespace BreCalClient
private Timer _timer;
Credentials _credentials;
private readonly Dictionary<int, ShipcallControlModel> _allShipcallsDict = new();
private readonly Dictionary<int, ShipcallControl> _allShipCallsControlDict = new();
private readonly List<ShipcallControlModel> _visibleControlModels = new();
private List<Ship> _ships = new();
private readonly ConcurrentDictionary<int, Ship> _shipLookupDict = new();
private List<Berth> _berths = new();
private readonly ConcurrentDictionary<int, Berth> _berthLookupDict = new();
private List<Participant> _participants = new();
private readonly Dictionary<int, Participant> _participantLookupDict = new();
private readonly List<ShipcallControlModel> _visibleControlModels = new();
private readonly DefaultApi _api;
private readonly CancellationTokenSource _tokenSource = new();
@ -173,12 +163,7 @@ namespace BreCalClient
private void buttonNew_Click(object sender, RoutedEventArgs e)
{
EditShipcallControl esc = new()
{
Participants = this._participants,
Ships = this._ships,
Berths = this._berths
};
EditShipcallControl esc = new();
if (esc.ShowDialog() ?? false)
{
@ -261,28 +246,22 @@ namespace BreCalClient
private async void LoadStaticLists()
{
this._berths = await _api.BerthsGetAsync();
foreach(var berth in this._berths)
_berthLookupDict[berth.Id] = berth;
this.searchFilterControl.SetBerths(this._berths);
this._ships = await _api.ShipsGetAsync();
foreach(var ship in this._ships)
_shipLookupDict[ship.Id] = ship;
this._participants = await _api.ParticipantsGetAsync();
BreCalLists.InitializeBerths(await _api.BerthsGetAsync());
BreCalLists.InitializeShips(await _api.ShipsGetAsync());
BreCalLists.InitializeParticipants(await _api.ParticipantsGetAsync());
List<Participant> agencies = new();
foreach (Participant participant in this._participants)
{
this._participantLookupDict[participant.Id] = participant;
this.searchFilterControl.SetBerths(BreCalLists.Berths);
foreach (Participant participant in BreCalLists.Participants)
{
if (_loginResult?.ParticipantId == participant.Id)
{
App.Participant = participant;
EnableControlsForParticipant();
}
if(participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY))
agencies.Add(participant);
}
}
this.searchFilterControl.SetAgencies(agencies);
this.searchFilterControl.SetAgencies(BreCalLists.Participants_Agent);
if (!string.IsNullOrEmpty(Properties.Settings.Default.FilterCriteria))
{
@ -376,37 +355,36 @@ namespace BreCalClient
_allShipcallsDict[scm.Shipcall.Id] = scm;
Shipcall shipcall = scm.Shipcall;
if (this._shipLookupDict.ContainsKey(shipcall.ShipId))
scm.Ship = this._shipLookupDict[shipcall.ShipId];
if (this._berthLookupDict.ContainsKey(shipcall.ArrivalBerthId ?? 0))
scm.Berth = this._berthLookupDict[shipcall.ArrivalBerthId ?? 0].Name;
scm.AssignParticipants(this._participants);
if (BreCalLists.ShipLookupDict.ContainsKey(shipcall.ShipId))
scm.Ship = BreCalLists.ShipLookupDict[shipcall.ShipId];
if (BreCalLists.BerthLookupDict.ContainsKey(shipcall.ArrivalBerthId ?? 0))
scm.Berth = BreCalLists.BerthLookupDict[shipcall.ArrivalBerthId ?? 0].Name;
scm.AssignParticipants(BreCalLists.Participants);
this.Dispatcher.Invoke(() =>
{
ShipcallControl sc = new()
{
Height = 120,
ShipcallControlModel = scm,
ParticipantDict = _participantLookupDict,
Berths = _berths
ShipcallControlModel = scm
};
sc.EditTimesRequested += Sc_EditTimesRequested;
sc.EditRequested += Sc_EditRequested;
sc.EditAgencyRequested += Sc_EditAgencyRequested;
sc.RefreshData();
this._allShipCallsControlDict[scm.Shipcall.Id] = sc;
});
}
}
private void UpdateShipcall(ShipcallControlModel scm)
{
if(scm.Shipcall == null) return;
Shipcall shipcall = scm.Shipcall;
if (this._shipLookupDict.ContainsKey(shipcall.ShipId))
scm.Ship = this._shipLookupDict[shipcall.ShipId];
if (this._berthLookupDict.ContainsKey(shipcall.ArrivalBerthId ?? 0))
scm.Berth = this._berthLookupDict[shipcall.ArrivalBerthId ?? 0].Name;
scm.AssignParticipants(this._participants);
if (BreCalLists.ShipLookupDict.ContainsKey(shipcall.ShipId))
scm.Ship = BreCalLists.ShipLookupDict[shipcall.ShipId];
if (BreCalLists.BerthLookupDict.ContainsKey(shipcall.ArrivalBerthId ?? 0))
scm.Berth = BreCalLists.BerthLookupDict[shipcall.ArrivalBerthId ?? 0].Name;
scm.AssignParticipants(BreCalLists.Participants);
}
private void RemoveShipcall(int shipcallId)
@ -440,42 +418,50 @@ namespace BreCalClient
if(sfm.Agencies.Count > 0 )
{
this._visibleControlModels.RemoveAll(x => !sfm.Agencies.Contains((x.GetParticipantIdForType(Extensions.ParticipantType.AGENCY)) ?? -1));
_ = this._visibleControlModels.RemoveAll((x) =>
{
Participant? agency = x.GetParticipantForType(ParticipantType.AGENCY);
if(agency != null)
{
return !sfm.Agencies.Contains(agency.Id);
}
return true;
});
}
if(sfm.Categories.Count > 0 )
{
this._visibleControlModels.RemoveAll(x => !sfm.Categories.Contains((x.Shipcall?.Type) ?? -1));
_ = this._visibleControlModels.RemoveAll(x => !sfm.Categories.Contains((x.Shipcall?.Type) ?? -1));
}
if(!string.IsNullOrEmpty(sfm.SearchString))
{
this._visibleControlModels.RemoveAll(x => !(x.ContainsRemarkText(sfm.SearchString) || (x.Ship?.Name.Contains(sfm.SearchString, StringComparison.InvariantCultureIgnoreCase) ?? false)));
_ = this._visibleControlModels.RemoveAll(x => !(x.ContainsRemarkText(sfm.SearchString) || (x.Ship?.Name.Contains(sfm.SearchString, StringComparison.InvariantCultureIgnoreCase) ?? false)));
}
if(sfm.ShipLengthTo != null)
{
this._visibleControlModels.RemoveAll(x => x.Ship?.Length > sfm.ShipLengthTo);
_ = this._visibleControlModels.RemoveAll(x => x.Ship?.Length > sfm.ShipLengthTo);
}
if(sfm.ShipLengthFrom != null)
{
this._visibleControlModels.RemoveAll(x => x.Ship?.Length < sfm.ShipLengthFrom);
_ = this._visibleControlModels.RemoveAll(x => x.Ship?.Length < sfm.ShipLengthFrom);
}
if(sfm.EtaFrom != null)
{
this._visibleControlModels.RemoveAll(x => x.Shipcall?.Eta < sfm.EtaFrom);
_ = this._visibleControlModels.RemoveAll(x => x.Shipcall?.Eta < sfm.EtaFrom);
}
if(sfm.EtaTo != null)
{
this._visibleControlModels.RemoveAll(x => x.Shipcall?.Eta > sfm.EtaTo);
_ = this._visibleControlModels.RemoveAll(x => x.Shipcall?.Eta > sfm.EtaTo);
}
if(!_showCanceled ?? true) // canceled calls are filtered by default
{
this._visibleControlModels.RemoveAll(x => x.Shipcall?.Canceled ?? false);
_ = this._visibleControlModels.RemoveAll(x => x.Shipcall?.Canceled ?? false);
}
if (this._sortOrder != null)
@ -534,10 +520,7 @@ namespace BreCalClient
{
EditShipcallControl esc = new()
{
ShipcallModel = obj.ShipcallControlModel,
Ships = _ships,
Participants = _participants,
Berths = _berths
ShipcallModel = obj.ShipcallControlModel
};
if(esc.ShowDialog() ?? false)
@ -560,9 +543,7 @@ namespace BreCalClient
private async void Sc_EditTimesRequested(ShipcallControl obj, Times? times, Extensions.ParticipantType participantType)
{
// show a dialog that lets the user create / update times for the given shipcall
IEditTimesControl etc = (participantType == ParticipantType.TERMINAL) ? new EditTimesTerminalControl() : new EditTimesControl();
if (etc is EditTimesTerminalControl ettc)
ettc.Berths = this._berths;
IEditTimesControl etc = (participantType == ParticipantType.TERMINAL) ? new EditTimesTerminalControl() : new EditTimesControl();
bool wasEdit = false;
if (times != null)
@ -602,6 +583,64 @@ namespace BreCalClient
}
}
private async void Sc_EditAgencyRequested(ShipcallControl sc, Times? times)
{
IEditShipcallTimesControl? editControl = null;
switch(sc.ShipcallControlModel?.Shipcall?.Type)
{
case (int)TypeEnum.Incoming:
editControl = new EditTimesAgencyIncomingControl();
break;
case (int)TypeEnum.Outgoing:
editControl = new EditTimesAgencyOutgoingControl();
break;
case (int)TypeEnum.Shifting:
editControl = new EditTimesAgencyShiftingControl();
break;
}
if (editControl != null)
{
editControl.ShipcallModel = sc.ShipcallControlModel ?? new ShipcallControlModel();
bool wasEdit = false;
if (times != null)
{
editControl.Times = times;
wasEdit = true;
}
editControl.Times.ParticipantType = (int)ParticipantType.AGENCY;
if(editControl.ShowDialog() ?? false)
{
try
{
editControl.Times.ParticipantId = App.Participant.Id;
if (wasEdit)
{
await _api.TimesPutAsync(editControl.Times);
}
else
{
if ((sc.ShipcallControlModel != null) && (sc.ShipcallControlModel.Shipcall != null))
{
editControl.Times.ShipcallId = sc.ShipcallControlModel.Shipcall.Id;
}
await _api.TimesPostAsync(editControl.Times);
sc.ShipcallControlModel?.Times.Add(editControl.Times);
}
await _api.ShipcallsPutAsync(editControl.ShipcallModel.Shipcall);
_refreshImmediately = true;
_tokenSource.Cancel();
}
catch(Exception ex)
{
ShowErrorDialog(ex.Message, "Error saving agency information");
}
}
}
}
#endregion
#region helper

View File

@ -478,6 +478,15 @@ namespace BreCalClient.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Length.
/// </summary>
public static string textLength {
get {
return ResourceManager.GetString("textLength", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to L/W.
/// </summary>
@ -865,6 +874,15 @@ namespace BreCalClient.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Width.
/// </summary>
public static string textWidth {
get {
return ResourceManager.GetString("textWidth", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Zone entry.
/// </summary>

View File

@ -394,10 +394,16 @@
<data name="textShifting" xml:space="preserve">
<value>Verholung</value>
</data>
<data name="textLength" xml:space="preserve">
<value>Länge</value>
</data>
<data name="textShiftingFrom" xml:space="preserve">
<value>Verholung von</value>
</data>
<data name="textShiftingTo" xml:space="preserve">
<value>Verholung nach</value>
</data>
<data name="textWidth" xml:space="preserve">
<value>Breite</value>
</data>
</root>

View File

@ -253,6 +253,9 @@
<data name="textInterval" xml:space="preserve">
<value>Interval</value>
</data>
<data name="textLength" xml:space="preserve">
<value>Length</value>
</data>
<data name="textLengthWidth" xml:space="preserve">
<value>L/W</value>
</data>
@ -382,6 +385,9 @@
<data name="textVoyage" xml:space="preserve">
<value>Voyage</value>
</data>
<data name="textWidth" xml:space="preserve">
<value>Width</value>
</data>
<data name="textZoneEntryTime" xml:space="preserve">
<value>Zone entry</value>
</data>

View File

@ -4,8 +4,6 @@
using BreCalClient.misc.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
@ -19,6 +17,16 @@ namespace BreCalClient
/// </summary>
public partial class ShipcallControl : UserControl
{
#region Fields
Participant? _agency;
Participant? _pilot;
Participant? _mooring;
Participant? _terminal;
Participant? _tug;
Participant? _port_administration;
#endregion
#region Construction
@ -33,6 +41,8 @@ namespace BreCalClient
public event Action<ShipcallControl>? EditRequested;
public event Action<ShipcallControl, Times?>? EditAgencyRequested;
internal event Action<ShipcallControl, Times?, Extensions.ParticipantType>? EditTimesRequested;
#endregion
@ -42,17 +52,7 @@ namespace BreCalClient
/// <summary>
/// this is our datasource
/// </summary>
public ShipcallControlModel? ShipcallControlModel { get; set; }
/// <summary>
/// these are all participants (currently loaded)
/// </summary>
public Dictionary<int, Participant>? ParticipantDict { get; set; }
/// <summary>
/// For berth name lookup
/// </summary>
public List<Berth>? Berths {get; set;}
public ShipcallControlModel? ShipcallControlModel { get; set; }
#endregion
@ -63,57 +63,69 @@ namespace BreCalClient
if (this.ShipcallControlModel == null) return;
string agentName = "";
string? name;
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.AGENCY);
_agency = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.AGENCY);
name = _agency?.Name;
if (name != null) agentName = name;
this.labelAgent.Content = name ?? "- / -";
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.MOORING);
_mooring = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.MOORING);
name = _mooring?.Name;
this.labelMooring.Content = name ?? "- / -";
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.PILOT);
_pilot = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.PILOT);
name = _pilot?.Name;
this.labelPilot.Content = name ?? "- / - ";
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.TUG);
_tug = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.TUG);
name = _tug?.Name;
this.labelTug.Content = name ?? "- / - ";
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.PORT_ADMINISTRATION);
_port_administration = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.PORT_ADMINISTRATION);
name = _port_administration?.Name;
this.labelPortAuthority.Content = name ?? "- / - ";
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.TERMINAL);
_terminal = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.TERMINAL);
name = _terminal?.Name;
this.labelTerminal.Content = name ?? "- / - ";
if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.TERMINAL)))
if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL) && (App.Participant.Id == _terminal?.Id))
{
this.labelTerminal.FontWeight = FontWeights.Bold;
this.labelTerminal.Foreground = Brushes.LightYellow;
}
if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PILOT) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.PILOT)))
if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PILOT) && (App.Participant.Id == _pilot?.Id))
{
this.labelPilot.FontWeight = FontWeights.Bold;
this.labelPilot.Foreground = Brushes.LightYellow;
}
if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.AGENCY)))
if((App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == _agency?.Id)) ||
(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD) && (_agency != null) && _agency.IsFlagSet(Extensions.ParticipantFlag.ALLOW_BSMD)))
{
this.labelAgent.FontWeight = FontWeights.Bold;
this.labelAgent.Foreground = Brushes.LightYellow;
}
if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.MOORING) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.MOORING)))
if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.MOORING) && (App.Participant.Id == _mooring?.Id))
{
this.labelMooring.FontWeight = FontWeights.Bold;
this.labelMooring.Foreground = Brushes.LightYellow;
}
if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.PORT_ADMINISTRATION)))
if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION) && (App.Participant.Id == _port_administration?.Id))
{
this.labelPortAuthority.FontWeight = FontWeights.Bold;
this.labelPortAuthority.Foreground = Brushes.LightYellow;
}
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TUG) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.TUG)))
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TUG) && (App.Participant.Id == _tug?.Id))
{
this.labelTug.FontWeight = FontWeights.Bold;
this.labelTug.Foreground = Brushes.LightYellow;
}
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD) ||
(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.AGENCY))))
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD))
{
this.labelShipName.FontWeight = FontWeights.Bold;
this.labelShipName.Foreground = Brushes.LightYellow;
@ -151,56 +163,54 @@ namespace BreCalClient
this.textBlockLengthWidth.Text = $"{this.ShipcallControlModel?.Ship?.Length} / {this.ShipcallControlModel?.Ship?.Width}";
this.textBlockAgency.Text = agentName.TruncateDots(10);
if (this.ParticipantDict != null)
if (this.ShipcallControlModel != null)
{
if (this.ShipcallControlModel != null)
{
foreach (Times times in this.ShipcallControlModel.Times)
{
if (times.ParticipantType == (int)Extensions.ParticipantType.AGENCY)
{
this.labelAgencyETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.labelAgencyETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockAgencyRemarks.Text = times.Remarks;
}
if (times.ParticipantType == (int) Extensions.ParticipantType.MOORING)
{
this.labelMooringETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.labelMooringETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockMooringRemarks.Text = times.Remarks;
}
if (times.ParticipantType == (int)Extensions.ParticipantType.PORT_ADMINISTRATION)
{
this.labelPortAuthorityETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.labelPortAuthorityETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockPortAuthorityRemarks.Text = times.Remarks;
}
if (times.ParticipantType == (int)Extensions.ParticipantType.PILOT)
{
this.labelPilotETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.labelPilotETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockPilotRemarks.Text = times.Remarks;
}
if (times.ParticipantType == (int)Extensions.ParticipantType.TUG)
{
this.labelTugETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.labelTugETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockTugRemarks.Text = times.Remarks;
}
if (times.ParticipantType == (int)Extensions.ParticipantType.TERMINAL)
{
if (this.Berths != null)
{
Berth? berth = this.Berths.Find((x) => x.Id == times.BerthId);
this.labelTerminalBerth.Content = (berth != null) ? berth.Name : "";
}
this.labelOperationsStart.Content = times.OperationsStart.HasValue ? times.OperationsStart.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.labelOperationsEnd.Content = times.OperationsEnd.HasValue ? times.OperationsEnd.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockTerminalRemarks.Text = times.Remarks;
}
foreach (Times times in this.ShipcallControlModel.Times)
{
if (times.ParticipantType == (int)Extensions.ParticipantType.AGENCY)
{
this.labelAgencyETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.labelAgencyETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockAgencyRemarks.Text = times.Remarks;
}
if (times.ParticipantType == (int) Extensions.ParticipantType.MOORING)
{
this.labelMooringETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.labelMooringETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockMooringRemarks.Text = times.Remarks;
}
if (times.ParticipantType == (int)Extensions.ParticipantType.PORT_ADMINISTRATION)
{
this.labelPortAuthorityETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.labelPortAuthorityETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockPortAuthorityRemarks.Text = times.Remarks;
}
if (times.ParticipantType == (int)Extensions.ParticipantType.PILOT)
{
this.labelPilotETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.labelPilotETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockPilotRemarks.Text = times.Remarks;
}
if (times.ParticipantType == (int)Extensions.ParticipantType.TUG)
{
this.labelTugETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.labelTugETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockTugRemarks.Text = times.Remarks;
}
if (times.ParticipantType == (int)Extensions.ParticipantType.TERMINAL)
{
if (BreCalLists.Berths != null)
{
Berth? berth = BreCalLists.Berths.Find((x) => x.Id == times.BerthId);
this.labelTerminalBerth.Content = (berth != null) ? berth.Name : "";
}
this.labelOperationsStart.Content = times.OperationsStart.HasValue ? times.OperationsStart.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.labelOperationsEnd.Content = times.OperationsEnd.HasValue ? times.OperationsEnd.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockTerminalRemarks.Text = times.Remarks;
}
}
}
}
}
#endregion
@ -214,8 +224,7 @@ namespace BreCalClient
private void buttonEditShipcall_Click(object? sender, RoutedEventArgs? e)
{
if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD) ||
(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.AGENCY))))
if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD))
this.EditRequested?.Invoke(this);
}
@ -226,15 +235,17 @@ namespace BreCalClient
private void labelAgent_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.AGENCY)))
if ((App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == _agency?.Id)) ||
(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD) && (_agency != null) && _agency.IsFlagSet(Extensions.ParticipantFlag.ALLOW_BSMD)))
{
this.EditRequested?.Invoke(this);
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY);
this.EditAgencyRequested?.Invoke(this, times);
}
}
private void labelMooring_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.MOORING) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.MOORING)))
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.MOORING) && (App.Participant.Id == _mooring?.Id))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.MOORING);
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.MOORING);
@ -243,7 +254,7 @@ namespace BreCalClient
private void labelPortAuthority_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.PORT_ADMINISTRATION)))
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION) && (App.Participant.Id == _port_administration?.Id))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PORT_ADMINISTRATION);
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.PORT_ADMINISTRATION);
@ -252,7 +263,7 @@ namespace BreCalClient
private void labelPilot_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PILOT) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.PILOT)))
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PILOT) && (App.Participant.Id == _pilot?.Id))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PILOT);
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.PILOT);
@ -261,7 +272,7 @@ namespace BreCalClient
private void labelTug_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TUG) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.TUG)))
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TUG) && (App.Participant.Id == _tug?.Id))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.TUG);
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.TUG);
@ -270,7 +281,7 @@ namespace BreCalClient
private void labelTerminal_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.TERMINAL)))
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL) && (App.Participant.Id == _terminal?.Id))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.TERMINAL);
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.TERMINAL);

View File

@ -131,25 +131,15 @@ namespace BreCalClient
#region helper
internal string? GetParticipantNameForType(Extensions.ParticipantType participantType)
internal Participant? GetParticipantForType(Extensions.ParticipantType participantType)
{
foreach(Participant p in AssignedParticipants.Values)
{
if (p.IsTypeFlagSet(participantType))
return p.Name;
return p;
}
return null;
}
internal int? GetParticipantIdForType(Extensions.ParticipantType participantType)
{
foreach(Participant p in AssignedParticipants.Values)
{
if(p.IsTypeFlagSet(participantType))
return p.Id;
}
return null;
}
}
private bool IsFlagSet(StatusFlags flag)
{