wip
This commit is contained in:
parent
2e91da8f3b
commit
5f28c8c7ea
14
ENI2/Controls/BusyControl.xaml
Normal file
14
ENI2/Controls/BusyControl.xaml
Normal file
@ -0,0 +1,14 @@
|
||||
<UserControl x:Class="ENI2.Controls.BusyControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:p="clr-namespace:ENI2.Properties"
|
||||
xmlns:util="clr-namespace:ENI2.Util"
|
||||
xmlns:local="clr-namespace:ENI2.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="28" d:DesignWidth="28">
|
||||
<Grid>
|
||||
<Image Source="../Resources/bullet_ball_grey.png" x:Name="imageBall" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
44
ENI2/Controls/BusyControl.xaml.cs
Normal file
44
ENI2/Controls/BusyControl.xaml.cs
Normal file
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for BusyControl.xaml
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -24,12 +24,21 @@
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label Content="Calendar week" />
|
||||
<Label Content="Type" />
|
||||
<Button x:Name="buttonImport" Margin="2" Content="Import" Width="70" />
|
||||
<Button x:Name="buttonExport" Margin="2" Content="Export" Width="70" />
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="30" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="Calendar week" Grid.Column="0"/>
|
||||
<Button x:Name="buttonLoad" Grid.Column="1" Content="Load" Margin="2" Click="buttonLoad_Click" />
|
||||
<Button x:Name="buttonImport" Grid.Column="2" Margin="2" Content="Import" Click="buttonImport_Click" />
|
||||
<Button x:Name="buttonExport" Grid.Column="3" Margin="2" Content="Export" Click="buttonExport_Click" />
|
||||
<local:BusyControl x:Name="busyControl" Grid.Column="5" />
|
||||
</Grid>
|
||||
<local:ENIDataGrid Grid.Row="1" Margin="2,8,2,2" x:Name="dataGridPOCores" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
|
||||
SelectionMode="Single" AutoGenerateColumns="False" CellEditEnding="dataGridPOCores_CellEditEnding" CanUserAddRows="False">
|
||||
<DataGrid.Columns>
|
||||
|
||||
@ -113,11 +113,6 @@ namespace ENI2.Controls
|
||||
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.
|
||||
|
||||
|
||||
Dictionary<MessageCore.SearchFilterType, string> filterDict = new Dictionary<MessageCore.SearchFilterType, string>();
|
||||
|
||||
DateTime start = DateTime.Now; // bsmd.database.Util.FirstDateOfWeekISO8601(DateTime.Now.Year, (int)this.doubleUpDownCalendarWeek.Value);
|
||||
@ -128,8 +123,6 @@ namespace ENI2.Controls
|
||||
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();
|
||||
|
||||
// suche auslösen
|
||||
this.searchResult = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoresWithFilters(filterDict);
|
||||
// alle anderen Häfen weg
|
||||
@ -182,5 +175,25 @@ 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
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,6 +218,9 @@
|
||||
<Compile Include="..\bsmd.ExcelReadService\LocodeDB.cs">
|
||||
<Link>Locode\LocodeDB.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Controls\BusyControl.xaml.cs">
|
||||
<DependentUpon>BusyControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\ClosableTabItem.cs" />
|
||||
<Compile Include="Controls\ConditionGroupControl.xaml.cs">
|
||||
<DependentUpon>ConditionGroupControl.xaml</DependentUpon>
|
||||
@ -453,6 +456,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Controls\BusyControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Controls\ConditionGroupControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
@ -21,6 +23,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()
|
||||
{
|
||||
SetBusyState(true);
|
||||
@ -28,6 +39,7 @@ namespace ENI2.Util
|
||||
|
||||
private static void SetBusyState(bool busy)
|
||||
{
|
||||
|
||||
if(busy != isBusy)
|
||||
{
|
||||
isBusy = busy;
|
||||
@ -36,7 +48,7 @@ namespace ENI2.Util
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<Message> messages)
|
||||
{
|
||||
foreach (Message aMessage in messages)
|
||||
@ -159,6 +203,5 @@ namespace ENI2.Util
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user