set enabled flags in times and terminal edit controls

This commit is contained in:
Daniel Schick 2023-10-13 11:32:18 +02:00 committed by puls200
parent 6079d1dc51
commit 2440424312
8 changed files with 60 additions and 35 deletions

View File

@ -31,6 +31,8 @@ namespace BreCalClient
public Times Times { get; set; } = new(); public Times Times { get; set; } = new();
public Extensions.TypeEnum CallType { get; set; }
#endregion #endregion
#region event handler #region event handler

View File

@ -4,8 +4,6 @@
using BreCalClient.misc.Model; using BreCalClient.misc.Model;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows; using System.Windows;
using static BreCalClient.Extensions; using static BreCalClient.Extensions;
@ -32,6 +30,8 @@ namespace BreCalClient
public Times Times { get; set; } = new(); public Times Times { get; set; } = new();
public Extensions.TypeEnum CallType { get; set; }
#endregion #endregion
#region event handler #region event handler

View File

@ -4,8 +4,6 @@
using BreCalClient.misc.Model; using BreCalClient.misc.Model;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows; using System.Windows;
using static BreCalClient.Extensions; using static BreCalClient.Extensions;
@ -32,6 +30,8 @@ namespace BreCalClient
public Times Times { get; set; } = new(); public Times Times { get; set; } = new();
public Extensions.TypeEnum CallType { get; set; }
#endregion #endregion
#region event handler #region event handler

View File

@ -27,6 +27,8 @@ namespace BreCalClient
public Times Times { get; set; } = new(); public Times Times { get; set; } = new();
public Extensions.TypeEnum CallType { get; set; }
internal Extensions.ParticipantType ParticipantType { get; set; } = Extensions.ParticipantType.NONE; internal Extensions.ParticipantType ParticipantType { get; set; } = Extensions.ParticipantType.NONE;
#endregion #endregion
@ -36,19 +38,7 @@ namespace BreCalClient
private void Window_Loaded(object sender, RoutedEventArgs e) private void Window_Loaded(object sender, RoutedEventArgs e)
{ {
this.CopyToControls(); this.CopyToControls();
bool enableControls = this.Times.ParticipantId == App.Participant.Id; this.EnableControls();
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) private void buttonOK_Click(object sender, RoutedEventArgs e)
@ -96,6 +86,37 @@ namespace BreCalClient
this.checkBoxZoneEntryFixed.IsChecked = this.Times.ZoneEntryFixed; this.checkBoxZoneEntryFixed.IsChecked = this.Times.ZoneEntryFixed;
} }
private void EnableControls()
{
switch (this.ParticipantType)
{
case Extensions.ParticipantType.MOORING:
case Extensions.ParticipantType.PORT_ADMINISTRATION:
case Extensions.ParticipantType.TUG:
this.datePickerETABerth.IsEnabled = (CallType == Extensions.TypeEnum.Incoming || CallType == Extensions.TypeEnum.Shifting);
this.checkBoxEtaBerthFixed.IsEnabled = (CallType == Extensions.TypeEnum.Incoming || CallType == Extensions.TypeEnum.Shifting);
this.datePickerETDBerth.IsEnabled = (CallType == Extensions.TypeEnum.Outgoing || CallType == Extensions.TypeEnum.Shifting);
this.checkBoxEtDBerthFixed.IsEnabled = (CallType == Extensions.TypeEnum.Outgoing || CallType == Extensions.TypeEnum.Shifting);
this.datePickerLockTime.IsEnabled = (CallType == Extensions.TypeEnum.Incoming || CallType == Extensions.TypeEnum.Shifting);
this.checkBoxLockTimeFixed.IsEnabled = (CallType == Extensions.TypeEnum.Incoming || CallType == Extensions.TypeEnum.Shifting);
this.datePickerZoneEntry.IsEnabled = false;
this.checkBoxZoneEntryFixed.IsEnabled = false;
this.textBoxRemarks.IsEnabled = true;
break;
case Extensions.ParticipantType.PILOT:
this.datePickerETABerth.IsEnabled = (CallType == Extensions.TypeEnum.Incoming || CallType == Extensions.TypeEnum.Shifting);
this.checkBoxEtaBerthFixed.IsEnabled = (CallType == Extensions.TypeEnum.Incoming || CallType == Extensions.TypeEnum.Shifting);
this.datePickerETDBerth.IsEnabled = (CallType == Extensions.TypeEnum.Outgoing || CallType == Extensions.TypeEnum.Shifting);
this.checkBoxEtDBerthFixed.IsEnabled = (CallType == Extensions.TypeEnum.Outgoing || CallType == Extensions.TypeEnum.Shifting);
this.datePickerLockTime.IsEnabled = (CallType == Extensions.TypeEnum.Incoming || CallType == Extensions.TypeEnum.Shifting);
this.checkBoxLockTimeFixed.IsEnabled = (CallType == Extensions.TypeEnum.Incoming || CallType == Extensions.TypeEnum.Shifting);
this.datePickerZoneEntry.IsEnabled = (CallType == Extensions.TypeEnum.Incoming);
this.checkBoxZoneEntryFixed.IsEnabled = (CallType == Extensions.TypeEnum.Incoming);
this.textBoxRemarks.IsEnabled = true;
break;
}
}
#endregion #endregion
#region clear value event handler #region clear value event handler

