diff --git a/src/BreCalClient/BreCalLists.cs b/src/BreCalClient/BreCalLists.cs new file mode 100644 index 0000000..c8df918 --- /dev/null +++ b/src/BreCalClient/BreCalLists.cs @@ -0,0 +1,123 @@ +// Copyright (c) 2023 schick Informatik +// Description: Static lists used everywhere +// + +using BreCalClient.misc.Model; +using System.Collections.Concurrent; +using System.Collections.Generic; + + +namespace BreCalClient +{ + public static class BreCalLists + { + + #region Fields + + private static readonly List aList = new(); + private static readonly List mList = new(); + private static readonly List pList = new(); + private static readonly List tList = new(); + private static readonly List terList = new(); + + private static List _berths = new(); + private static List _participants = new(); + private static List _ships = new(); + + private readonly static ConcurrentDictionary _shipLookupDict = new(); + private readonly static ConcurrentDictionary _berthLookupDict = new(); + private readonly static Dictionary _participantLookupDict = new(); + + #endregion + + #region Properties + + public static ConcurrentDictionary ShipLookupDict { get { return _shipLookupDict; } } + + public static ConcurrentDictionary BerthLookupDict { get { return _berthLookupDict; } } + + public static Dictionary ParticipantLookupDict { get { return _participantLookupDict; } } + + /// + /// Participants that are agents + /// + public static List Participants_Agent { get { return aList; } } + + /// + /// Participants that are mooring companies + /// + public static List Participants_Mooring { get { return mList; } } + + /// + /// Participants that are pilots + /// + public static List Participants_Pilot { get { return pList; } } + + /// + /// Participants that are tug shipping companies + /// + public static List Participants_Tug { get { return tList; } } + + /// + /// Participants that are terminals + /// + public static List Participants_Terminal { get { return terList; } } + + /// + /// All participants + /// + public static List Participants { get { return _participants; } } + + /// + /// All berths + /// + public static List Berths { get { return _berths; } } + + /// + /// All ships + /// + public static List Ships { get { return _ships; } } + + #endregion + + #region methods + + internal static void InitializeParticipants(List participants) + { + _participants = participants; + + aList.Clear(); + mList.Clear(); + pList.Clear(); + tList.Clear(); + terList.Clear(); + + foreach (Participant p in participants) + { + _participantLookupDict[p.Id] = p; + if (p.IsTypeFlagSet(Extensions.ParticipantType.AGENCY)) aList.Add(p); + if (p.IsTypeFlagSet(Extensions.ParticipantType.MOORING)) mList.Add(p); + if (p.IsTypeFlagSet(Extensions.ParticipantType.PILOT)) pList.Add(p); + if (p.IsTypeFlagSet(Extensions.ParticipantType.TUG)) tList.Add(p); + if (p.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL)) terList.Add(p); + } + } + + internal static void InitializeBerths(List berths) + { + foreach (var berth in berths) + _berthLookupDict[berth.Id] = berth; + _berths = berths; + } + + internal static void InitializeShips(List ships) + { + foreach (var ship in ships) + _shipLookupDict[ship.Id] = ship; + _ships = ships; + } + + #endregion + + } +} diff --git a/src/BreCalClient/EditShipcallControl.xaml b/src/BreCalClient/EditShipcallControl.xaml index 7138d90..dae9047 100644 --- a/src/BreCalClient/EditShipcallControl.xaml +++ b/src/BreCalClient/EditShipcallControl.xaml @@ -8,7 +8,7 @@ xmlns:db="clr-namespace:BreCalClient;assembly=BreCalClient" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" - Title="{x:Static p:Resources.textEditShipcall}" Height="466" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico"> + Title="{x:Static p:Resources.textEditShipcall}" Height="214" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico"> @@ -26,135 +26,73 @@ - - - - - - - - -