diff --git a/src/BreCalClient/HistoryControl.xaml b/src/BreCalClient/HistoryControl.xaml
index 90c87f6..ea4625c 100644
--- a/src/BreCalClient/HistoryControl.xaml
+++ b/src/BreCalClient/HistoryControl.xaml
@@ -14,19 +14,26 @@
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/BreCalClient/HistoryControl.xaml.cs b/src/BreCalClient/HistoryControl.xaml.cs
index caa0d72..4f2b9d5 100644
--- a/src/BreCalClient/HistoryControl.xaml.cs
+++ b/src/BreCalClient/HistoryControl.xaml.cs
@@ -3,6 +3,7 @@
//
using BreCalClient.misc.Model;
+using System;
using System.Windows.Controls;
namespace BreCalClient
@@ -12,16 +13,26 @@ namespace BreCalClient
///
public partial class HistoryControl : UserControl
{
- public HistoryControl(string ship, History history)
+ private readonly History _history;
+ public event Action? HistorySelected;
+
+ public HistoryControl(string ship, History history, string callType, string etaetd)
{
InitializeComponent();
-
+ _history = history;
this.textBlockOperation.Text = $"{history.Operation} on {history.Type}";
- this.textBlockShip.Text = ship;
+ this.hyperLinkShip.Text = ship;
+
if(BreCalLists.ParticipantLookupDict.ContainsKey(history.ParticipantId))
this.textBlockParticipant.Text = BreCalLists.ParticipantLookupDict[history.ParticipantId].Name;
this.textBlockTimestamp.Text = history.Timestamp.ToString();
+ this.textBlockEta.Text = etaetd;
+ this.textBlockShipcallType.Text = callType;
+ }
+ private void textBlockShip_Click(object sender, System.Windows.RoutedEventArgs e)
+ {
+ this.HistorySelected?.Invoke(_history.ShipcallId);
}
}
}
diff --git a/src/BreCalClient/HistoryDialog.xaml.cs b/src/BreCalClient/HistoryDialog.xaml.cs
index f348258..3b80236 100644
--- a/src/BreCalClient/HistoryDialog.xaml.cs
+++ b/src/BreCalClient/HistoryDialog.xaml.cs
@@ -4,8 +4,10 @@
using BreCalClient.misc.Api;
using BreCalClient.misc.Model;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
+using System.Printing;
using System.Windows;
namespace BreCalClient
@@ -22,6 +24,12 @@ namespace BreCalClient
#endregion
+ #region delegate/event to react to history item selection
+
+ public event Action? HistoryItemSelected;
+
+ #endregion
+
#region Construction
public HistoryDialog(ConcurrentDictionary shipcalls, StaticApi staticApi)
@@ -69,7 +77,19 @@ namespace BreCalClient
Ship? ship = this._shipcalls[history.ShipcallId].Ship;
if (ship != null)
shipname = ship.Name;
- HistoryControl hc = new(shipname, history);
+ string etaetd = "", calltype = "";
+ if (_shipcalls.ContainsKey(history.ShipcallId))
+ {
+ etaetd = _shipcalls[history.ShipcallId].GetETAETD();
+ if (_shipcalls[history.ShipcallId].Shipcall != null)
+ {
+ ShipcallType? type = _shipcalls[history.ShipcallId].Shipcall?.Type;
+ if (type != null) calltype = type.Value.ToString();
+ }
+ }
+
+ HistoryControl hc = new(shipname, history, calltype, etaetd);
+ hc.HistorySelected += (x) => { HistoryItemSelected?.Invoke(x); }; // bubble event
this.stackPanel.Children.Add(hc);
}
}
diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs
index 3ec35b6..e3301d3 100644
--- a/src/BreCalClient/MainWindow.xaml.cs
+++ b/src/BreCalClient/MainWindow.xaml.cs
@@ -357,6 +357,11 @@ namespace BreCalClient
{
_historyDialog = new HistoryDialog(_allShipcallsDict, _staticApi);
_historyDialog.Closed += (sender, e) => { this._historyDialog = null; };
+ _historyDialog.HistoryItemSelected += (x) =>
+ {
+ if(_allShipCallsControlDict.ContainsKey(x))
+ _allShipCallsControlDict[x].BringIntoView();
+ };
_historyDialog.Show();
}
else
diff --git a/src/BreCalClient/ShipcallControlModel.cs b/src/BreCalClient/ShipcallControlModel.cs
index 4210c3d..08c83b6 100644
--- a/src/BreCalClient/ShipcallControlModel.cs
+++ b/src/BreCalClient/ShipcallControlModel.cs
@@ -182,6 +182,33 @@ namespace BreCalClient
return berthText;
}
+ public string GetETAETD()
+ {
+ DateTime theDate = DateTime.Now;
+ if(this.Shipcall != null)
+ {
+ if (this.Shipcall.Type == ShipcallType.Arrival)
+ theDate = this.Shipcall.Eta ?? DateTime.Now;
+ else
+ theDate = this.Shipcall.Etd ?? DateTime.Now;
+ }
+ Times? agentTimes = this.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY);
+ if(agentTimes != null)
+ {
+ if(this.Shipcall?.Type == ShipcallType.Arrival)
+ {
+ if (agentTimes.EtaBerth != null)
+ theDate = agentTimes.EtaBerth.Value;
+ }
+ else
+ {
+ if (agentTimes.EtdBerth != null)
+ theDate = agentTimes.EtdBerth.Value;
+ }
+ }
+ return theDate.ToString();
+ }
+
///
/// After closing the edit shipcall or edit agency dialogs, the times assignments may have changed.