Filter berths in combobox by selected port. Might still need some work..
This commit is contained in:
parent
80ad3e8e5a
commit
6215449bc8
@ -135,7 +135,22 @@ namespace BreCalClient
|
||||
|
||||
#endregion
|
||||
|
||||
#region methods
|
||||
#region public static methods
|
||||
|
||||
public static List<Berth> GetBerthsByPort(int port)
|
||||
{
|
||||
List<Berth> berths = new();
|
||||
foreach(Berth berth in _berths)
|
||||
{
|
||||
if(berth.PortId == port)
|
||||
berths.Add(berth);
|
||||
}
|
||||
return berths;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal initializer methods
|
||||
|
||||
internal static void InitializeParticipants(List<Participant> participants)
|
||||
{
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
<Label Content="{x:Static p:Resources.textCancelled}" Grid.Column="0" Grid.Row="5" HorizontalContentAlignment="Right" />
|
||||
<CheckBox x:Name="checkBoxCancelled" Grid.Column="1" Grid.Row="5" Margin="2" VerticalContentAlignment="Center" />
|
||||
<Label Content="{x:Static p:Resources.textHarbour}" Grid.Column="0" Grid.Row="6" HorizontalContentAlignment="Right" />
|
||||
<ComboBox x:Name="comboBoxHarbour" Grid.Column="1" Margin="2" Grid.Row="6" DisplayMemberPath="Name" SelectedValuePath="Id" />
|
||||
<ComboBox x:Name="comboBoxHarbour" Grid.Column="1" Margin="2" Grid.Row="6" DisplayMemberPath="Name" SelectedValuePath="Id" SelectionChanged="comboBoxHarbour_SelectionChanged"/>
|
||||
<Button x:Name="buttonEditShips" Grid.Column="1" Grid.Row="7" Margin="2" Content="{x:Static p:Resources.textEditShips}" Click="buttonEditShips_Click" Visibility="Hidden" />
|
||||
|
||||
<Label Content="{x:Static p:Resources.textType}" Grid.Column="2" Grid.Row="0" HorizontalContentAlignment="Right" />
|
||||
|
||||
@ -432,6 +432,24 @@ namespace BreCalClient
|
||||
this.comboBoxShip.ItemsSource = BreCalLists.Ships;
|
||||
}
|
||||
|
||||
private void comboBoxHarbour_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
Port port = (Port)this.comboBoxHarbour.SelectedItem;
|
||||
if (port == null) return;
|
||||
|
||||
// Filter berth selection combobox by port
|
||||
List<Berth> availableBerths = BreCalLists.GetBerthsByPort(port.Id);
|
||||
this.comboBoxArrivalBerth.ItemsSource = null;
|
||||
this.comboBoxArrivalBerth.ItemsSource = availableBerths;
|
||||
this.comboBoxDepartureBerth.ItemsSource = null;
|
||||
this.comboBoxDepartureBerth.ItemsSource = availableBerths;
|
||||
|
||||
// Filter agency combobox by port
|
||||
|
||||
// TODO
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
@ -47,10 +47,13 @@ namespace BreCalClient
|
||||
this.comboBoxTug.ItemsSource = BreCalLists.Participants_Tug;
|
||||
this.comboBoxTerminal.ItemsSource = BreCalLists.Participants_Terminal;
|
||||
|
||||
this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
|
||||
if ((this.ShipcallModel != null) && (this.ShipcallModel.Shipcall != null))
|
||||
this.comboBoxArrivalBerth.ItemsSource = BreCalLists.GetBerthsByPort(this.ShipcallModel.Shipcall.PortId);
|
||||
else
|
||||
this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
|
||||
this.CopyToControls();
|
||||
|
||||
this.Title = this.ShipcallModel.Title;
|
||||
this.Title = this.ShipcallModel?.Title;
|
||||
|
||||
Participant? p = null;
|
||||
if(this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY))
|
||||
|
||||
@ -54,10 +54,13 @@ namespace BreCalClient
|
||||
this.comboBoxTug.ItemsSource = BreCalLists.Participants_Tug;
|
||||
this.comboBoxTerminal.ItemsSource = BreCalLists.Participants_Terminal;
|
||||
|
||||
this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
|
||||
if ((this.ShipcallModel != null) && (this.ShipcallModel.Shipcall != null))
|
||||
this.comboBoxDepartureBerth.ItemsSource = BreCalLists.GetBerthsByPort(this.ShipcallModel.Shipcall.PortId);
|
||||
else
|
||||
this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
|
||||
this.CopyToControls();
|
||||
|
||||
this.Title = this.ShipcallModel.Title;
|
||||
this.Title = this.ShipcallModel?.Title;
|
||||
|
||||
Participant? p = null;
|
||||
if (this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY))
|
||||
|
||||
@ -4,7 +4,9 @@
|
||||
|
||||
using BreCalClient.misc.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using static BreCalClient.Extensions;
|
||||
|
||||
namespace BreCalClient
|
||||
@ -46,8 +48,18 @@ namespace BreCalClient
|
||||
this.comboBoxTug.ItemsSource = BreCalLists.Participants_Tug;
|
||||
this.comboBoxTerminal.ItemsSource = BreCalLists.Participants_Terminal;
|
||||
|
||||
this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
|
||||
this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
|
||||
if ((this.ShipcallModel != null) && (this.ShipcallModel.Shipcall != null))
|
||||
{
|
||||
List<Berth> availableBerths = BreCalLists.GetBerthsByPort(this.ShipcallModel.Shipcall.PortId);
|
||||
this.comboBoxArrivalBerth.ItemsSource = availableBerths;
|
||||
this.comboBoxDepartureBerth.ItemsSource = availableBerths;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
|
||||
this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
|
||||
}
|
||||
|
||||
this.CopyToControls();
|
||||
|
||||
this.Title = this.ShipcallModel.Title;
|
||||
|
||||
@ -30,7 +30,10 @@ namespace BreCalClient
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.comboBoxBerth.ItemsSource = BreCalLists.Berths;
|
||||
if ((this.ShipcallModel != null) && (this.ShipcallModel.Shipcall != null))
|
||||
this.comboBoxBerth.ItemsSource = BreCalLists.GetBerthsByPort(this.ShipcallModel.Shipcall.PortId);
|
||||
else
|
||||
this.comboBoxBerth.ItemsSource = BreCalLists.Berths;
|
||||
this.CopyToControls();
|
||||
this.EnableControls();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user