72 lines
2.7 KiB
C#
72 lines
2.7 KiB
C#
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";
|
|
}
|
|
}
|
|
}
|
|
}
|