From 9ebc723c76d0201f03aecd3af0e5b50beb95f2e6 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Fri, 9 May 2025 08:15:09 +0200 Subject: [PATCH] Trenz map thumbnails in last column --- src/BreCalClient/BreCalClient.csproj | 1 + src/BreCalClient/MainWindow.xaml | 2 ++ .../Resources/Resources.Designer.cs | 9 +++++++ src/BreCalClient/Resources/Resources.de.resx | 3 +++ src/BreCalClient/Resources/Resources.resx | 3 +++ src/BreCalClient/ShipcallControl.xaml | 5 ++++ src/BreCalClient/ShipcallControl.xaml.cs | 25 ++++++++++++++++++- 7 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/BreCalClient/BreCalClient.csproj b/src/BreCalClient/BreCalClient.csproj index 818c99a..cccc2b9 100644 --- a/src/BreCalClient/BreCalClient.csproj +++ b/src/BreCalClient/BreCalClient.csproj @@ -119,6 +119,7 @@ + diff --git a/src/BreCalClient/MainWindow.xaml b/src/BreCalClient/MainWindow.xaml index dd169f8..d27f2a8 100644 --- a/src/BreCalClient/MainWindow.xaml +++ b/src/BreCalClient/MainWindow.xaml @@ -97,6 +97,7 @@ + @@ -105,6 +106,7 @@ + diff --git a/src/BreCalClient/Resources/Resources.Designer.cs b/src/BreCalClient/Resources/Resources.Designer.cs index 7a002ab..da41c58 100644 --- a/src/BreCalClient/Resources/Resources.Designer.cs +++ b/src/BreCalClient/Resources/Resources.Designer.cs @@ -1064,6 +1064,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Position. + /// + public static string textPosition { + get { + return ResourceManager.GetString("textPosition", resourceCulture); + } + } + /// /// Looks up a localized string similar to Rain sensitive cargo. /// diff --git a/src/BreCalClient/Resources/Resources.de.resx b/src/BreCalClient/Resources/Resources.de.resx index c28930b..c3ecaa8 100644 --- a/src/BreCalClient/Resources/Resources.de.resx +++ b/src/BreCalClient/Resources/Resources.de.resx @@ -556,4 +556,7 @@ Es ist keine Hafenzuordnung vorhanden + + Position + \ No newline at end of file diff --git a/src/BreCalClient/Resources/Resources.resx b/src/BreCalClient/Resources/Resources.resx index 0a0154d..c89a9be 100644 --- a/src/BreCalClient/Resources/Resources.resx +++ b/src/BreCalClient/Resources/Resources.resx @@ -604,4 +604,7 @@ No port assigned to this participant + + Position + \ No newline at end of file diff --git a/src/BreCalClient/ShipcallControl.xaml b/src/BreCalClient/ShipcallControl.xaml index cc55bdc..064a71e 100644 --- a/src/BreCalClient/ShipcallControl.xaml +++ b/src/BreCalClient/ShipcallControl.xaml @@ -18,6 +18,7 @@ + @@ -281,6 +282,10 @@ + + + + diff --git a/src/BreCalClient/ShipcallControl.xaml.cs b/src/BreCalClient/ShipcallControl.xaml.cs index 7c115ab..27f68bf 100644 --- a/src/BreCalClient/ShipcallControl.xaml.cs +++ b/src/BreCalClient/ShipcallControl.xaml.cs @@ -4,6 +4,7 @@ using BreCalClient.misc.Model; using log4net; +using Microsoft.Web.WebView2.Wpf; using System; using System.Windows; using System.Windows.Controls; @@ -26,6 +27,7 @@ namespace BreCalClient Participant? _tug; Participant? _port_administration; private static readonly ILog _log = LogManager.GetLogger(typeof(ShipcallControl)); + private WebView2? _webView = null; #endregion @@ -59,7 +61,7 @@ namespace BreCalClient #region public methods - public void RefreshData() + public async void RefreshData() { try { @@ -508,6 +510,27 @@ namespace BreCalClient } this.DataContext = this.ShipcallControlModel; + + // initialize Map if eta is close to current time + + DateTime? refTime = (this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival) ? this.ShipcallControlModel?.Eta : this.ShipcallControlModel?.Etd; + if (refTime.HasValue) + { + if ((refTime.Value > DateTime.Now.AddDays(-1)) && refTime.Value < DateTime.Now.AddDays(2)) + { + if(this._webView == null) + { + _webView = new WebView2(); + string trenzUri = $"https://aismap.trenz.de/Live/StaticDemo.aspx?site=bsmd&Zoom=13&api=usgPcOPJnvTWUPTVbfVs&apikey=demo-H6cE4SG0FG&imo={this.ShipcallControlModel?.Ship?.Imo}"; + await Dispatcher.InvokeAsync(() => { + this.placeHolderMap.Children.Add(_webView); + _webView.EnsureCoreWebView2Async(null); + _webView.Source = new Uri(trenzUri); + }); + } + + } + } } } catch (Exception ex)