104 lines
3.8 KiB
C#
104 lines
3.8 KiB
C#
using AutoUpdaterDotNET;
|
|
using Config.Net;
|
|
using Config.Net.Stores;
|
|
using Hardcodet.Wpf.TaskbarNotification;
|
|
using NHotkey;
|
|
using NHotkey.Wpf;
|
|
using System;
|
|
using System.IO;
|
|
using System.IO.Compression;
|
|
using System.Reflection;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
|
|
namespace FSI.BT.Tools
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for App.xaml
|
|
/// </summary>
|
|
public partial class App : System.Windows.Application
|
|
{
|
|
private static readonly KeyGesture RadialMenu = new(Key.OemBackslash, ModifierKeys.Control);
|
|
private static readonly KeyGesture TimeStamp = new(Key.C, ModifierKeys.Control | ModifierKeys.Alt);
|
|
|
|
|
|
public void Application_Startup(object sender, StartupEventArgs e)
|
|
{
|
|
|
|
Global.Log.Info("Anwendung wurde gestartet!");
|
|
|
|
ExtractEmbeddedZip("FSI.BT.Tools.ExtTools.kalk.zip", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\ExtTools\\");
|
|
ExtractEmbeddedZip("FSI.BT.Tools.ExtTools.AudioSwitch.zip", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\ExtTools\\");
|
|
ExtractEmbeddedZip("FSI.BT.Tools.ExtTools.SmartSystemMenu_v2.21.2.zip", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\ExtTools\\");
|
|
|
|
// App-Settings
|
|
JsonConfigStore _store = new(System.IO.Path.Combine(Directory.GetCurrentDirectory(), "config.json"), true);
|
|
Global.AppSettings = new ConfigurationBuilder<Settings.AppSettings.IAppSettings>()
|
|
.UseConfigStore(_store)
|
|
.Build();
|
|
|
|
Global.TaskbarIcon = (TaskbarIcon)FindResource("FSINotifyIcon");
|
|
|
|
Global.AdminRights = Admin.CheckAdminRight();
|
|
Global.SuperAdminRights = Admin.CheckSuperAdminRight();
|
|
Global.UserRights = Admin.CheckUserRight();
|
|
|
|
HotkeyManager.Current.AddOrReplace("RadialMenu", RadialMenu, ShowRadialMenu);
|
|
HotkeyManager.Current.AddOrReplace("TimeStampToClipboard", TimeStamp, TimeStampToClipboard);
|
|
|
|
Global.FrmRadialMenu = new FrmRadialMenu();
|
|
|
|
Global.WinCC = new Lib.Guis.SieTiaWinCCMsgMgt.ViewModel()
|
|
{
|
|
Data = Global.AppSettings.WinCC
|
|
};
|
|
Global.WinCC.Init();
|
|
|
|
Global.Iba = new Lib.Guis.IbaDirSync.ViewModel()
|
|
{
|
|
Data = Global.AppSettings.IbaDirSync
|
|
};
|
|
Global.Iba.Init();
|
|
|
|
}
|
|
|
|
private void ShowRadialMenu(object sender, HotkeyEventArgs e)
|
|
{
|
|
var cmd = new Commands.RadialMenuCommand();
|
|
|
|
if (cmd.CanExecute(null))
|
|
cmd.Execute(null);
|
|
|
|
e.Handled = true;
|
|
}
|
|
|
|
private void TimeStampToClipboard(object sender, HotkeyEventArgs e)
|
|
{
|
|
var cmd = new Commands.TimeStampToClipboardCommand();
|
|
cmd.Execute(null);
|
|
|
|
e.Handled = true;
|
|
}
|
|
|
|
private static void ExtractEmbeddedZip(string zipName, string destPath)
|
|
{
|
|
System.IO.Directory.CreateDirectory(destPath); // Erstellt alle fehlenden Verzeichnisse
|
|
using Stream _pluginZipResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(zipName);
|
|
using ZipArchive zip = new(_pluginZipResourceStream);
|
|
zip.ExtractToDirectory(destPath, true);
|
|
Global.Log.Info("Externes Tool \"{0}\" wurde in das Verzeichnis \"{1}\" entpackt", zipName, destPath);
|
|
}
|
|
|
|
private void Application_Exit(object sender, ExitEventArgs e)
|
|
{
|
|
|
|
if (Global.Iba.RoboCopy != null)
|
|
{
|
|
Global.Iba.RoboCopy.Stop();
|
|
Global.Iba.RoboCopy.Dispose();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
} |