Squashed 'FSI.Lib/' content from commit dceb500
git-subtree-dir: FSI.Lib git-subtree-split: dceb5008a2176c2b8ab5e55a73b1c25d31a7f841
This commit is contained in:
54
FSI.Lib/Guis/AutoPw/FrmMain.xaml
Normal file
54
FSI.Lib/Guis/AutoPw/FrmMain.xaml
Normal file
@@ -0,0 +1,54 @@
|
||||
<Window x:Class="FSI.Lib.Guis.AutoPw.FrmMain"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FSI.Lib.Guis.AutoPw"
|
||||
mc:Ignorable="d"
|
||||
Title="Passwort eingeben"
|
||||
SizeToContent="WidthAndHeight"
|
||||
Height="Auto"
|
||||
Width="Auto"
|
||||
Icon="../../Icons/FondiumU.ico"
|
||||
WindowStyle="ToolWindow">
|
||||
|
||||
<Grid FocusManager.FocusedElement="{Binding ElementName=TbPw}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Passwort:"
|
||||
Margin="5 5" />
|
||||
<PasswordBox x:Name="TbPw"
|
||||
Margin=" 5 5 5 5"
|
||||
MinWidth="150"
|
||||
PasswordChanged="TbPw_PasswordChanged"
|
||||
KeyDown="TbPw_KeyDown"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
Orientation="Horizontal">
|
||||
<Button x:Name="BtnOk"
|
||||
Content="Ok"
|
||||
MinWidth="75"
|
||||
Click="BtnOk_Click"
|
||||
Margin="5 5 " />
|
||||
|
||||
<Button x:Name="BtnCancel"
|
||||
Content="Abbruch"
|
||||
MinWidth="75"
|
||||
Click="BtnCancel_Click"
|
||||
Margin="5 5 " />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<StatusBar Grid.Row="2">
|
||||
<StatusBarItem HorizontalAlignment="Right">
|
||||
<TextBlock Text="{Binding CurrentTime}" />
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
</Window>
|
||||
81
FSI.Lib/Guis/AutoPw/FrmMain.xaml.cs
Normal file
81
FSI.Lib/Guis/AutoPw/FrmMain.xaml.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace FSI.Lib.Guis.AutoPw
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für FrmMain.xaml
|
||||
/// </summary>
|
||||
public partial class FrmMain : Window
|
||||
{
|
||||
public bool CloseAtLostFocus { get; set; }
|
||||
public bool PwOk { get; set; }
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
BtnOk.IsEnabled = false;
|
||||
Deactivated += FrmMain_Deactivated;
|
||||
DataContext = new MVVM.ViewModel.CurrentTimeViewModel();
|
||||
}
|
||||
|
||||
private void FrmMain_Deactivated(object sender, System.EventArgs e)
|
||||
{
|
||||
if (CloseAtLostFocus)
|
||||
Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void BtnOk_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void BtnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
PwOk = false;
|
||||
}
|
||||
|
||||
|
||||
private void TbPw_PasswordChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
if (((PasswordBox)sender).Password.Equals(DateTime.Now.ToString("yyyyMMdd")))
|
||||
{
|
||||
BtnOk.IsEnabled = true;
|
||||
PwOk = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
BtnOk.IsEnabled = false;
|
||||
PwOk = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void TbPw_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (BtnOk.IsEnabled == true)
|
||||
{
|
||||
Close();
|
||||
PwOk = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Close();
|
||||
PwOk = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
55
FSI.Lib/Guis/DeEncryptMessage/FrmMain.xaml
Normal file
55
FSI.Lib/Guis/DeEncryptMessage/FrmMain.xaml
Normal file
@@ -0,0 +1,55 @@
|
||||
<Window x:Class="FSI.Lib.Guis.DeEncryptMessage.FrmMain"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FSI.Lib.Guis.DeEncryptMessage"
|
||||
mc:Ignorable="d"
|
||||
Title="FSI Message Ent-/Verschlüsseln"
|
||||
SizeToContent="WidthAndHeight"
|
||||
Height="Auto"
|
||||
Width="Auto"
|
||||
Icon="../../Icons/FondiumU.ico">
|
||||
|
||||
<Grid MinWidth="300">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MinHeight="100" />
|
||||
<RowDefinition MinHeight="100" />
|
||||
<RowDefinition MaxHeight="30"
|
||||
Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBox x:Name="tbInput"
|
||||
TextWrapping="Wrap"
|
||||
AcceptsReturn="True"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
|
||||
<TextBox x:Name="tboutput"
|
||||
Grid.Row="1"
|
||||
AcceptsReturn="True"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Grid.Row="2">
|
||||
<Button x:Name="btnCrypt"
|
||||
Content="verschlüsseln"
|
||||
Margin="5 5 5 5 "
|
||||
Click="btnCrypt_Click" />
|
||||
<Button x:Name="btnDeCrypt"
|
||||
Content="entschlüsseln"
|
||||
Margin="5 5 5 5 "
|
||||
Click="btnDeCrypt_Click" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<StatusBar Grid.Row="3">
|
||||
<StatusBarItem HorizontalAlignment="Right">
|
||||
<TextBlock Text="{Binding CurrentTime}" />
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
61
FSI.Lib/Guis/DeEncryptMessage/FrmMain.xaml.cs
Normal file
61
FSI.Lib/Guis/DeEncryptMessage/FrmMain.xaml.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace FSI.Lib.Guis.DeEncryptMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für FrmMain.xaml
|
||||
/// </summary>
|
||||
public partial class FrmMain : Window
|
||||
{
|
||||
public string Password { get; set; }
|
||||
public bool CloseAtLostFocus { get; set; }
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
Deactivated += FrmMain_Deactivated;
|
||||
DataContext = new MVVM.ViewModel.CurrentTimeViewModel();
|
||||
}
|
||||
|
||||
private void FrmMain_Deactivated(object sender, System.EventArgs e)
|
||||
{
|
||||
if (CloseAtLostFocus)
|
||||
Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void btnDeCrypt_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
tboutput.Text = DeEncryptString.DeEncrypt.DecryptString(tbInput.Text, Password);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Text kann nicht entschlüsselt werden!", "Achtung", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCrypt_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
tboutput.Text = DeEncryptString.DeEncrypt.CryptString(tbInput.Text, Password);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Text kann nicht verschlüsselt werden!", "Achtung", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
116
FSI.Lib/Guis/Pdf.Mgt/Cmds.cs
Normal file
116
FSI.Lib/Guis/Pdf.Mgt/Cmds.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FSI.Lib.Guis.Pdf.Mgt
|
||||
{
|
||||
public class Cmds
|
||||
{
|
||||
public static Task DelDirectoriesAsync(string path)
|
||||
{
|
||||
return Task.Factory.StartNew(() =>
|
||||
{
|
||||
Action<string> DelPath = null;
|
||||
DelPath = p =>
|
||||
{
|
||||
Directory.EnumerateFiles(p).ToList().ForEach(System.IO.File.Delete); // Dateien im Verzeichnis löschen
|
||||
Directory.EnumerateDirectories(p).ToList().ForEach(DelPath);
|
||||
Directory.EnumerateDirectories(p).ToList().ForEach(Directory.Delete); // Verzeichnis löschen
|
||||
};
|
||||
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
string[] directories = Directory.GetDirectories(path); // Alle Unterverzeichniss auslesen
|
||||
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
if (!(directory.Replace(path, "")).StartsWith(".")) // Überprüfen ob Verzeichnis mit "." startet
|
||||
{
|
||||
DelPath(directory); // Unterverzeichnisse inkl. Dateien löschen
|
||||
Directory.Delete(directory); // Verzeichnis löschen
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Task DelFilesAsync(string path)
|
||||
{
|
||||
return Task.Factory.StartNew(() =>
|
||||
{
|
||||
var files = Directory.GetFiles(path);
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(file);
|
||||
|
||||
const int STR_LENGTH = 27; // min. Dateinamen Länge (Zahlen inkl. Bindestriche)
|
||||
|
||||
if (!fileInfo.Name.StartsWith(".")) // Überprüfen ob Datei mit "." startet
|
||||
{
|
||||
if (fileInfo.Extension != ".pdf" || fileInfo.Name.Length <= STR_LENGTH) // Überprüfen ob es sich um eine PDF-Datei handelt
|
||||
{
|
||||
System.IO.File.Delete(fileInfo.FullName); // ... wenn nicht Datei löschen
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] fileStrings = fileInfo.Name.Substring(0, STR_LENGTH - 1).Split('-'); // Zahlenblock splitten für Überprüfung
|
||||
|
||||
if (fileStrings.Length == 3) // 3 Zahlenblöcke vorhanden?
|
||||
{
|
||||
if (fileStrings[0].Length != 10 || !Int64.TryParse(fileStrings[0], out _) || fileStrings[1].Length != 10 || !Int64.TryParse(fileStrings[1], out _) || fileStrings[2].Length != 4 || !Int64.TryParse(fileStrings[2], out _)) // Länge der Zahlenblöcke überprüfen
|
||||
{
|
||||
System.IO.File.Delete(fileInfo.FullName); // ..., wenn Länge nicht passt, Datei löschen
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.IO.File.Delete(fileInfo.FullName); // ..., wenn nicht Datei löschen
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Task CreatePdfShortcutsAsync(string path)
|
||||
{
|
||||
return Task.Factory.StartNew(() =>
|
||||
{
|
||||
var files = Directory.GetFiles(path, "*.pdf"); // alle PDF-Dateien einlesen
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(file);
|
||||
|
||||
string[] fileStrings = System.IO.Path.GetFileNameWithoutExtension(fileInfo.Name).Split(' '); // Datei-Namen für Verzeichnis Bezeichnung aufteilen
|
||||
|
||||
string tmpPath = path + fileStrings[1] + " " + fileStrings[2]; // Verzeichnis Bezeichnung zusammenstellen
|
||||
|
||||
if (Convert.ToBoolean(ConfigurationManager.AppSettings["SubDir"])) // mit/ohne Unterverzeichnis
|
||||
{
|
||||
tmpPath = path + fileStrings[1] + @"\" + fileStrings[2]; // mit Unterverzeichnis
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpPath = path + fileStrings[1] + " " + fileStrings[2]; // ohne Unterverzeichnis
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(tmpPath); // Verzeichnis erstellen
|
||||
|
||||
// Shortcut erstellen
|
||||
if (Convert.ToBoolean(ConfigurationManager.AppSettings["WithNo"]))
|
||||
{
|
||||
LnkParser.ShortCut.Create(System.IO.Path.GetFileNameWithoutExtension(tmpPath + "\\" + fileInfo.Name), tmpPath, fileInfo.FullName, System.IO.Path.GetFileNameWithoutExtension(fileInfo.FullName));
|
||||
}
|
||||
else
|
||||
{
|
||||
LnkParser.ShortCut.Create(System.IO.Path.GetFileNameWithoutExtension(fileInfo.Name.Replace(fileStrings[0], "")), tmpPath, fileInfo.FullName, System.IO.Path.GetFileNameWithoutExtension(fileInfo.FullName));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
68
FSI.Lib/Guis/Pdf.Mgt/FrmMain.xaml
Normal file
68
FSI.Lib/Guis/Pdf.Mgt/FrmMain.xaml
Normal file
@@ -0,0 +1,68 @@
|
||||
<Window x:Class="FSI.Lib.Guis.Pdf.Mgt.FrmMain"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FSI.Lib.Guis.Pdf.Mgt"
|
||||
mc:Ignorable="d"
|
||||
Title="FSI Eplan PDF Mgt"
|
||||
SizeToContent="WidthAndHeight"
|
||||
Height="Auto"
|
||||
Width="Auto"
|
||||
Icon="../../Icons/FondiumU.ico"
|
||||
WindowStyle="ToolWindow">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MaxHeight="30"
|
||||
Height="*" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button x:Name="btnCleanUp"
|
||||
Content="aufräumen"
|
||||
Margin="5 5 5 5 "
|
||||
Click="btnCleanUp_Click" />
|
||||
<Button x:Name="btnCreateShortcuts"
|
||||
Content="Verknüpfungen erstellen"
|
||||
Margin="5 5 5 5 "
|
||||
Click="btnCreateShortcuts_Click" />
|
||||
<Button x:Name="btnStart"
|
||||
Content="alles ausführen"
|
||||
Margin="5 5 5 5 "
|
||||
Click="btnStart_Click" />
|
||||
</StackPanel>
|
||||
<StatusBar Grid.Row="2">
|
||||
<StatusBar.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="4*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
|
||||
</Grid.ColumnDefinitions>
|
||||
</Grid>
|
||||
</ItemsPanelTemplate>
|
||||
</StatusBar.ItemsPanel>
|
||||
<StatusBarItem>
|
||||
<TextBlock x:Name="tbStatus" />
|
||||
</StatusBarItem>
|
||||
<StatusBarItem Grid.Column="1">
|
||||
<ProgressBar x:Name="pgProgress"
|
||||
Width="80"
|
||||
Height="18" />
|
||||
</StatusBarItem>
|
||||
|
||||
|
||||
<StatusBarItem HorizontalAlignment="Right">
|
||||
<TextBlock Text="{Binding CurrentTime}" />
|
||||
</StatusBarItem>
|
||||
|
||||
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
</Window>
|
||||
71
FSI.Lib/Guis/Pdf.Mgt/FrmMain.xaml.cs
Normal file
71
FSI.Lib/Guis/Pdf.Mgt/FrmMain.xaml.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System.Configuration;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
|
||||
namespace FSI.Lib.Guis.Pdf.Mgt
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für FrmMain.xaml
|
||||
/// </summary>
|
||||
public partial class FrmMain : Window
|
||||
{
|
||||
public bool CloseAtLostFocus { get; set; }
|
||||
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new MVVM.ViewModel.CurrentTimeViewModel();
|
||||
Title += " v" + Assembly.GetExecutingAssembly().GetName().Version; // Version in Titel eintragen
|
||||
Deactivated += FrmMain_Deactivated;
|
||||
}
|
||||
|
||||
private void FrmMain_Deactivated(object sender, System.EventArgs e)
|
||||
{
|
||||
if (CloseAtLostFocus)
|
||||
Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private async void btnCleanUp_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
BtnMgt(false); // Schaltflächen sperren
|
||||
|
||||
await Cmds.DelDirectoriesAsync(ConfigurationManager.AppSettings["PdfPath"]); // nicht benötigte/zulässige Verzeichnisse löschen
|
||||
await Cmds.DelFilesAsync(ConfigurationManager.AppSettings["PdfPath"]); // nicht benötigte/zulässige Datien löschen
|
||||
BtnMgt(true); // Schaltflächen freigeben
|
||||
}
|
||||
|
||||
private async void btnCreateShortcuts_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
BtnMgt(false); // Schaltflächen sperren
|
||||
await Cmds.CreatePdfShortcutsAsync(ConfigurationManager.AppSettings["PdfPath"]); // Verzeichnisstruktur und Verknüpfungen erstellen
|
||||
BtnMgt(true); // Schaltflächen freigeben
|
||||
}
|
||||
|
||||
private async void btnStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
BtnMgt(false); // Schaltflächen sperren
|
||||
await Cmds.DelDirectoriesAsync(ConfigurationManager.AppSettings["PdfPath"]); // nicht benötigte/zulässige Verzeichnisse löschen
|
||||
await Cmds.DelFilesAsync(ConfigurationManager.AppSettings["PdfPath"]); // nicht benötigte/zulässige Datien lösche
|
||||
await Cmds.CreatePdfShortcutsAsync(ConfigurationManager.AppSettings["PdfPath"]); // Verzeichnisstruktur und Verknüpfungen erstellen
|
||||
BtnMgt(true); // Schaltflächen freigeben
|
||||
}
|
||||
|
||||
private void BtnMgt(bool enable)
|
||||
{
|
||||
btnCleanUp.IsEnabled =
|
||||
btnCreateShortcuts.IsEnabled =
|
||||
btnStart.IsEnabled = enable;
|
||||
pgProgress.IsIndeterminate = !enable;
|
||||
|
||||
// Status anzeige
|
||||
if (enable)
|
||||
{
|
||||
tbStatus.Text = "beendet";
|
||||
}
|
||||
else
|
||||
{
|
||||
tbStatus.Text = "gestartet";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
185
FSI.Lib/Guis/Prj.Mgt/FrmMain.xaml
Normal file
185
FSI.Lib/Guis/Prj.Mgt/FrmMain.xaml
Normal file
@@ -0,0 +1,185 @@
|
||||
<Window x:Class="FSI.Lib.Guis.Prj.Mgt.FrmMain"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
|
||||
xmlns:local="clr-namespace:FSI.Lib.Guis.Prj.Mgt"
|
||||
xmlns:control="clr-namespace:FSI.Lib.Wpf.Ctrls.FilterDataGrid"
|
||||
xmlns:viewmodel="clr-namespace:FSI.Lib.Guis.Prj.Mgt.ViewModel"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:ViewModelPrj}"
|
||||
mc:Ignorable="d"
|
||||
SizeToContent="Width"
|
||||
Height="800"
|
||||
Width="Auto"
|
||||
Icon="../../Icons/FondiumU.ico">
|
||||
|
||||
<Window.Resources>
|
||||
<ObjectDataProvider x:Key="PrjsFiltered"></ObjectDataProvider>
|
||||
</Window.Resources>
|
||||
|
||||
<Window.InputBindings>
|
||||
<KeyBinding Command="{Binding CmdOpen}"
|
||||
Gesture="CTRL+o" />
|
||||
</Window.InputBindings>
|
||||
|
||||
<Grid FocusManager.FocusedElement="{Binding ElementName=tbSearch}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0"
|
||||
Margin="0,10"
|
||||
HorizontalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0"
|
||||
HorizontalAlignment="Left"
|
||||
Orientation="Horizontal">
|
||||
<Label Margin="0,0,20,0"
|
||||
VerticalAlignment="Bottom"
|
||||
Content="Suche:"
|
||||
FontWeight="Bold" />
|
||||
<TextBox Name="tbSearch"
|
||||
Height="26"
|
||||
MinWidth="200"
|
||||
VerticalAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Text="{Binding Search, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
TextChanged="tbSearch_TextChanged" />
|
||||
<Button Width="Auto"
|
||||
Margin="5,0,0,0"
|
||||
Padding="4"
|
||||
Command="{Binding RefreshCommand}"
|
||||
ToolTip="Filter löschen"
|
||||
Cursor="Hand">
|
||||
<Image Source="../../Icons/Cross.png"
|
||||
Height="14" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button Width="Auto"
|
||||
Margin="0 0 20 0"
|
||||
Padding="4"
|
||||
ToolTip="öffen"
|
||||
Command="{Binding CmdOpen}"
|
||||
IsEnabled="{Binding CanExecuteOpen}"
|
||||
Cursor="Hand">
|
||||
<Image Source="../../Icons/Open.png"
|
||||
Height="14" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
HorizontalAlignment="Left"
|
||||
Orientation="Horizontal"
|
||||
Margin="0,5">
|
||||
<Label Margin="0,0,20,0"
|
||||
VerticalAlignment="Bottom"
|
||||
Content="Quick-Filter:"
|
||||
FontWeight="Bold" />
|
||||
<Button Width="Auto"
|
||||
Margin="5,0,0,0"
|
||||
Padding="4"
|
||||
ToolTip="Filter löschen"
|
||||
Command="{Binding RefreshCommand}"
|
||||
Cursor="Hand">
|
||||
<Image Source="../../Icons/Cross.png"
|
||||
Height="14" />
|
||||
</Button>
|
||||
<Button Content="PL1"
|
||||
Width="Auto"
|
||||
Margin="10,0,0,0"
|
||||
ToolTip="Filter auf PL1"
|
||||
Command="{Binding CmdQuickSearch}"
|
||||
CommandParameter="PL1"
|
||||
FocusManager.FocusedElement="{Binding ElementName=tbSearch}" />
|
||||
<Button Content="PL2"
|
||||
Width="Auto"
|
||||
Margin="10,0,0,0"
|
||||
ToolTip="Filter auf PL2"
|
||||
Command="{Binding CmdQuickSearch}"
|
||||
CommandParameter="PL2"
|
||||
FocusManager.FocusedElement="{Binding ElementName=tbSearch}" />
|
||||
<Button Content="PL3"
|
||||
Width="Auto"
|
||||
Margin="10,0,0,0"
|
||||
ToolTip="Filter auf PL3"
|
||||
Command="{Binding CmdQuickSearch}"
|
||||
CommandParameter="PL3"
|
||||
FocusManager.FocusedElement="{Binding ElementName=tbSearch}" />
|
||||
<Button Content="SMZ"
|
||||
Width="Auto"
|
||||
Margin="10,0,0,0"
|
||||
ToolTip="Filter auf SMZ"
|
||||
Command="{Binding CmdQuickSearch}"
|
||||
CommandParameter="SMZ"
|
||||
FocusManager.FocusedElement="{Binding ElementName=tbSearch}" />
|
||||
</StackPanel>
|
||||
|
||||
<control:FilterDataGrid x:Name="FilterDataGrid"
|
||||
Grid.Row="2"
|
||||
AutoGenerateColumns="False"
|
||||
DateFormatString="d"
|
||||
FilterLanguage="German"
|
||||
ItemsSource="{Binding PrjsFiltered, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectionMode="Single"
|
||||
SelectedItem="{Binding SeletctedPrj, UpdateSourceTrigger=PropertyChanged}"
|
||||
ShowElapsedTime="false"
|
||||
ShowRowsCount="True"
|
||||
ShowStatusBar="True">
|
||||
|
||||
<control:FilterDataGrid.InputBindings>
|
||||
<MouseBinding MouseAction="LeftDoubleClick"
|
||||
Command="{Binding CmdOpen}" />
|
||||
|
||||
</control:FilterDataGrid.InputBindings>
|
||||
<control:FilterDataGrid.Columns>
|
||||
|
||||
<control:DataGridTemplateColumn FieldName="PlantNo"
|
||||
Header="Anlagen-Nr."
|
||||
IsColumnFiltered="True"
|
||||
SortMemberPath="PlantNo">
|
||||
<control:DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate DataType="local:Prj">
|
||||
<TextBlock Text="{Binding PlantNo}" />
|
||||
</DataTemplate>
|
||||
</control:DataGridTemplateColumn.CellTemplate>
|
||||
</control:DataGridTemplateColumn>
|
||||
|
||||
<control:DataGridTextColumn Binding="{Binding SubPlantNo}"
|
||||
Header="Teilanlagen-Nr."
|
||||
IsReadOnly="True"
|
||||
IsColumnFiltered="True" />
|
||||
|
||||
<control:DataGridTextColumn Binding="{Binding No, StringFormat={}{0:0000}}"
|
||||
Header="Lfd.-Nr."
|
||||
IsReadOnly="True"
|
||||
IsColumnFiltered="True" />
|
||||
|
||||
<control:DataGridTextColumn Binding="{Binding Plant}"
|
||||
Header="Anlage"
|
||||
IsReadOnly="True"
|
||||
IsColumnFiltered="True" />
|
||||
|
||||
<control:DataGridTextColumn Binding="{Binding SubPlant}"
|
||||
Header="Teilanlage"
|
||||
IsReadOnly="True"
|
||||
IsColumnFiltered="True" />
|
||||
|
||||
<control:DataGridTextColumn Binding="{Binding Description}"
|
||||
Header="Bezeichnung"
|
||||
IsReadOnly="True"
|
||||
IsColumnFiltered="True" />
|
||||
</control:FilterDataGrid.Columns>
|
||||
</control:FilterDataGrid>
|
||||
</Grid>
|
||||
</Window>
|
||||
63
FSI.Lib/Guis/Prj.Mgt/FrmMain.xaml.cs
Normal file
63
FSI.Lib/Guis/Prj.Mgt/FrmMain.xaml.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using FSI.Lib.Guis.Prj.Mgt.ViewModel;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace FSI.Lib.Guis.Prj.Mgt
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für Main.xaml
|
||||
/// </summary>
|
||||
public partial class FrmMain : Window
|
||||
{
|
||||
public ViewModelPrj Prj { get; set; }
|
||||
public bool ShowPdf { get; set; }
|
||||
public bool CloseAtLostFocus { get; set; }
|
||||
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Loaded += Main_Loaded;
|
||||
Deactivated += FrmMain_Deactivated;
|
||||
}
|
||||
|
||||
private void FrmMain_Deactivated(object sender, System.EventArgs e)
|
||||
{
|
||||
if (CloseAtLostFocus)
|
||||
Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void Main_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string path;
|
||||
|
||||
if (ShowPdf)
|
||||
{
|
||||
Title = "FSI PDF-Auswahl";
|
||||
path = Settings.Setting<string>("Epl.Pdf.Path");
|
||||
}
|
||||
else
|
||||
{
|
||||
Title = "FSI Epl Projektauswahl";
|
||||
path = Settings.Setting<string>("Epl.Prj.Path");
|
||||
}
|
||||
|
||||
Title += " v" + Assembly.GetExecutingAssembly().GetName().Version; // Version in Titel eintragen
|
||||
|
||||
Prj = new ViewModelPrj(new PrjDataProvider())
|
||||
{
|
||||
DataPath = path,
|
||||
ShowPdf = ShowPdf,
|
||||
};
|
||||
DataContext = Prj;
|
||||
|
||||
Prj.Load();
|
||||
}
|
||||
|
||||
private void tbSearch_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
tbSearch.Select(tbSearch.Text.Length, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
FSI.Lib/Guis/Prj.Mgt/Model/Prj.cs
Normal file
25
FSI.Lib/Guis/Prj.Mgt/Model/Prj.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FSI.Lib.Guis.Prj.Mgt.Model
|
||||
{
|
||||
public class Prj
|
||||
{
|
||||
public Int64 PlantNo { get; set; }
|
||||
public Int64 SubPlantNo { get; set; }
|
||||
public Int64 No { get; set; }
|
||||
public string Plant { get; set; }
|
||||
public string SubPlant { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string DescriptionDetail { get; set; }
|
||||
public string FullName { get; set; }
|
||||
}
|
||||
|
||||
public interface IPrjDataProvider
|
||||
{
|
||||
IEnumerable<Prj> Load(string path, bool showPdf);
|
||||
}
|
||||
}
|
||||
209
FSI.Lib/Guis/Prj.Mgt/ViewModel/ViewModelPrj.cs
Normal file
209
FSI.Lib/Guis/Prj.Mgt/ViewModel/ViewModelPrj.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
using FSI.Lib.Guis.Prj.Mgt.Model;
|
||||
using FSI.Lib.MVVM;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FSI.Lib.Guis.Prj.Mgt.ViewModel
|
||||
{
|
||||
public class ViewModelPrj : MVVM.ViewModelBase
|
||||
{
|
||||
readonly IPrjDataProvider _prjDataProvider;
|
||||
private string _search;
|
||||
private ICollectionView _collView;
|
||||
|
||||
public ICommand RefreshCommand => new DelegateCommand(RefreshData);
|
||||
private ICommand _cmdQuickSearch;
|
||||
private ICommand _cmdOpen;
|
||||
|
||||
public ViewModelPrj(IPrjDataProvider prjDataProvider)
|
||||
{
|
||||
Prjs = new ObservableCollection<Model.Prj>();
|
||||
_prjDataProvider = prjDataProvider;
|
||||
|
||||
_cmdQuickSearch = new RelayCommand<object>(ExecuteQuickSearch, CanExecuteQuickSearch);
|
||||
_cmdOpen = new RelayCommand<object>(ExecuteOpen, CanExecuteOpen);
|
||||
}
|
||||
|
||||
public ObservableCollection<Model.Prj> Prjs { get; }
|
||||
public ObservableCollection<Model.Prj> PrjsFiltered { get; set; }
|
||||
|
||||
public Model.Prj SeletctedPrj { get; set; }
|
||||
|
||||
public string DataPath { get; set; }
|
||||
|
||||
public bool ShowPdf { get; set; }
|
||||
|
||||
public void Load()
|
||||
{
|
||||
var prjs = _prjDataProvider.Load(DataPath, ShowPdf);
|
||||
Prjs.Clear();
|
||||
|
||||
if (prjs != null)
|
||||
{
|
||||
foreach (Model.Prj prj in prjs)
|
||||
{
|
||||
Prjs.Add(prj);
|
||||
}
|
||||
}
|
||||
|
||||
PrjsFiltered = new ObservableCollection<Model.Prj>(Prjs);
|
||||
_collView = CollectionViewSource.GetDefaultView(PrjsFiltered);
|
||||
}
|
||||
|
||||
public string Search
|
||||
{
|
||||
get => _search;
|
||||
set
|
||||
{
|
||||
_search = value;
|
||||
|
||||
_collView.Filter = e =>
|
||||
{
|
||||
var item = (Model.Prj)e;
|
||||
return item != null && ((item.Plant?.StartsWith(_search, StringComparison.OrdinalIgnoreCase) ?? false)
|
||||
|| (item.SubPlant?.StartsWith(_search, StringComparison.OrdinalIgnoreCase) ?? false)
|
||||
#if NET472
|
||||
|| (item.Description?.Contains(_search) ?? false)
|
||||
|| (item.DescriptionDetail?.Contains(_search) ?? false)
|
||||
#elif NET6_0
|
||||
|| (item.Description?.Contains(_search, StringComparison.OrdinalIgnoreCase) ?? false)
|
||||
|| (item.DescriptionDetail?.Contains(_search, StringComparison.OrdinalIgnoreCase) ?? false)
|
||||
#endif
|
||||
);
|
||||
};
|
||||
|
||||
_collView.Refresh();
|
||||
PrjsFiltered = new ObservableCollection<Model.Prj>(_collView.OfType<Model.Prj>().ToList());
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void QuickSearch(string search)
|
||||
{
|
||||
Search = search + " ";
|
||||
}
|
||||
|
||||
private void RefreshData(object obj)
|
||||
{
|
||||
Search = string.Empty;
|
||||
}
|
||||
|
||||
private bool CanExecuteQuickSearch(object obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ExecuteQuickSearch(object obj)
|
||||
{
|
||||
QuickSearch(obj.ToString());
|
||||
}
|
||||
|
||||
public ICommand CmdQuickSearch
|
||||
{
|
||||
get { return _cmdQuickSearch; }
|
||||
set => _cmdQuickSearch = value;
|
||||
}
|
||||
|
||||
private bool CanExecuteOpen(object obj)
|
||||
{
|
||||
if (SeletctedPrj != null)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ExecuteOpen(object obj)
|
||||
{
|
||||
if (ShowPdf)
|
||||
{
|
||||
new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo(SeletctedPrj.FullName)
|
||||
{
|
||||
UseShellExecute = true
|
||||
}
|
||||
}.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
var files = Settings.Setting<string>("Epl.Exe", Settings.Mode.ExeSetttings).Replace(Environment.NewLine, "").Replace("\t", "").Split(";");
|
||||
|
||||
var arguments = " /Variant:\"Electric P8\" ProjectOpen /Project:\"" + SeletctedPrj.FullName + "\"";
|
||||
|
||||
string fileName = string.Empty;
|
||||
string path = string.Empty;
|
||||
|
||||
for (int i = 0; i <= files.Length - 1; i++)
|
||||
{
|
||||
if (File.Exists(files[i].Trim()))
|
||||
{
|
||||
fileName = files[i].Trim();
|
||||
}
|
||||
}
|
||||
|
||||
new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo()
|
||||
{
|
||||
FileName = fileName,
|
||||
Arguments = arguments,
|
||||
}
|
||||
}.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand CmdOpen
|
||||
{
|
||||
get { return _cmdOpen; }
|
||||
set => _cmdOpen = value;
|
||||
}
|
||||
}
|
||||
|
||||
public class PrjDataProvider : IPrjDataProvider
|
||||
{
|
||||
public IEnumerable<Model.Prj> Load(string path, bool showPdf)
|
||||
{
|
||||
var prjs = new ObservableCollection<Model.Prj>();
|
||||
string[] files = Directory.GetFiles(path); // alle PDF-Dateien einlesen
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
if (((file.EndsWith(".elk") || file.EndsWith(".elp") || file.EndsWith(".els") || file.EndsWith(".elx") || file.EndsWith(".elr") || file.EndsWith(".ell") || file.EndsWith(".elf"))
|
||||
&& !showPdf) || (file.EndsWith(".pdf") && showPdf))
|
||||
{
|
||||
Model.Prj prj = new();
|
||||
FileInfo fileInfo = new(file);
|
||||
string[] nameNo = fileInfo.Name[..(27 - 1)].Split('-');
|
||||
|
||||
if (nameNo.Length == 3) // 3 Zahlenblöcke vorhanden?
|
||||
{
|
||||
if (nameNo[0].Length == 10 || Int64.TryParse(nameNo[0], out _) || nameNo[1].Length == 10 || Int64.TryParse(nameNo[1], out _) || nameNo[2].Length == 4 || !Int64.TryParse(nameNo[2], out _)) // Länge der Zahlenblöcke überprüfen
|
||||
{
|
||||
prj.PlantNo = Int64.Parse(nameNo[0]);
|
||||
prj.SubPlantNo = Int64.Parse(nameNo[1]);
|
||||
prj.No = Int64.Parse(nameNo[2]);
|
||||
|
||||
string[] fileStrings = System.IO.Path.GetFileNameWithoutExtension(fileInfo.Name).Split(' ');
|
||||
prj.Plant = fileStrings[1];
|
||||
prj.SubPlant = fileStrings[2];
|
||||
prj.Description = System.IO.Path.GetFileNameWithoutExtension(fileInfo.Name).Replace(nameNo[0] + "-" + nameNo[1] + "-" + nameNo[2] + " " + fileStrings[1] + " " + fileStrings[2], "");
|
||||
prj.Description = prj.Description.Trim();
|
||||
prj.DescriptionDetail = prj.Plant + " " + prj.SubPlant + " " + prj.Description;
|
||||
prj.FullName = fileInfo.FullName;
|
||||
prjs.Add(prj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return prjs;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
54
FSI.Lib/Guis/SieStarterCsvExporter/FrmMain.xaml
Normal file
54
FSI.Lib/Guis/SieStarterCsvExporter/FrmMain.xaml
Normal file
@@ -0,0 +1,54 @@
|
||||
<Window x:Class="FSI.Lib.Guis.SieStarterCsvExporter.FrmMain"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Title="FSI Siemens Starter Trace Csv-Exporter"
|
||||
SizeToContent="WidthAndHeight"
|
||||
Height="Auto"
|
||||
Width="Auto"
|
||||
Icon="../../Icons/FondiumU.ico"
|
||||
WindowStyle="ToolWindow">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Datei:"
|
||||
Margin="5 5 5 5" />
|
||||
<TextBox x:Name="tbSrcFile"
|
||||
Width="600"
|
||||
Margin="5 5 5 5"
|
||||
AllowDrop="True"
|
||||
TextChanged="TbSrcFile_TextChanged"
|
||||
PreviewDragEnter="TbSrcFile_PreviewDragEnter"
|
||||
PreviewDragOver="TbSrcFile_PreviewDragOver"
|
||||
Drop="TbSrcFile_Drop" />
|
||||
|
||||
<Button x:Name="btnSlctSrcFile"
|
||||
Content="..."
|
||||
Width="30"
|
||||
Margin="5 5 5 5"
|
||||
Click="BtnSlctSrcFile_Click" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="1">
|
||||
<Button x:Name="btnStart"
|
||||
Content="Start"
|
||||
Margin="5 5 5 5"
|
||||
IsEnabled="False"
|
||||
Click="BtnStart_Click" />
|
||||
</StackPanel>
|
||||
|
||||
<StatusBar Grid.Row="2">
|
||||
<StatusBarItem HorizontalAlignment="Right">
|
||||
<TextBlock Text="{Binding CurrentTime}" />
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
116
FSI.Lib/Guis/SieStarterCsvExporter/FrmMain.xaml.cs
Normal file
116
FSI.Lib/Guis/SieStarterCsvExporter/FrmMain.xaml.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using Microsoft.Win32;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace FSI.Lib.Guis.SieStarterCsvExporter
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für frmMain.xaml
|
||||
/// </summary>
|
||||
public partial class FrmMain : Window
|
||||
{
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new MVVM.ViewModel.CurrentTimeViewModel();
|
||||
}
|
||||
private void BtnSlctSrcFile_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OpenFileDialog dlg = new()
|
||||
{
|
||||
Filter = "Trace (*.trc)|*.trc|alle Dateien (*:*)|*.*"
|
||||
};
|
||||
|
||||
if ((bool)dlg.ShowDialog())
|
||||
{
|
||||
tbSrcFile.Text = dlg.FileName;
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string[] tbEntries = tbSrcFile.Text.Split("\n");
|
||||
|
||||
string test = GetType().Namespace;
|
||||
|
||||
var test2 = Assembly.GetExecutingAssembly;
|
||||
|
||||
|
||||
foreach (string tbEntry in tbEntries)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(tbEntry))
|
||||
{
|
||||
Process process= new Process();
|
||||
process.StartInfo.FileName = Directory.GetCurrentDirectory() + @"\Guis\SieStarterCsvExporter\" + "Convert_SINAMICS_trace_CSV.exe";
|
||||
process.StartInfo.Arguments = "\"" + tbEntry + "\"";
|
||||
|
||||
process.Start();
|
||||
process.WaitForExit();
|
||||
}
|
||||
}
|
||||
|
||||
tbSrcFile.Text = string.Empty;
|
||||
}
|
||||
|
||||
private void TbSrcFile_PreviewDragEnter(object sender, System.Windows.DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))
|
||||
{
|
||||
e.Effects = System.Windows.DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effects = System.Windows.DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void TbSrcFile_PreviewDragOver(object sender, System.Windows.DragEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void TbSrcFile_Drop(object sender, System.Windows.DragEventArgs e)
|
||||
{
|
||||
// Get data object
|
||||
var dataObject = e.Data as System.Windows.DataObject;
|
||||
|
||||
// Check for file list
|
||||
if (dataObject.ContainsFileDropList())
|
||||
{
|
||||
// Clear values
|
||||
tbSrcFile.Text = string.Empty;
|
||||
|
||||
// Process file names
|
||||
StringCollection fileNames = dataObject.GetFileDropList();
|
||||
StringBuilder bd = new();
|
||||
foreach (string fileName in fileNames)
|
||||
{
|
||||
if (fileName.EndsWith(".trc"))
|
||||
{
|
||||
bd.Append(fileName + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Set text
|
||||
tbSrcFile.Text = bd.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void TbSrcFile_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(tbSrcFile.Text))
|
||||
{
|
||||
btnStart.IsEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
btnStart.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
59
FSI.Lib/Guis/SieTiaWinCCMsgMgt/FrmMain.xaml
Normal file
59
FSI.Lib/Guis/SieTiaWinCCMsgMgt/FrmMain.xaml
Normal file
@@ -0,0 +1,59 @@
|
||||
<Window x:Class="FSI.Lib.Guis.SieTiaWinCCMsgMgt.FrmMain"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FSI.Lib.Guis.SieTiaWinCCMsgMgt"
|
||||
mc:Ignorable="d"
|
||||
Title="FSI WinCC Mgt"
|
||||
SizeToContent="WidthAndHeight"
|
||||
Height="Auto"
|
||||
Width="Auto"
|
||||
MinWidth="200"
|
||||
Icon="../../Icons/FondiumU.ico"
|
||||
WindowStyle="ToolWindow">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MaxHeight="30"
|
||||
Height="*" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button x:Name="btnStart"
|
||||
Content="Start"
|
||||
Margin="5 5 5 5 "
|
||||
Click="btnStart_Click" />
|
||||
<Button x:Name="btnStop"
|
||||
Content="Stop"
|
||||
Margin="5 5 5 5 "
|
||||
Click="btnStop_Click" />
|
||||
</StackPanel>
|
||||
|
||||
<StatusBar Grid.Row="2">
|
||||
<StatusBar.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="4*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
|
||||
</Grid.ColumnDefinitions>
|
||||
</Grid>
|
||||
</ItemsPanelTemplate>
|
||||
</StatusBar.ItemsPanel>
|
||||
<StatusBarItem>
|
||||
<TextBlock x:Name="tbStatus" />
|
||||
</StatusBarItem>
|
||||
<StatusBarItem Grid.Column="1">
|
||||
<ProgressBar x:Name="pgProgress"
|
||||
Width="80"
|
||||
Height="18" />
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
57
FSI.Lib/Guis/SieTiaWinCCMsgMgt/FrmMain.xaml.cs
Normal file
57
FSI.Lib/Guis/SieTiaWinCCMsgMgt/FrmMain.xaml.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace FSI.Lib.Guis.SieTiaWinCCMsgMgt
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für FrmMain.xaml
|
||||
/// </summary>
|
||||
public partial class FrmMain : Window
|
||||
{
|
||||
public WinCC WinCC { get; set; }
|
||||
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void btnStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WinCC.Start();
|
||||
CtrlMgt();
|
||||
}
|
||||
|
||||
private void btnStop_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WinCC.Stop();
|
||||
CtrlMgt();
|
||||
}
|
||||
|
||||
private void CtrlMgt()
|
||||
{
|
||||
if (WinCC.Status)
|
||||
{
|
||||
btnStart.IsEnabled = false;
|
||||
btnStop.IsEnabled = true;
|
||||
pgProgress.IsIndeterminate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
btnStart.IsEnabled = true;
|
||||
btnStop.IsEnabled = false;
|
||||
pgProgress.IsIndeterminate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
172
FSI.Lib/Guis/SieTiaWinCCMsgMgt/WinCC.cs
Normal file
172
FSI.Lib/Guis/SieTiaWinCCMsgMgt/WinCC.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FSI.Lib.Guis.SieTiaWinCCMsgMgt
|
||||
{
|
||||
public class WinCC
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern IntPtr PostMessage(IntPtr hwndParent, int msg, int wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool IsWindowVisible(IntPtr hWnd);
|
||||
|
||||
const int BM_CLICK = 0x00F5; //message for Click which is a constant
|
||||
const int WM_LBUTTONDOWN = 0x0201; //message for Mouse down
|
||||
const int WM_LBUTTONUP = 0x0202; // message for Mouse up
|
||||
|
||||
private CancellationTokenSource tokenSource = null;
|
||||
private CancellationToken token;
|
||||
private Task task = null;
|
||||
|
||||
private BackgroundWorker backgroundWorker;
|
||||
|
||||
|
||||
public bool AutoStart { get; set; }
|
||||
public int UpdateIntervall { get; set; }
|
||||
public string WindowsName { get; set; }
|
||||
public string WindowsClassName { get; set; }
|
||||
public string ButtonName { get; set; }
|
||||
|
||||
public WinCC()
|
||||
{
|
||||
backgroundWorker = new BackgroundWorker
|
||||
{
|
||||
WorkerReportsProgress = true,
|
||||
WorkerSupportsCancellation = true
|
||||
};
|
||||
backgroundWorker.DoWork += BackgroundWorker_DoWork;
|
||||
backgroundWorker.ProgressChanged += BackgroundWorker_ProgressChanged;
|
||||
|
||||
if (AutoStart)
|
||||
{
|
||||
Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
BackgroundWorker worker = sender as BackgroundWorker;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (worker.CancellationPending == true)
|
||||
{
|
||||
e.Cancel = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Perform a time consuming operation and report progress.
|
||||
System.Threading.Thread.Sleep(UpdateIntervall);
|
||||
|
||||
// Find windos by Name
|
||||
var windowHandle = FindWindow(WindowsClassName, WindowsName);
|
||||
|
||||
if (windowHandle != IntPtr.Zero && IsWindowVisible(windowHandle))
|
||||
{
|
||||
SetForegroundWindow(windowHandle);
|
||||
var btnHandle = FindWindowEx(windowHandle, IntPtr.Zero, null, ButtonName);
|
||||
SendMessage(btnHandle, BM_CLICK, IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (backgroundWorker.IsBusy != true)
|
||||
{
|
||||
backgroundWorker.RunWorkerAsync();
|
||||
}
|
||||
Status = true;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (backgroundWorker.WorkerSupportsCancellation == true)
|
||||
{
|
||||
backgroundWorker.CancelAsync();
|
||||
}
|
||||
Status = false;
|
||||
}
|
||||
|
||||
public bool Status { get; set; }
|
||||
|
||||
private void WinCCMsgMgt()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (token.IsCancellationRequested)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
}
|
||||
//MessageBox.Show("13456");
|
||||
Thread.Sleep(5000);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
bool disposedValue = false;
|
||||
|
||||
try
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
tokenSource.Cancel();
|
||||
task.Wait();
|
||||
tokenSource.Dispose();
|
||||
task.Dispose();
|
||||
}
|
||||
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
tokenSource = null;
|
||||
task = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user