277 lines
13 KiB
C#
277 lines
13 KiB
C#
// Copyright (c) 2023 schick Informatik
|
|
// Description: Show general shipcall info
|
|
//
|
|
|
|
using BreCalClient.misc.Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
|
|
namespace BreCalClient
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for ShipcallControl.xaml
|
|
/// </summary>
|
|
public partial class ShipcallControl : UserControl
|
|
{
|
|
|
|
#region Construction
|
|
|
|
public ShipcallControl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region events
|
|
|
|
public event Action<ShipcallControl>? EditRequested;
|
|
|
|
public event Action<ShipcallControl, Times?>? EditTimesRequested;
|
|
|
|
public event Action<ShipcallControl>? OpenExtraRequested;
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
/// <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; }
|
|
|
|
#endregion
|
|
|
|
#region public methods
|
|
|
|
public void RefreshData()
|
|
{
|
|
if (this.ShipcallControlModel == null) return;
|
|
string agentName = "";
|
|
string? name;
|
|
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.AGENCY);
|
|
if (name != null)
|
|
{
|
|
this.labelAgent.Content = name;
|
|
agentName = name;
|
|
}
|
|
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.MOORING);
|
|
if (name != null)
|
|
this.labelMooring.Content = name;
|
|
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.PILOT);
|
|
if (name != null)
|
|
this.labelPilot.Content = name;
|
|
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.TUG);
|
|
if (name != null)
|
|
this.labelTug.Content = name;
|
|
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.PORT_ADMINISTRATION);
|
|
if (name != null)
|
|
this.labelPortAuthority.Content = name;
|
|
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.TERMINAL);
|
|
if (name != null)
|
|
this.labelTerminal.Content = name;
|
|
|
|
if(App.Participant.IsFlagSet(Extensions.ParticipantType.TERMINAL)) {
|
|
this.labelTerminal.FontWeight = FontWeights.Bold;
|
|
this.labelTerminal.Foreground = Brushes.LightYellow;
|
|
}
|
|
if(App.Participant.IsFlagSet(Extensions.ParticipantType.PILOT))
|
|
{
|
|
this.labelPilot.FontWeight = FontWeights.Bold;
|
|
this.labelPilot.Foreground = Brushes.LightYellow;
|
|
}
|
|
if(App.Participant.IsFlagSet(Extensions.ParticipantType.AGENCY))
|
|
{
|
|
this.labelAgent.FontWeight = FontWeights.Bold;
|
|
this.labelAgent.Foreground = Brushes.LightYellow;
|
|
}
|
|
if(App.Participant.IsFlagSet(Extensions.ParticipantType.MOORING))
|
|
{
|
|
this.labelMooring.FontWeight = FontWeights.Bold;
|
|
this.labelMooring.Foreground = Brushes.LightYellow;
|
|
}
|
|
if(App.Participant.IsFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION))
|
|
{
|
|
this.labelPortAuthority.FontWeight = FontWeights.Bold;
|
|
this.labelPortAuthority.Foreground = Brushes.LightYellow;
|
|
}
|
|
if (App.Participant.IsFlagSet(Extensions.ParticipantType.TUG))
|
|
{
|
|
this.labelTug.FontWeight = FontWeights.Bold;
|
|
this.labelTug.Foreground = Brushes.LightYellow;
|
|
}
|
|
|
|
this.labelShipName.Content = this.ShipcallControlModel?.Ship?.Name;
|
|
switch(this.ShipcallControlModel?.Shipcall?.Type)
|
|
{
|
|
case 1: // incoming
|
|
this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalClient;component/Resources/arrow_down_red.png"));
|
|
break;
|
|
case 2: // outgoing
|
|
this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalClient;component/Resources/arrow_up_green.png"));
|
|
break;
|
|
case 3: // shifting
|
|
this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalClient;component/Resources/arrow_right_blue.png"));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
this.textBlockAgency.Text = this.ShipcallControlModel?.Agency;
|
|
this.textBlockBerth.Text = this.ShipcallControlModel?.Berth;
|
|
this.textBlockCallsign.Text = this.ShipcallControlModel?.Ship?.Callsign;
|
|
if ((this.ShipcallControlModel?.Shipcall?.Type == 1) || (this.ShipcallControlModel?.Shipcall?.Type == 3))
|
|
{
|
|
this.textBlockETA.Text = this.ShipcallControlModel?.Shipcall?.Eta.ToString("dd.MM. HH:mm");
|
|
}
|
|
if(this.ShipcallControlModel?.Shipcall?.Type == 2)
|
|
{
|
|
this.labelETA.Text = "ETD";
|
|
this.textBlockETA.Text = this.ShipcallControlModel?.Shipcall?.Etd?.ToString("dd.MM. HH:mm");
|
|
}
|
|
|
|
this.textBlockIMO.Text = this.ShipcallControlModel?.Ship?.Imo.ToString();
|
|
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)
|
|
{
|
|
foreach (Times times in this.ShipcallControlModel.Times)
|
|
{
|
|
if(this.ParticipantDict.ContainsKey(times.ParticipantId))
|
|
{
|
|
if (this.ParticipantDict[times.ParticipantId].IsFlagSet(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.textBlockAgency.Text = times.Remarks;
|
|
}
|
|
if (this.ParticipantDict[times.ParticipantId].IsFlagSet(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 (this.ParticipantDict[times.ParticipantId].IsFlagSet(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 (this.ParticipantDict[times.ParticipantId].IsFlagSet(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 (this.ParticipantDict[times.ParticipantId].IsFlagSet(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 (this.ParticipantDict[times.ParticipantId].IsFlagSet(Extensions.ParticipantType.TERMINAL))
|
|
{
|
|
this.labelTerminalETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
|
|
this.labelTerminalETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
|
|
this.textBlockTerminalRemarks.Text = times.Remarks;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region event handler
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void buttonEditShipcall_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.EditRequested?.Invoke(this);
|
|
}
|
|
|
|
private void buttonOpenDropDown_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.OpenExtraRequested?.Invoke(this);
|
|
}
|
|
|
|
private void Image_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
this.EditRequested?.Invoke(this);
|
|
}
|
|
|
|
private void labelAgent_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
if (App.Participant.IsFlagSet(Extensions.ParticipantType.AGENCY))
|
|
{
|
|
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY);
|
|
this.EditTimesRequested?.Invoke(this, times);
|
|
}
|
|
}
|
|
|
|
private void labelMooring_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
if (App.Participant.IsFlagSet(Extensions.ParticipantType.MOORING))
|
|
{
|
|
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.MOORING);
|
|
this.EditTimesRequested?.Invoke(this, times);
|
|
}
|
|
}
|
|
|
|
private void labelPortAuthority_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
if (App.Participant.IsFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION))
|
|
{
|
|
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PORT_ADMINISTRATION);
|
|
this.EditTimesRequested?.Invoke(this, times);
|
|
}
|
|
}
|
|
|
|
private void labelPilot_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
if (App.Participant.IsFlagSet(Extensions.ParticipantType.PILOT))
|
|
{
|
|
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PILOT);
|
|
this.EditTimesRequested?.Invoke(this, times);
|
|
}
|
|
}
|
|
|
|
private void labelTug_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
if (App.Participant.IsFlagSet(Extensions.ParticipantType.TUG))
|
|
{
|
|
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.TUG);
|
|
this.EditTimesRequested?.Invoke(this, times);
|
|
}
|
|
}
|
|
|
|
private void labelTerminal_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
if (App.Participant.IsFlagSet(Extensions.ParticipantType.TERMINAL))
|
|
{
|
|
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.TERMINAL);
|
|
this.EditTimesRequested?.Invoke(this, times);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|