115 lines
4.8 KiB
C#
115 lines
4.8 KiB
C#
// Copyright (c) 2023 schick Informatik
|
|
// Description: Single dialog to edit times for all participant types
|
|
// (we might use different controls at a later time)
|
|
//
|
|
|
|
using BreCalClient.misc.Model;
|
|
using System.Windows;
|
|
|
|
namespace BreCalClient
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for EditTimesControl.xaml
|
|
/// </summary>
|
|
public partial class EditTimesControl : Window
|
|
{
|
|
|
|
#region Construction
|
|
|
|
public EditTimesControl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
public Times Times { get; set; } = new();
|
|
|
|
internal Extensions.ParticipantType ParticipantType { get; set; } = Extensions.ParticipantType.NONE;
|
|
|
|
#endregion
|
|
|
|
#region event handler
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
this.CopyToControls();
|
|
// enable controls according to participant type
|
|
this.datePickerETABerth.IsEnabled = App.Participant.IsFlagSet(Extensions.ParticipantType.AGENCY) ||
|
|
App.Participant.IsFlagSet(Extensions.ParticipantType.MOORING) ||
|
|
App.Participant.IsFlagSet(Extensions.ParticipantType.PILOT) ||
|
|
App.Participant.IsFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION) ||
|
|
App.Participant.IsFlagSet(Extensions.ParticipantType.TUG);
|
|
|
|
|
|
this.checkBoxEtaBerthFixed.IsEnabled = this.datePickerETABerth.IsEnabled;
|
|
this.datePickerETDBerth.IsEnabled = this.datePickerETABerth.IsEnabled;
|
|
this.checkBoxEtDBerthFixed.IsEnabled = this.datePickerETABerth.IsEnabled;
|
|
|
|
this.datePickerLockTime.IsEnabled = App.Participant.IsFlagSet(Extensions.ParticipantType.AGENCY) ||
|
|
App.Participant.IsFlagSet(Extensions.ParticipantType.MOORING) ||
|
|
App.Participant.IsFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION);
|
|
this.checkBoxLockTimeFixed.IsEnabled = this.datePickerLockTime.IsEnabled;
|
|
|
|
this.datePickerZoneEntry.IsEnabled = App.Participant.IsFlagSet(Extensions.ParticipantType.AGENCY) ||
|
|
App.Participant.IsFlagSet(Extensions.ParticipantType.PILOT);
|
|
this.checkBoxZoneEntryFixed.IsEnabled = this.datePickerZoneEntry.IsEnabled;
|
|
|
|
this.datePickerOperationStart.IsEnabled = App.Participant.IsFlagSet(Extensions.ParticipantType.TERMINAL);
|
|
this.datePickerOperationEnd.IsEnabled = App.Participant.IsFlagSet(Extensions.ParticipantType.TERMINAL);
|
|
}
|
|
|
|
private void buttonOK_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.CopyToModel();
|
|
this.DialogResult = true;
|
|
this.Close();
|
|
}
|
|
|
|
private void buttonCancel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.DialogResult = false;
|
|
this.Close();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region private methods
|
|
|
|
private void CopyToModel()
|
|
{
|
|
this.Times.Remarks = this.textBoxRemarks.Text.Trim().Truncate(512);
|
|
this.Times.EtaBerth = this.datePickerETABerth.Value;
|
|
this.Times.EtdBerth = this.datePickerETDBerth.Value;
|
|
this.Times.LockTime = this.datePickerLockTime.Value;
|
|
this.Times.ZoneEntry = this.datePickerZoneEntry.Value;
|
|
this.Times.OperationsStart = this.datePickerOperationStart.Value;
|
|
this.Times.OperationsEnd = this.datePickerOperationEnd.Value;
|
|
this.Times.EtaBerthFixed = this.checkBoxEtaBerthFixed.IsChecked;
|
|
this.Times.EtdBerthFixed = this.checkBoxEtDBerthFixed.IsChecked;
|
|
this.Times.LockTimeFixed = this.checkBoxLockTimeFixed.IsChecked;
|
|
this.Times.ZoneEntryFixed = this.checkBoxZoneEntryFixed.IsChecked;
|
|
}
|
|
|
|
private void CopyToControls()
|
|
{
|
|
this.textBoxRemarks.Text = this.Times.Remarks;
|
|
this.datePickerETABerth.Value = this.Times.EtaBerth;
|
|
this.datePickerETDBerth.Value = this.Times.EtdBerth;
|
|
this.datePickerLockTime.Value = this.Times.LockTime;
|
|
this.datePickerZoneEntry.Value = this.Times.ZoneEntry;
|
|
this.datePickerOperationStart.Value = this.Times.OperationsStart;
|
|
this.datePickerOperationEnd.Value = this.Times.OperationsEnd;
|
|
this.checkBoxEtaBerthFixed.IsChecked = this.Times.EtaBerthFixed;
|
|
this.checkBoxEtDBerthFixed.IsChecked = this.Times.EtdBerthFixed;
|
|
this.checkBoxLockTimeFixed.IsChecked = this.Times.LockTimeFixed;
|
|
this.checkBoxZoneEntryFixed.IsChecked = this.Times.ZoneEntryFixed;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|