diff --git a/src/BreCalClient/App.xaml.cs b/src/BreCalClient/App.xaml.cs index e85a282..c44620d 100644 --- a/src/BreCalClient/App.xaml.cs +++ b/src/BreCalClient/App.xaml.cs @@ -1,4 +1,5 @@ -using System; +using BreCalClient.misc.Model; +using System; using System.Collections.Generic; using System.Configuration; using System.Data; @@ -13,5 +14,6 @@ namespace BreCalClient /// public partial class App : Application { + public static Participant Participant { get; set; } = new Participant(); } } diff --git a/src/BreCalClient/Extensions.cs b/src/BreCalClient/Extensions.cs new file mode 100644 index 0000000..eae3ed0 --- /dev/null +++ b/src/BreCalClient/Extensions.cs @@ -0,0 +1,62 @@ +// Copyright (c) 2023 schick Informatik +// Description: some helpers +// + +using BreCalClient.misc.Model; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BreCalClient +{ + internal static class Extensions + { + + #region Enum + + /// + /// Copied from models clunky I know + /// + [Flags] + public enum ParticipantType + { + [Description("not assigned")] + NONE = 0, + [Description("BSMD")] + BSMD = 1, + [Description("Terminal")] + TERMINAL = 2, + [Description("Lotsen")] + PILOT = 4, + [Description("Agentur")] + AGENCY = 8, + [Description("Festmacher")] + MOORING = 16, + [Description("Hafenamt")] + PORT_ADMINISTRATION = 32, + [Description("Schlepper")] + TUG = 64, + } + + #endregion + + #region public helper + + public static bool IsFlagSet(this Participant participant, ParticipantType flag) + { + return (participant.Type & (uint)flag) != 0; + } + + public static void SetFlag(this Participant participant, bool value, ParticipantType flag) + { + if (value) participant.Type |= (int)flag; + else participant.Type &= (int)~flag; + } + + #endregion + + } +} diff --git a/src/BreCalClient/MainWindow.xaml b/src/BreCalClient/MainWindow.xaml index 6fe04e5..44f992b 100644 --- a/src/BreCalClient/MainWindow.xaml +++ b/src/BreCalClient/MainWindow.xaml @@ -57,6 +57,7 @@ +