git_bsmd/ENI2/SheetDisplayControls/ShipDataControl.xaml.cs

174 lines
8.6 KiB
C#

// Copyright (c) 2025- schick Informatik
// Description: Display control of formsheet Tab 5. Ship data
//
using bsmd.database;
using System.Windows;
namespace ENI2.SheetDisplayControls
{
/// <summary>
/// Interaction logic for ShipDataControl.xaml
/// </summary>
public partial class ShipDataControl : DetailBaseControl
{
#region Fields
private INFO _info;
private PRE72H _pre72H;
private SEC _sec;
private MDH _mdh;
private STAT _stat;
private static readonly string[] isscTypes = { "Final", "Preliminary" };
private static readonly string[] isscIssuerTypes = { "Authority", "RSO (Recognized security org.)" };
private static readonly string[] hullConfiguration = {
Properties.Resources.textSingleHull,
Properties.Resources.textSingleHullBallast,
Properties.Resources.textDoubleHull
};
#endregion
#region Construction
public ShipDataControl()
{
InitializeComponent();
Loaded += ShipDataControl_Loaded;
}
#endregion
#region public override
public override void Initialize()
{
base.Initialize();
foreach (Message aMessage in this.Messages)
{
if (aMessage.MessageNotificationClass == Message.NotificationClass.STAT) { this._stat = aMessage.Elements[0] as STAT; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.SEC) { this._sec = aMessage.Elements[0] as SEC; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.INFO) { this._info = aMessage.Elements[0] as INFO; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.PRE72H) { this._pre72H = aMessage.Elements[0] as PRE72H; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.MDH) { this._mdh = aMessage.Elements[0] as MDH; this.ControlMessages.Add(aMessage); }
}
// 5.1
this.textBoxVesselName.DataContext = _stat;
this.textBoxIMO.DataContext = this.Core;
this.comboBoxVesselType.ItemsSource = STAT.VesselTypeDict;
this.comboBoxVesselType.DataContext = _stat;
this.comboBoxFlag.ItemsSource = CREW.NationalityDict;
this.comboBoxFlag.DataContext = _stat;
this.locodePortOfRegistry.DataContext = _stat;
this.textBoxCallsign.DataContext = _stat;
this.textBoxMMSI.DataContext = _stat;
this.doubleUpDownLength.DataContext = _stat;
this.doubleUpDownBeam.DataContext = _stat;
this.integerUpDownGrossTonnage.DataContext = _stat;
this.integerUpDownNetTonnage.DataContext = _stat;
this.doubleUpDownDisplacementSummerDraught.DataContext = _info;
this.datePickerRegistryDateOfIssue.DataContext = _stat;
this.textBoxCertificateRegistry.DataContext = _stat;
this.datePickerLastExpandedInspection.DataContext = _pre72H;
this.checkBoxIsDueToInspection.DataContext = _pre72H;
this.checkBoxPossibleAnchorage.DataContext = _pre72H;
this.textBoxCompanyName.DataContext = _stat;
this.textBoxCompanyId.DataContext = _stat;
this.shipEMailLabel.DataContext = this.Core;
// 5.2
this.checkBoxSanitaryControlExemption.DataContext = _mdh;
this.textBoxPlaceOfIssue.DataContext = _mdh;
this.datePickerDateOfIssue.DataContext = _mdh;
this.checkBoxReinspectionSanitary.DataContext = _mdh;
// 5.3
this.textBoxCSOLastName.DataContext = _sec;
this.textBoxCSOFirstName.DataContext = _sec;
this.textBoxCSOPhoneName.DataContext = _sec;
this.textBoxCSOEMailName.DataContext = _sec;
this.textBoxCSOFaxName.DataContext = _sec;
this.checkBoxValidISSCOnBoard.DataContext = _sec;
this.textBoxReasonsForNoValidISSC.DataContext = _sec;
this.comboBoxISSCType.ItemsSource = isscTypes;
this.comboBoxISSCType.DataContext = _sec;
this.datePickerISSCDateOfExpiration.DataContext = _sec;
this.comboBoxISSCIssuerType.ItemsSource = isscIssuerTypes;
this.comboBoxISSCIssuerType.DataContext = _sec;
this.textBoxISSCIssuerName.DataContext = _sec;
this.checkBoxApprovedSecurityPlanOnBoard.DataContext = _sec;
// 5.4
this.comboBoxTankerHullConfig.ItemsSource = hullConfiguration;
this.comboBoxTankerHullConfig.DataContext = _pre72H;
}
#endregion
#region event handler
private void ShipDataControl_Loaded(object sender, RoutedEventArgs e)
{
// 5.1
this.RegisterTextboxChange(this.textBoxVesselName, Message.NotificationClass.STAT);
this.RegisterComboboxValueChange(this.comboBoxVesselType, Message.NotificationClass.STAT);
this.RegisterComboboxValueChange(this.comboBoxFlag, Message.NotificationClass.STAT);
this.RegisterLocodeChange(this.locodePortOfRegistry, Message.NotificationClass.STAT);
this.RegisterLocodeChange(this.locodePortOfRegistry, Message.NotificationClass.STAT);
this.RegisterTextboxChange(this.textBoxCallsign, Message.NotificationClass.STAT);
this.RegisterTextboxChange(this.textBoxMMSI, Message.NotificationClass.STAT);
this.RegisterDoubleUpDownChange(this.doubleUpDownLength, Message.NotificationClass.STAT);
this.RegisterDoubleUpDownChange(this.doubleUpDownBeam, Message.NotificationClass.STAT);
this.RegisterIntegerUpDownChange(this.integerUpDownGrossTonnage, Message.NotificationClass.STAT);
this.RegisterIntegerUpDownChange(this.integerUpDownNetTonnage, Message.NotificationClass.STAT);
this.RegisterDoubleUpDownChange(this.doubleUpDownDisplacementSummerDraught, Message.NotificationClass.INFO);
this.RegisterDatePickerChange(this.datePickerRegistryDateOfIssue, Message.NotificationClass.STAT);
this.RegisterTextboxChange(this.textBoxCertificateRegistry, Message.NotificationClass.STAT);
this.RegisterDatePickerChange(this.datePickerLastExpandedInspection, Message.NotificationClass.PRE72H);
this.RegisterCheckboxChange(this.checkBoxIsDueToInspection, Message.NotificationClass.PRE72H);
this.RegisterCheckboxChange(this.checkBoxPossibleAnchorage, Message.NotificationClass.PRE72H);
this.RegisterTextboxChange(this.textBoxCompanyName, Message.NotificationClass.STAT);
this.RegisterTextboxChange(this.textBoxCompanyId, Message.NotificationClass.STAT);
// 5.2
this.RegisterCheckboxChange(this.checkBoxSanitaryControlExemption, Message.NotificationClass.MDH);
this.RegisterTextboxChange(this.textBoxPlaceOfIssue, Message.NotificationClass.MDH);
this.RegisterDatePickerChange(this.datePickerDateOfIssue, Message.NotificationClass.MDH);
this.RegisterCheckboxChange(this.checkBoxReinspectionSanitary, Message.NotificationClass.MDH);
// 5.3
this.RegisterTextboxChange(this.textBoxCSOLastName, Message.NotificationClass.SEC);
this.RegisterTextboxChange(this.textBoxCSOFirstName, Message.NotificationClass.SEC);
this.RegisterTextboxChange(this.textBoxCSOPhoneName, Message.NotificationClass.SEC);
this.RegisterTextboxChange(this.textBoxCSOFaxName, Message.NotificationClass.SEC);
this.RegisterTextboxChange(this.textBoxCSOEMailName, Message.NotificationClass.SEC);
this.RegisterCheckboxChange(this.checkBoxValidISSCOnBoard, Message.NotificationClass.SEC);
this.RegisterTextboxChange(this.textBoxReasonsForNoValidISSC, Message.NotificationClass.SEC);
this.RegisterComboboxIndexChange(this.comboBoxISSCType, Message.NotificationClass.SEC);
this.RegisterDatePickerChange(this.datePickerISSCDateOfExpiration, Message.NotificationClass.SEC);
this.RegisterComboboxIndexChange(this.comboBoxISSCIssuerType, Message.NotificationClass.SEC);
this.RegisterTextboxChange(this.textBoxISSCIssuerName, Message.NotificationClass.SEC);
this.RegisterCheckboxChange(this.checkBoxApprovedSecurityPlanOnBoard, Message.NotificationClass.SEC);
// 5.4
this.RegisterComboboxIndexChange(this.comboBoxTankerHullConfig, Message.NotificationClass.PRE72H);
}
#endregion
}
}