View File

@ -19,7 +19,9 @@ namespace BreCalClient
#region Properties #region Properties
public Times Times { get; set; } = new(); public Times Times { get; set; } = new();
public Extensions.TypeEnum CallType { get; set; }
#endregion #endregion
@ -29,15 +31,7 @@ namespace BreCalClient
{ {
this.comboBoxBerth.ItemsSource = BreCalLists.Berths; this.comboBoxBerth.ItemsSource = BreCalLists.Berths;
this.CopyToControls(); this.CopyToControls();
this.EnableControls();
bool enableControls = this.Times.ParticipantId == App.Participant.Id;
this.datePickerOperationStart.IsEnabled = enableControls;
this.datePickerOperationEnd.IsEnabled = enableControls;
this.comboBoxBerth.IsEnabled = enableControls;
this.comboBoxPierside.IsEnabled = enableControls;
this.textBoxRemarks.IsEnabled = enableControls;
this.textBoxBerthRemarks.IsEnabled = enableControls;
this.buttonOK.IsEnabled = enableControls;
} }
private void contextMenuItemClearOperationStart_Click(object sender, RoutedEventArgs e) private void contextMenuItemClearOperationStart_Click(object sender, RoutedEventArgs e)
@ -98,8 +92,17 @@ namespace BreCalClient
this.textBoxBerthRemarks.Text = this.Times.BerthInfo; this.textBoxBerthRemarks.Text = this.Times.BerthInfo;
} }
#endregion private void EnableControls()
{
this.datePickerOperationStart.IsEnabled = (CallType == Extensions.TypeEnum.Incoming) || (CallType == Extensions.TypeEnum.Shifting);
this.datePickerOperationEnd.IsEnabled = (CallType == Extensions.TypeEnum.Outgoing) || (CallType == Extensions.TypeEnum.Shifting);
this.comboBoxBerth.IsEnabled = (CallType == Extensions.TypeEnum.Incoming) || (CallType == Extensions.TypeEnum.Shifting);
this.comboBoxPierside.IsEnabled = (CallType == Extensions.TypeEnum.Incoming) || (CallType == Extensions.TypeEnum.Shifting);
this.textBoxBerthRemarks.IsEnabled = (CallType == Extensions.TypeEnum.Incoming) || (CallType == Extensions.TypeEnum.Shifting);
this.textBoxRemarks.IsEnabled = true;
}
#endregion
} }
} }

View File

@ -4,15 +4,11 @@
using BreCalClient.misc.Model; using BreCalClient.misc.Model;
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BreCalClient namespace BreCalClient
{ {
internal static class Extensions public static class Extensions
{ {
#region Enum #region Enum

View File

@ -11,6 +11,8 @@ namespace BreCalClient
{ {
Times Times { get; set; } Times Times { get; set; }
Extensions.TypeEnum CallType { get; set; }
bool? ShowDialog(); bool? ShowDialog();
} }

View File

@ -565,9 +565,10 @@ namespace BreCalClient
if (!obj.ShipcallControlModel.AssignedParticipants.ContainsKey(participantType)) return; // no assigment means no dialog my friend if (!obj.ShipcallControlModel.AssignedParticipants.ContainsKey(participantType)) return; // no assigment means no dialog my friend
// show a dialog that lets the user create / update times for the given shipcall // show a dialog that lets the user create / update times for the given shipcall
IEditTimesControl etc = (participantType == ParticipantType.TERMINAL) ? new EditTimesTerminalControl() : new EditTimesControl(); IEditTimesControl etc = (participantType == ParticipantType.TERMINAL) ? new EditTimesTerminalControl() : new EditTimesControl();
if(obj.ShipcallControlModel.Shipcall != null)
etc.CallType = (TypeEnum) obj.ShipcallControlModel.Shipcall.Type;
bool wasEdit = false; bool wasEdit = false;
if (times != null) if (times != null)
{ {