// 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 { /// /// Interaction logic for EditTimesControl.xaml /// public partial class EditTimesControl : Window, IEditTimesControl { #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(); bool enableControls = this.Times.ParticipantId == App.Participant.Id; this.datePickerETABerth.IsEnabled = enableControls; this.checkBoxEtaBerthFixed.IsEnabled = enableControls; this.datePickerETDBerth.IsEnabled = enableControls; this.checkBoxEtDBerthFixed.IsEnabled = enableControls; this.datePickerLockTime.IsEnabled = enableControls; this.checkBoxLockTimeFixed.IsEnabled = enableControls; this.datePickerZoneEntry.IsEnabled = enableControls; this.checkBoxZoneEntryFixed.IsEnabled = enableControls; this.textBoxRemarks.IsEnabled = enableControls; this.buttonOK.IsEnabled = enableControls; } 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.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.checkBoxEtaBerthFixed.IsChecked = this.Times.EtaBerthFixed; this.checkBoxEtDBerthFixed.IsChecked = this.Times.EtdBerthFixed; this.checkBoxLockTimeFixed.IsChecked = this.Times.LockTimeFixed; this.checkBoxZoneEntryFixed.IsChecked = this.Times.ZoneEntryFixed; } #endregion #region clear value event handler private void contextMenuItemClearETA_Click(object sender, RoutedEventArgs e) { this.datePickerETABerth.Value = null; } private void contextMenuItemClearETD_Click(object sender, RoutedEventArgs e) { this.datePickerETDBerth.Value = null; } private void contextMenuItemClearLockTime_Click(object sender, RoutedEventArgs e) { this.datePickerLockTime.Value = null; } private void contextMenuItemClearZoneEntry_Click(object sender, RoutedEventArgs e) { this.datePickerZoneEntry.Value = null; } #endregion } }