diff --git a/ENI2/Controls/BusyControl.xaml b/ENI2/Controls/BusyControl.xaml
new file mode 100644
index 00000000..83b0c937
--- /dev/null
+++ b/ENI2/Controls/BusyControl.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
diff --git a/ENI2/Controls/BusyControl.xaml.cs b/ENI2/Controls/BusyControl.xaml.cs
new file mode 100644
index 00000000..e840a1fc
--- /dev/null
+++ b/ENI2/Controls/BusyControl.xaml.cs
@@ -0,0 +1,44 @@
+// Copyright (c) 2023- schick Informatik
+//
+// Description: Idea to have a simple control that shows if the application is busy or not using a simple icon
+// that will be set according to a state
+//
+
+using ENI2.Util;
+using System.Windows.Controls;
+
+namespace ENI2.Controls
+{
+ ///
+ /// Interaction logic for BusyControl.xaml
+ ///
+ public partial class BusyControl : UserControl
+ {
+ UIHelper.BusyStateEnum _busyState = UIHelper.BusyStateEnum.NEUTRAL;
+
+ public BusyControl()
+ {
+ InitializeComponent();
+ }
+
+ public UIHelper.BusyStateEnum BusyState
+ {
+ set
+ {
+ _busyState = value;
+ //Dispatcher.Invoke(() =>
+ //{
+ switch (_busyState)
+ {
+ case UIHelper.BusyStateEnum.NEUTRAL: imageBall.Source = Properties.Resources.bullet_ball_grey.CreateBitmapSource(); break;
+ case UIHelper.BusyStateEnum.BUSY: imageBall.Source = Properties.Resources.bullet_ball_yellow.CreateBitmapSource(); break;
+ case UIHelper.BusyStateEnum.FAIL: imageBall.Source = Properties.Resources.bullet_ball_red.CreateBitmapSource(); break;
+ case UIHelper.BusyStateEnum.SUCCESS: imageBall.Source = Properties.Resources.bullet_ball_green.CreateBitmapSource(); break;
+ }
+ //});
+ }
+
+ get => _busyState;
+ }
+ }
+}
diff --git a/ENI2/Controls/MaerskListControl.xaml b/ENI2/Controls/MaerskListControl.xaml
index b2bde931..b6ab6887 100644
--- a/ENI2/Controls/MaerskListControl.xaml
+++ b/ENI2/Controls/MaerskListControl.xaml
@@ -24,12 +24,21 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ENI2/Controls/MaerskListControl.xaml.cs b/ENI2/Controls/MaerskListControl.xaml.cs
index ffaa94a2..647297c7 100644
--- a/ENI2/Controls/MaerskListControl.xaml.cs
+++ b/ENI2/Controls/MaerskListControl.xaml.cs
@@ -111,24 +111,17 @@ namespace ENI2.Controls
private void PerformSearch()
{
this.dataGridPOCores.ItemsSource = null;
- this.filteredResult.Clear();
-
- // TODO: Da diese Suche hier so unfassbar lahmarschig ist wäre es günstig (zukünftig für das gesamte ENI),
- // wenn die Abfrage asynchron stattfinden würde. Man muss nur irgendwie den Anwender bei Laune halten so dass
- // er merkt, da passiert noch was. Eventuell mit einem "spinning" Icon. Aber der Rest bleibt aktiv.
-
+ this.filteredResult.Clear();
Dictionary filterDict = new Dictionary();
DateTime start = DateTime.Now; // bsmd.database.Util.FirstDateOfWeekISO8601(DateTime.Now.Year, (int)this.doubleUpDownCalendarWeek.Value);
DateTime end = start.Add(new TimeSpan(6, 23, 59, 59));
-
+
// Die Suche findet in einem erweiterten Intervall statt, da später wenn möglich nach ATA gefiltert wird
uint from = start.Subtract(new TimeSpan(10, 0, 0, 0)).ToUniversalTime().ToUnixTimeStamp();
uint to = end.Add(new TimeSpan(5, 0, 0, 0)).ToUniversalTime().ToUnixTimeStamp();
- filterDict.Add(MessageCore.SearchFilterType.FILTER_ETA, string.Format("{0}:{1}", from.ToString() ?? "", to.ToString() ?? ""));
-
- Util.UIHelper.SetBusyState();
+ filterDict.Add(MessageCore.SearchFilterType.FILTER_ETA, string.Format("{0}:{1}", from.ToString() ?? "", to.ToString() ?? ""));
// suche auslösen
this.searchResult = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoresWithFilters(filterDict);
@@ -181,6 +174,26 @@ namespace ENI2.Controls
}
#endregion
-
+
+ #region button event handler
+
+ private void buttonLoad_Click(object sender, RoutedEventArgs e)
+ {
+ Util.UIHelper.SetBusyState();
+ this.PerformSearch();
+ }
+
+ private void buttonImport_Click(object sender, RoutedEventArgs e)
+ {
+
+ }
+
+ private void buttonExport_Click(object sender, RoutedEventArgs e)
+ {
+
+ }
+
+ #endregion
+
}
}
diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj
index 724287f6..d0bb12f2 100644
--- a/ENI2/ENI2.csproj
+++ b/ENI2/ENI2.csproj
@@ -218,6 +218,9 @@
Locode\LocodeDB.cs
+
+ BusyControl.xaml
+
ConditionGroupControl.xaml
@@ -453,6 +456,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/ENI2/EditControls/CompareExcelDialog.xaml.cs b/ENI2/EditControls/CompareExcelDialog.xaml.cs
index 36429513..62bfba7a 100644
--- a/ENI2/EditControls/CompareExcelDialog.xaml.cs
+++ b/ENI2/EditControls/CompareExcelDialog.xaml.cs
@@ -31,7 +31,7 @@ namespace ENI2.EditControls
#region Drag&Drop event handler
- private async void imageSource_Drop(object sender, DragEventArgs e)
+ private void imageSource_Drop(object sender, DragEventArgs e)
{
string[] files = (string[]) e.Data.GetData(DataFormats.FileDrop);
if (files != null)
diff --git a/ENI2/Util/UIHelper.cs b/ENI2/Util/UIHelper.cs
index 3edcad61..383881b9 100644
--- a/ENI2/Util/UIHelper.cs
+++ b/ENI2/Util/UIHelper.cs
@@ -5,10 +5,12 @@
using System;
using System.Collections.Generic;
+
using System.Reflection;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
+using System.Windows.Media.Imaging;
using System.Windows.Threading;
using bsmd.database;
@@ -20,6 +22,15 @@ namespace ENI2.Util
private static bool isBusy;
private static readonly Random r = new Random();
+
+
+ public enum BusyStateEnum
+ {
+ NEUTRAL,
+ BUSY,
+ FAIL,
+ SUCCESS
+ }
public static void SetBusyState()
{
@@ -28,15 +39,16 @@ namespace ENI2.Util
private static void SetBusyState(bool busy)
{
+
if(busy != isBusy)
{
isBusy = busy;
- Mouse.OverrideCursor = isBusy ? Cursors.Wait : null;
+ Mouse.OverrideCursor = isBusy ? Cursors.Wait : null;
}
if(isBusy)
{
- new DispatcherTimer(TimeSpan.FromSeconds(0), DispatcherPriority.ApplicationIdle, dispatcherTimer_Tick, Application.Current.Dispatcher);
+ _ = new DispatcherTimer(TimeSpan.FromSeconds(0), DispatcherPriority.ApplicationIdle, dispatcherTimer_Tick, Application.Current.Dispatcher);
}
}
@@ -44,13 +56,13 @@ namespace ENI2.Util
{
if (sender is DispatcherTimer timer)
{
- SetBusyState(false);
+ SetBusyState(false);
timer.Stop();
}
}
public static bool IsModal(this Window window)
- {
+ {
return (bool)typeof(Window).GetField("_showingAsDialog", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(window);
}
@@ -59,6 +71,38 @@ namespace ENI2.Util
return Color.FromRgb((byte) r.Next(150, 255), (byte) r.Next(150, 255), (byte) r.Next(150, 255));
}
+ public static BitmapSource CreateBitmapSource(this System.Drawing.Bitmap bitmap)
+ {
+ if (bitmap == null)
+ throw new ArgumentNullException("bitmap");
+
+ System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height);
+
+ System.Drawing.Imaging.BitmapData bitmapData = bitmap.LockBits(rect,
+ System.Drawing.Imaging.ImageLockMode.ReadWrite,
+ System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+
+ try
+ {
+ var size = rect.Width * rect.Height * 4;
+
+ return BitmapSource.Create(
+ bitmap.Width,
+ bitmap.Height,
+ bitmap.HorizontalResolution,
+ bitmap.VerticalResolution,
+ PixelFormats.Bgra32,
+ null,
+ bitmapData.Scan0,
+ size,
+ bitmapData.Stride);
+ }
+ finally
+ {
+ bitmap.UnlockBits(bitmapData);
+ }
+ }
+
public static void SetMessageIcons(List messages)
{
foreach (Message aMessage in messages)
@@ -159,6 +203,5 @@ namespace ENI2.Util
}
}
}
-
}
}
diff --git a/bsmd.database/DBManager.cs b/bsmd.database/DBManager.cs
index ed3c9426..735cf5cf 100644
--- a/bsmd.database/DBManager.cs
+++ b/bsmd.database/DBManager.cs
@@ -1537,7 +1537,7 @@ namespace bsmd.database
cmd.Connection = this._con;
// Stopwatch sw = new Stopwatch();
// sw.Start();
- reader = cmd.ExecuteReader();
+ reader = cmd.ExecuteReader();
// sw.Stop();
// _log.DebugFormat("{1}ms: {0}", cmd.CommandText, sw.ElapsedMilliseconds);