Arrows für Asp eingebaut
Aktualisierungsmöglichkeit und Export für Today für den Pförtner eingebaut
This commit is contained in:
parent
761641f71a
commit
dee300ade9
@ -173,7 +173,7 @@
|
||||
<RowDefinition Height="160"/>
|
||||
<RowDefinition x:Name="gridRowTop" Height="*" MinHeight="300"/>
|
||||
<RowDefinition Height="10" MinHeight="15" MaxHeight="15"/>
|
||||
<RowDefinition Height="1*" MinHeight="100"/>
|
||||
<RowDefinition x:Name="gridRowArrivals" Height="1*" MinHeight="100"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Canvas x:Name="canvasIvo" Visibility="Collapsed">
|
||||
@ -554,8 +554,19 @@
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Button x:Name="btnTableExport" Visibility="Collapsed" ToolTipService.InitialShowDelay="50" Grid.Row="3" Height="30" Width="60" Padding="0" Margin="220,-20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" ToolTip="Heutige Firmen und Besucher exportieren" Click="btnTableExport_Click">
|
||||
<Button.Content>
|
||||
<Image Source="/Resources/TableExport.png"/>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
|
||||
<Grid x:Name="gridToday" Grid.Row="1" Visibility="Collapsed" VerticalAlignment="Stretch" MinHeight="100" Margin="0,-10,0,0" >
|
||||
<Button x:Name="btnRefresh" Visibility="Collapsed" ToolTipService.InitialShowDelay="50" Grid.Row="3" Height="30" Width="30" Padding="3" Margin="290,-20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" ToolTip="Heutige Firmen- und Besucherliste manuell aktualisieren" Click="btnRefresh_Click">
|
||||
<Button.Content>
|
||||
<Image Source="/Resources/Refresh.png"/>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
|
||||
<Grid x:Name="gridToday" Grid.Row="1" Visibility="Collapsed" VerticalAlignment="Stretch" MinHeight="100" Margin="0,-10,0,0" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="columnLeft" Width="1.456*" MinWidth="1000"/>
|
||||
<ColumnDefinition Width="15"/>
|
||||
@ -786,13 +797,13 @@
|
||||
</TransformGroup>
|
||||
</TextBlock.RenderTransform>
|
||||
</TextBlock>
|
||||
<GridSplitter x:Name="gridSplitter" Cursor="SizeNS" ResizeDirection="Rows" ResizeBehavior="PreviousAndNext" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="300,10,300,-10" Height="3" Background="LightGray" Grid.IsSharedSizeScope="True" Visibility="Collapsed" DragCompleted="gridSplitter_DragCompleted"/>
|
||||
<GridSplitter x:Name="gridSplitter" Cursor="SizeNS" ResizeDirection="Rows" ResizeBehavior="PreviousAndNext" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="350,10,350,-10" Height="3" Background="LightGray" Grid.IsSharedSizeScope="True" Visibility="Collapsed" DragCompleted="gridSplitter_DragCompleted"/>
|
||||
<!---->
|
||||
|
||||
|
||||
|
||||
|
||||
<Grid x:Name="gridArrived" Margin="0,10,0,10" Grid.Row="3" Visibility="Collapsed" VerticalAlignment="Top" MinHeight="100">
|
||||
<Grid x:Name="gridArrived" Margin="0,10,0,10" Grid.Row="3" Visibility="Collapsed" VerticalAlignment="Bottom" MinHeight="10">
|
||||
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Width="300" Margin="10,10,0,0"><Run Text="Ankunft bereits bestätigt: (letzte 10 Tage)"/></TextBlock>
|
||||
|
||||
<DataGrid x:Name="dgOverview" MinHeight="90" RowHeaderWidth="0" HorizontalGridLinesBrush="Gray" GridLinesVisibility="Horizontal" KeyboardNavigation.TabNavigation="None" ItemsSource="{Binding ., UpdateSourceTrigger=PropertyChanged}" CanUserAddRows="False" CanUserDeleteRows="False" AutoGenerateColumns="False" Margin="10,31,10,0" CellEditEnding="dgOverview_CellEditEnding">
|
||||
|
||||
@ -3,6 +3,7 @@ using ControlzEx.Standard;
|
||||
using FuzzySharp;
|
||||
using MahApps.Metro.Controls;
|
||||
using Microsoft.Toolkit.Uwp.Notifications;
|
||||
using Microsoft.Win32;
|
||||
using MySql.Data.MySqlClient;
|
||||
using MySql.Data.Types;
|
||||
using System;
|
||||
@ -28,6 +29,8 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.Storage.Streams;
|
||||
using Windows.UI.Composition;
|
||||
using Process = System.Diagnostics.Process;
|
||||
|
||||
@ -46,7 +49,7 @@ namespace ZKuP
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public static string Version { get; } = "5.2.5.2";
|
||||
public static string Version { get; } = "5.2.6.1";
|
||||
//public static Roles LoggedInRole { get; private set; } = Roles.None;
|
||||
internal static MainWindow main;
|
||||
ThemeManager TM;
|
||||
@ -369,6 +372,7 @@ namespace ZKuP
|
||||
|
||||
private void OnWindowMoveFinished()
|
||||
{
|
||||
CheckArrivalsSpacing(gridSplitter, null);
|
||||
Helper.CheckScale(this);
|
||||
}
|
||||
|
||||
@ -537,23 +541,36 @@ namespace ZKuP
|
||||
RoleManager.LoggedInRole != Roles.None)
|
||||
{
|
||||
var id = SQL.ReadSingleValue($"SELECT idusers FROM {MainWindow.table}.users WHERE `Username` = '{Environment.UserName}'");
|
||||
var aspId = SQL.ReadSingleValue($"SELECT EXISTS (SELECT 1 FROM ansprechpartner WHERE CreatorID = '{id}')");
|
||||
var aspId = SQL.ReadSingleValue($"SELECT EXISTS (SELECT 1 FROM {MainWindow.table}.ansprechpartner WHERE CreatorID = '{id}')");
|
||||
|
||||
if (aspId != "0")
|
||||
{
|
||||
var res = SQL.ReadSQL($"SELECT * FROM {MainWindow.table}.ansprechpartner WHERE CreatorID = '{id}'").Result;
|
||||
var firstRow = res.Rows[0];
|
||||
bool hasEmptyOrNull = firstRow.ItemArray.Any(field =>
|
||||
field == DBNull.Value ||
|
||||
(field is string str && string.IsNullOrWhiteSpace(str))
|
||||
);
|
||||
var emptyFields = firstRow.Table.Columns
|
||||
.Cast<DataColumn>()
|
||||
.Where(col =>
|
||||
{
|
||||
var value = firstRow[col];
|
||||
return value == DBNull.Value ||
|
||||
(value is string s && string.IsNullOrWhiteSpace(s));
|
||||
})
|
||||
.Select(col => col.ColumnName)
|
||||
.ToList();
|
||||
|
||||
if (hasEmptyOrNull)
|
||||
//bool hasEmptyOrNull = firstRow.ItemArray.Any(field =>
|
||||
// field == DBNull.Value ||
|
||||
// (field is string str && string.IsNullOrWhiteSpace(str))
|
||||
// );
|
||||
|
||||
if (emptyFields.Count > 0)
|
||||
{
|
||||
if (MessageBoxResult.OK == MessageBox.Show("Ihr Eintrag als Ansprechpartner ist nicht vorhanden oder unvollständig!\n\nBitte erstellen oder vervollständigen", "Fehlende Asp Informationen", MessageBoxButton.OK, MessageBoxImage.Warning))
|
||||
{
|
||||
ManageAsp map = new ManageAsp();
|
||||
ManageAsp map = new ManageAsp(emptyFields);
|
||||
map.ShowDialog();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1135,7 +1152,12 @@ namespace ZKuP
|
||||
private async Task getToday()
|
||||
{
|
||||
bool isVisible = false;
|
||||
Dispatcher.Invoke(() => isVisible = gridToday.Visibility == Visibility.Visible);
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
isVisible = gridToday.Visibility == Visibility.Visible;
|
||||
Cursor = Cursors.Wait;
|
||||
});
|
||||
|
||||
if (isVisible)
|
||||
{
|
||||
//bool changeTable = false;
|
||||
@ -1250,6 +1272,8 @@ namespace ZKuP
|
||||
q.Click += BtnInfo_Click;
|
||||
}));
|
||||
}
|
||||
|
||||
Dispatcher.Invoke(() => Cursor = Cursors.Arrow);
|
||||
}
|
||||
|
||||
|
||||
@ -2740,6 +2764,11 @@ namespace ZKuP
|
||||
|
||||
|
||||
private void gridSplitter_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
|
||||
{
|
||||
CheckArrivalsSpacing(sender, e);
|
||||
}
|
||||
|
||||
private void CheckArrivalsSpacing(object sender, DragCompletedEventArgs e)
|
||||
{
|
||||
GridSplitter splitter = sender as GridSplitter;
|
||||
Window window = Window.GetWindow(splitter);
|
||||
@ -2748,16 +2777,29 @@ namespace ZKuP
|
||||
|
||||
Point splitterPosition = splitter.TransformToAncestor(window).Transform(new Point(0, 0));
|
||||
|
||||
if (splitterPosition.Y > ((this.ActualHeight - 190) / Helper.scale))
|
||||
var arrivalsHeight = this.ActualHeight - splitterPosition.Y;
|
||||
|
||||
var x = gridRowArrivals.ActualHeight;
|
||||
|
||||
|
||||
if(arrivalsHeight < 100)
|
||||
{
|
||||
e.Handled = true; // Bewegung stoppen
|
||||
gridRowTop.Height = new GridLength((this.ActualHeight - 160 - 190) / (Helper.scale == 0 ? 1 : Helper.scale));
|
||||
//if (arrivalsHeight < ((this.ActualHeight * .05)))
|
||||
//{
|
||||
if(e != null) e.Handled = true; // Bewegung stoppen 160: MenuRow Height
|
||||
//gridRowTop.Height = new GridLength((this.ActualHeight - Main.ActualHeight - (this.ActualHeight * .05)) / (Helper.scale == 0 ? 1 : Helper.scale));
|
||||
//gridRowTop.Height = new GridLength(this.ActualHeight - Main.ActualHeight - (this.ActualHeight * .05));// / (Helper.scale == 0 ? 1 : Helper.scale));
|
||||
gridRowTop.Height = new GridLength(this.ActualHeight - Main.ActualHeight - 100);
|
||||
}
|
||||
//if (splitterPosition.Y > ((this.ActualHeight - 160) / Helper.scale))
|
||||
//{
|
||||
// e.Handled = true; // Bewegung stoppen 160: MenuRow Height
|
||||
// gridRowTop.Height = new GridLength((this.ActualHeight - 160 - 160) / (Helper.scale == 0 ? 1 : Helper.scale));
|
||||
//}
|
||||
|
||||
Settings.WriteSetting("SplitterPos", gridRowTop.Height.Value);
|
||||
}
|
||||
|
||||
|
||||
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
|
||||
@ -3053,6 +3095,24 @@ namespace ZKuP
|
||||
lAb.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
lAb.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void btnTableExport_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FileDialog file = new SaveFileDialog();
|
||||
file.DefaultExt = "*.csv";
|
||||
file.Filter = "CSV Datei | *.csv";
|
||||
file.ShowDialog();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(file.FileName))
|
||||
TableExporter.ExportToCsv(file.FileName, new DataGrid[] { dgToday, dgTodayBesucher });
|
||||
}
|
||||
|
||||
private void btnRefresh_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
getToday();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -7,8 +7,72 @@
|
||||
xmlns:local="clr-namespace:ZKuP"
|
||||
mc:Ignorable="d"
|
||||
Title="Ansprechpartner verwalten" Height="450" Width="1180"
|
||||
WindowStartupLocation="CenterScreen" MinHeight="450" MinWidth="1180">
|
||||
<Grid>
|
||||
WindowStartupLocation="CenterScreen" MinHeight="450" MinWidth="1180" ClipToBounds="False">
|
||||
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<Storyboard x:Key="ArrowBounceStoryboard" RepeatBehavior="5x">
|
||||
<!-- Vertikales Hüpfen -->
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
Storyboard.TargetName="arrowTel_Nr"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform.Y)">
|
||||
|
||||
<!-- Ausgangspunkt -->
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
|
||||
|
||||
<!-- Hoch (Start des Hops) -->
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:1.15" Value="-25">
|
||||
<EasingDoubleKeyFrame.EasingFunction>
|
||||
<CubicEase EasingMode="EaseOut"/>
|
||||
</EasingDoubleKeyFrame.EasingFunction>
|
||||
</EasingDoubleKeyFrame>
|
||||
|
||||
<!-- Runter + leichter Aufprall -->
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:1.0" Value="0">
|
||||
<EasingDoubleKeyFrame.EasingFunction>
|
||||
<BounceEase Bounces="1" Bounciness="1.5" EasingMode="EaseOut"/>
|
||||
</EasingDoubleKeyFrame.EasingFunction>
|
||||
</EasingDoubleKeyFrame>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
|
||||
|
||||
<!-- Squeeze beim Aufprall: ScaleX + ScaleY -->
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
Storyboard.TargetName="arrowTel_Nr"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
|
||||
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="1"/>
|
||||
|
||||
<!-- kurz beim Auftreffen etwas breiter -->
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:1.30" Value="1.08">
|
||||
<EasingDoubleKeyFrame.EasingFunction>
|
||||
<CubicEase EasingMode="EaseOut"/>
|
||||
</EasingDoubleKeyFrame.EasingFunction>
|
||||
</EasingDoubleKeyFrame>
|
||||
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:1.45" Value="1"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
Storyboard.TargetName="arrowTel_Nr"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
|
||||
|
||||
<DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="1"/>
|
||||
|
||||
<!-- bei breiterem X leicht flacher -->
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:1.30" Value="0.92">
|
||||
<EasingDoubleKeyFrame.EasingFunction>
|
||||
<CubicEase EasingMode="EaseOut"/>
|
||||
</EasingDoubleKeyFrame.EasingFunction>
|
||||
</EasingDoubleKeyFrame>
|
||||
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:1.45" Value="1"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid ClipToBounds="False">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="230"/>
|
||||
<ColumnDefinition/>
|
||||
@ -42,13 +106,56 @@
|
||||
<DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Button Content="3" Width="20" Height="20" Padding="0,2,0,0" Foreground="Red" ToolTip="Eintrag löschen" ToolTipService.ShowOnDisabled="True" FontFamily="Wingdings 2" FontSize="18" Click="DeleteButton_Click" Loaded="DelButton_Loaded"/>
|
||||
<Button Content="3" Width="20" Height="20" Padding="0,2,0,0" ToolTip="Eintrag löschen" ToolTipService.ShowOnDisabled="True" FontFamily="Wingdings 2" FontSize="18" Click="DeleteButton_Click" Loaded="DelButton_Loaded"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Image x:Name="arrowName" Source="/Resources/arrow.png" Grid.Column="1" Width="50" HorizontalAlignment="Left" Margin="120,-90,0,0" Visibility="Collapsed"/>
|
||||
<Image x:Name="arrowRaum" Source="/Resources/arrow.png" Grid.Column="1" Width="50" HorizontalAlignment="Left" Margin="230,-90,0,0" Visibility="Collapsed"/>
|
||||
<Image x:Name="arrowVertreter" Source="/Resources/arrow.png" Grid.Column="1" Width="50" HorizontalAlignment="Left" Margin="350,-90,0,0" Visibility="Collapsed"/>
|
||||
<Image x:Name="arrowVorgesetzter" Source="/Resources/arrow.png" Grid.Column="1" Width="50" HorizontalAlignment="Left" Margin="470,-90,0,0" Visibility="Collapsed"/>
|
||||
|
||||
<!--<Popup x:Name="ArrowPopup"
|
||||
PlacementTarget="{Binding ElementName=RootGrid}"
|
||||
Placement="Left"
|
||||
AllowsTransparency="True"
|
||||
StaysOpen="True"
|
||||
IsOpen="True" HorizontalOffset="870" VerticalOffset="-90" ClipToBounds="False">
|
||||
--><!-- per Code öffnen/schließen --><!--
|
||||
<Border Background="Transparent">
|
||||
<Image x:Name="arrowTel_Nr"
|
||||
Source="/Resources/arrow.png"
|
||||
Width="60" Height="200"
|
||||
RenderTransformOrigin="0.5,0.5">
|
||||
<Image.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform/>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</Image.RenderTransform>
|
||||
</Image>
|
||||
</Border>
|
||||
</Popup>-->
|
||||
<Image x:Name="arrowTel_Nr" Source="/Resources/arrow.png" Visibility="Visible" Grid.Column="1" Width="50" HorizontalAlignment="Left" Margin="590,-90,0,0" >
|
||||
<!--<Image.RenderTransform>
|
||||
<TransformGroup>
|
||||
0 = Scale, 1 = Translate, 2 = Rotate
|
||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
<RotateTransform Angle="0"/>
|
||||
</TransformGroup>
|
||||
</Image.RenderTransform>-->
|
||||
</Image>
|
||||
|
||||
<Image x:Name="arrowTel_Vertreter" Source="/Resources/arrow.png" Grid.Column="1" Width="50" HorizontalAlignment="Left" Margin="700,-90,0,0" Visibility="Collapsed"/>
|
||||
<Image x:Name="arrowTel_Vorgesetzter" Source="/Resources/arrow.png" Grid.Column="1" Width="50" HorizontalAlignment="Left" Margin="820,-90,0,0" Visibility="Collapsed"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<StackPanel Grid.Row="0" Margin="0,10,0,0">
|
||||
<TextBlock HorizontalAlignment="Left" Foreground="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" Grid.Row="0" Margin="10,0,0,0" TextWrapping="Wrap" Text="Ansprechpartner:" VerticalAlignment="Top" Width="110"/>
|
||||
<TextBox x:Name="tbAsp" Grid.Row="0" HorizontalAlignment="Left" Height="25" Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="215" Padding="0,2,0,0" TabIndex="1"/>
|
||||
|
||||
@ -13,6 +13,7 @@ using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
@ -35,7 +36,7 @@ namespace ZKuP
|
||||
DataTable asp = new DataTable("Asp");
|
||||
string UserID = "-1";
|
||||
|
||||
public ManageAsp()
|
||||
public ManageAsp(List<string> Columns = null)
|
||||
{
|
||||
this.DataContext = this;
|
||||
|
||||
@ -46,8 +47,17 @@ namespace ZKuP
|
||||
if (UserID == "1" && Environment.UserName.ToLower() != "marcusbachler") Log.WriteLog("UserID Fail");
|
||||
|
||||
Query();
|
||||
|
||||
if (Columns != null)
|
||||
{
|
||||
foreach (var col in Columns)
|
||||
{
|
||||
CreateBlinkStoryboard(col).Begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Query()
|
||||
{
|
||||
if (RoleManager.LoggedInRole == Roles.Admin)
|
||||
@ -240,6 +250,46 @@ namespace ZKuP
|
||||
{
|
||||
Helper.CheckWindowIsInScreenSpace(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Storyboard CreateBlinkStoryboard(string target)
|
||||
{
|
||||
var storyboard = new Storyboard
|
||||
{
|
||||
RepeatBehavior = RepeatBehavior.Forever
|
||||
};
|
||||
|
||||
var animation = new DoubleAnimationUsingKeyFrames();
|
||||
|
||||
var element = (FrameworkElement)this.FindName("arrow" + target);
|
||||
|
||||
if (element == null) return null;
|
||||
|
||||
element.Visibility = Visibility.Visible;
|
||||
Storyboard.SetTarget(animation, element);
|
||||
Storyboard.SetTargetProperty(animation, new PropertyPath(UIElement.OpacityProperty));
|
||||
|
||||
animation.KeyFrames.Add(new EasingDoubleKeyFrame
|
||||
{
|
||||
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)),
|
||||
Value = 1
|
||||
});
|
||||
|
||||
animation.KeyFrames.Add(new EasingDoubleKeyFrame
|
||||
{
|
||||
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.5)),
|
||||
Value = 0
|
||||
});
|
||||
|
||||
animation.KeyFrames.Add(new EasingDoubleKeyFrame
|
||||
{
|
||||
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)),
|
||||
Value = 1
|
||||
});
|
||||
|
||||
storyboard.Children.Add(animation);
|
||||
return storyboard;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
ZKuP/Resources/Refresh.png
Normal file
BIN
ZKuP/Resources/Refresh.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 738 B |
BIN
ZKuP/Resources/TableExport.png
Normal file
BIN
ZKuP/Resources/TableExport.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 205 KiB |
BIN
ZKuP/Resources/arrow.png
Normal file
BIN
ZKuP/Resources/arrow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1008 B |
@ -392,6 +392,11 @@ namespace ZKuP
|
||||
main.BE.Visibility = Visibility.Visible;
|
||||
main.BesuchP.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
main.btnRefresh.Visibility = Visibility.Visible;
|
||||
main.btnTableExport.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
main.tcMainMenu.SelectedIndex = 2;
|
||||
}
|
||||
|
||||
|
||||
146
ZKuP/TableExporter.cs
Normal file
146
ZKuP/TableExporter.cs
Normal file
@ -0,0 +1,146 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ZKuP
|
||||
{
|
||||
public static class TableExporter
|
||||
{
|
||||
public static void ExportToCsv(string filePath, params DataGrid[] grids)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
foreach (var dg in grids)
|
||||
{
|
||||
var table = TryGetDataTable(dg);
|
||||
|
||||
// sichtbare Spalten
|
||||
var cols = dg.Columns
|
||||
.Where(c => c.Visibility == Visibility.Visible)
|
||||
.ToList();
|
||||
|
||||
// Header
|
||||
sb.AppendLine(string.Join(";", cols.Select(c => Escape(GetHeader(c)))));
|
||||
|
||||
if (table != null)
|
||||
{
|
||||
// --- CSV aus DataTable (immer vollständig, unabhängig von Virtualisierung) ---
|
||||
foreach (DataRow row in table.Rows)
|
||||
{
|
||||
var vals = cols.Select(col =>
|
||||
{
|
||||
var name = GetBindingPath(col);
|
||||
if (name != null && table.Columns.Contains(name))
|
||||
return Escape(Convert.ToString(row[name]));
|
||||
return "";
|
||||
});
|
||||
|
||||
sb.AppendLine(string.Join(";", vals));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// --- Fallback: Items → Reflection über BindingPath ---
|
||||
foreach (var item in GetAllItems(dg))
|
||||
{
|
||||
var vals = cols.Select(col =>
|
||||
{
|
||||
var path = GetBindingPath(col);
|
||||
if (path == null) return "";
|
||||
var val = GetPropertyValue(item, path);
|
||||
return Escape(val?.ToString() ?? "");
|
||||
});
|
||||
|
||||
sb.AppendLine(string.Join(";", vals));
|
||||
}
|
||||
}
|
||||
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
File.WriteAllText(filePath, sb.ToString(), Encoding.UTF8);
|
||||
}
|
||||
|
||||
// ---------------- Hilfsfunktionen ----------------
|
||||
|
||||
private static DataTable TryGetDataTable(DataGrid dg)
|
||||
{
|
||||
if (dg.ItemsSource is DataView dv) return dv.Table;
|
||||
if (dg.ItemsSource is DataTable dt) return dt;
|
||||
|
||||
if (dg.ItemsSource is IEnumerable ie)
|
||||
{
|
||||
var first = ie.Cast<object>().FirstOrDefault();
|
||||
if (first is DataRowView drv) return drv.DataView.Table;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static IEnumerable GetAllItems(DataGrid dg)
|
||||
{
|
||||
if (dg.ItemsSource == null)
|
||||
return dg.Items.Cast<object>().Where(x => x != CollectionView.NewItemPlaceholder);
|
||||
|
||||
if (dg.ItemsSource is System.ComponentModel.ICollectionView cv)
|
||||
return cv.SourceCollection;
|
||||
|
||||
return dg.ItemsSource as IEnumerable;
|
||||
}
|
||||
|
||||
private static string GetHeader(DataGridColumn col)
|
||||
{
|
||||
if (col.Header is string s) return s;
|
||||
return col.Header?.ToString() ?? "";
|
||||
}
|
||||
|
||||
private static string GetBindingPath(DataGridColumn col)
|
||||
{
|
||||
if (col is DataGridBoundColumn bc && bc.Binding is Binding b && b.Path != null)
|
||||
return b.Path.Path;
|
||||
|
||||
if (col is DataGridCheckBoxColumn cb && cb.Binding is Binding b2 && b2.Path != null)
|
||||
return b2.Path.Path;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static object GetPropertyValue(object obj, string path)
|
||||
{
|
||||
var parts = path.Split('.');
|
||||
object current = obj;
|
||||
|
||||
foreach (var part in parts)
|
||||
{
|
||||
if (current == null) return null;
|
||||
|
||||
var type = current.GetType();
|
||||
var prop = type.GetProperty(part, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
|
||||
if (prop == null) return null;
|
||||
|
||||
current = prop.GetValue(current);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
private static string Escape(string s)
|
||||
{
|
||||
if (s == null) return "";
|
||||
if (s.Contains(";") || s.Contains("\""))
|
||||
return "\"" + s.Replace("\"", "\"\"") + "\"";
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -336,6 +336,7 @@
|
||||
<Compile Include="signoPad.cs" />
|
||||
<Compile Include="SQL.cs" />
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
<Compile Include="TableExporter.cs" />
|
||||
<Compile Include="ThemeManager.cs" />
|
||||
<Compile Include="ucSpinnerPiston.xaml.cs">
|
||||
<DependentUpon>ucSpinnerPiston.xaml</DependentUpon>
|
||||
@ -898,5 +899,14 @@
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Loading2.gif" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\TableExport.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Refresh.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\arrow.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Loading…
x
Reference in New Issue
Block a user