Files
FSI.BT.IR.Tools/FSI.BT.Tools/App.xaml.cs
Maier Stephan SI 63512e77aa Sicherung
2023-01-16 16:03:54 +01:00

98 lines
3.1 KiB
C#

using Hardcodet.Wpf.TaskbarNotification;
using NHotkey;
using NHotkey.Wpf;
using System.Windows;
using System.Windows.Input;
using FSI.Lib.CompareNetObjects;
using Config.Net.Stores;
using System.IO;
using Config.Net;
using System.Collections.Generic;
using System.Linq;
using System;
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!");
// App-Settings
JsonConfigStore _store = new JsonConfigStore(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 void DeCrypt(ref IEnumerable<Settings.StringValue.IStringValueCrypt> values)
{
var valuesToDeCrypt = values.ToList();
foreach (var value in valuesToDeCrypt.ToList())
value.ValueDeCrypt = Lib.DeEncryptString.DeEncrypt.DecryptString(value.Value, AppDomain.CurrentDomain.FriendlyName);
}
private void Application_Exit(object sender, ExitEventArgs e)
{
if (Global.Iba.RoboCopy != null)
{
Global.Iba.RoboCopy.Stop();
Global.Iba.RoboCopy.Dispose();
}
}
}
}