From 32296f7d155da8b39feb55cb0b183ae808a04ced Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Fri, 29 Mar 2024 10:13:23 +0100 Subject: [PATCH] Change history Part 3 Finished layout of history control, reversed sort order (newest on top) May need to move labels to HistoryDialog --- src/BreCalClient/BreCalClient.licenseheader | 4 +-- src/BreCalClient/HistoryControl.xaml | 32 +++++++++++++++++++ src/BreCalClient/HistoryControl.xaml.cs | 27 ++++++++++++++++ src/BreCalClient/HistoryDialog.xaml.cs | 31 ++++++++++-------- .../Resources/Resources.Designer.cs | 27 ++++++++++++++++ src/BreCalClient/Resources/Resources.de.resx | 9 ++++++ src/BreCalClient/Resources/Resources.resx | 9 ++++++ 7 files changed, 124 insertions(+), 15 deletions(-) create mode 100644 src/BreCalClient/HistoryControl.xaml create mode 100644 src/BreCalClient/HistoryControl.xaml.cs diff --git a/src/BreCalClient/BreCalClient.licenseheader b/src/BreCalClient/BreCalClient.licenseheader index 82bf51d..ae39ce3 100644 --- a/src/BreCalClient/BreCalClient.licenseheader +++ b/src/BreCalClient/BreCalClient.licenseheader @@ -1,12 +1,12 @@ extensions: designer.cs generated.cs extensions: .cs .cpp .h -// Copyright (c) 2023 schick Informatik +// Copyright (c) 2024- schick Informatik // Description: // extensions: .aspx .ascx <%-- -Copyright (c) 2023 schick Informatik +Copyright (c) 2024- schick Informatik --%> extensions: .vb 'Sample license text. diff --git a/src/BreCalClient/HistoryControl.xaml b/src/BreCalClient/HistoryControl.xaml new file mode 100644 index 0000000..90c87f6 --- /dev/null +++ b/src/BreCalClient/HistoryControl.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/BreCalClient/HistoryControl.xaml.cs b/src/BreCalClient/HistoryControl.xaml.cs new file mode 100644 index 0000000..caa0d72 --- /dev/null +++ b/src/BreCalClient/HistoryControl.xaml.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2024- schick Informatik +// Description: display single history element (later shown in a list) +// + +using BreCalClient.misc.Model; +using System.Windows.Controls; + +namespace BreCalClient +{ + /// + /// Interaction logic for HistoryControl.xaml + /// + public partial class HistoryControl : UserControl + { + public HistoryControl(string ship, History history) + { + InitializeComponent(); + + this.textBlockOperation.Text = $"{history.Operation} on {history.Type}"; + this.textBlockShip.Text = ship; + if(BreCalLists.ParticipantLookupDict.ContainsKey(history.ParticipantId)) + this.textBlockParticipant.Text = BreCalLists.ParticipantLookupDict[history.ParticipantId].Name; + this.textBlockTimestamp.Text = history.Timestamp.ToString(); + + } + } +} diff --git a/src/BreCalClient/HistoryDialog.xaml.cs b/src/BreCalClient/HistoryDialog.xaml.cs index 4b3f074..f348258 100644 --- a/src/BreCalClient/HistoryDialog.xaml.cs +++ b/src/BreCalClient/HistoryDialog.xaml.cs @@ -1,23 +1,12 @@ -// Copyright (c) 2023 schick Informatik -// Description: +// Copyright (c) 2024- schick Informatik +// Description: Window to show (complete) list of current shipcall histories // using BreCalClient.misc.Api; using BreCalClient.misc.Model; -using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace BreCalClient { @@ -62,10 +51,26 @@ namespace BreCalClient private async void RefreshHistory() { + List allHistories = new(); foreach (int shipcall_id in _shipcalls.Keys) { List shipcallHistory = await _staticApi.HistoryGetAsync(shipcall_id); System.Diagnostics.Trace.WriteLine($"{shipcallHistory.Count} history elements loaded for shipcall {shipcall_id}"); + allHistories.AddRange( shipcallHistory ); + } + + // sort all entries + allHistories.Sort((x, y) => { return y.Timestamp.CompareTo(x.Timestamp); }); + + // create controls for all entries + foreach (History history in allHistories) + { + string shipname = ""; + Ship? ship = this._shipcalls[history.ShipcallId].Ship; + if (ship != null) + shipname = ship.Name; + HistoryControl hc = new(shipname, history); + this.stackPanel.Children.Add(hc); } } diff --git a/src/BreCalClient/Resources/Resources.Designer.cs b/src/BreCalClient/Resources/Resources.Designer.cs index d3ae93d..d352e3c 100644 --- a/src/BreCalClient/Resources/Resources.Designer.cs +++ b/src/BreCalClient/Resources/Resources.Designer.cs @@ -717,6 +717,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Operation. + /// + public static string textOperation { + get { + return ResourceManager.GetString("textOperation", resourceCulture); + } + } + /// /// Looks up a localized string similar to Operations end. /// @@ -744,6 +753,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Participant. + /// + public static string textParticipant { + get { + return ResourceManager.GetString("textParticipant", resourceCulture); + } + } + /// /// Looks up a localized string similar to Participants. /// @@ -987,6 +1005,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Timestamp. + /// + public static string textTimestamp { + get { + return ResourceManager.GetString("textTimestamp", resourceCulture); + } + } + /// /// Looks up a localized string similar to to. /// diff --git a/src/BreCalClient/Resources/Resources.de.resx b/src/BreCalClient/Resources/Resources.de.resx index a5e4165..774c98e 100644 --- a/src/BreCalClient/Resources/Resources.de.resx +++ b/src/BreCalClient/Resources/Resources.de.resx @@ -457,4 +457,13 @@ Änderungshistorie der Anläufe anzeigen + + Vorgang + + + Teilnehmer + + + Zeitpunkt + \ No newline at end of file diff --git a/src/BreCalClient/Resources/Resources.resx b/src/BreCalClient/Resources/Resources.resx index 4a55bf0..7bf17cf 100644 --- a/src/BreCalClient/Resources/Resources.resx +++ b/src/BreCalClient/Resources/Resources.resx @@ -331,6 +331,9 @@ Old password + + Operation + Operations end @@ -340,6 +343,9 @@ Outgoing + + Participant + Participants @@ -421,6 +427,9 @@ Tidal window + + Timestamp + to