// Copyright (c) 2023 schick Informatik
// Description: Show general shipcall info
//
using System;
using System.Windows;
using System.Windows.Controls;
namespace BreCalClient
{
///
/// Interaction logic for ShipcallControl.xaml
///
public partial class ShipcallControl : UserControl
{
#region Construction
public ShipcallControl()
{
InitializeComponent();
}
#endregion
#region events
public event Action? EditRequested;
public event Action? TimesRequested;
public event Action? OpenExtraRequested;
#endregion
#region Properties
///
/// this is our datasource
///
public ShipcallControlModel? ShipcallControlModel { get; set; }
#endregion
#region public methods
public void RefreshData()
{
if (this.ShipcallControlModel == null) return;
string? name;
name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.AGENCY);
if (name != null)
this.labelAgent.Content = 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;
}
#endregion
#region event handler
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
this.DataContext = this.ShipcallControlModel;
}
private void buttonListTimes_Click(object sender, RoutedEventArgs e)
{
this.TimesRequested?.Invoke(this);
}
private void buttonEditShipcall_Click(object sender, RoutedEventArgs e)
{
this.EditRequested?.Invoke(this);
}
private void buttonOpenDropDown_Click(object sender, RoutedEventArgs e)
{
this.OpenExtraRequested?.Invoke(this);
}
#endregion
}
}