TeamsNetphoneLink/TeamsNetphoneLinkWPF/App.xaml.cs
krjan02 55ca9934df
All checks were successful
Build and Relase / build-release (push) Successful in 1m22s
Build and Relase / create-release (push) Successful in 38s
changed release archive name / fixed log scrollbar
2025-03-26 17:25:10 +01:00

69 lines
2.4 KiB
C#

using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media;
using TeamsNetphoneLink.WPF.MVVM;
namespace TeamsNetphoneLink
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool AllocConsole();
public App()
{
#if DEBUG
// Konsole für Debugging-Zwecke öffnen
AllocConsole();
#endif
// Initialisierung der Anwendungskomponenten
InitializeApplication();
}
private void InitializeApplication()
{
UpdateCheck.UpgradeSettingsIfRequired();
// Erstellen der benötigten Instanzen
var TeamsLocalAPI = new Teams.TeamsLocalAPI();
var Netphone = new Netphone.NetPhoneEvents();
var TeamsGraph = new Teams.TeamsGraph();
var dashboardViewModel = new DashboardViewModel();
var LogEntries = new LogViewModel();
var finishPanelViewModel = new FinishPanelViewModel();
var latestTag = UpdateCheck.GetLatestReleaseTagAsync().GetAwaiter().GetResult();
var currentTag = UpdateCheck.GetCurrentVersion();
dashboardViewModel.VersionText = currentTag;
// Erstellen der Synchronisationsinstanz
var sync = new Syncronisation(Netphone, TeamsLocalAPI, TeamsGraph, dashboardViewModel, LogEntries, finishPanelViewModel);
// Erstellen und Anzeigen des Dashboard-Fensters
var dashboard = new WPF.DashboardWindow(sync);
dashboard.Show();
if (UpdateCheck.IsVersionLower(currentTag, latestTag))
{
UpdateCheck.UpdateAvailable = true;
dashboardViewModel.VersionText = String.Format("Version {0} verfügbar!", latestTag);
dashboardViewModel.VersionBackground = new SolidColorBrush(Colors.Orange);
// Erstellen und Anzeigen des Update-Fensters
var updateWindow = new WPF.UpdateWindow(currentTag, latestTag);
updateWindow.Show();
}
// Asynchrone Initialisierung von Netphone und TeamsLocalAPI
sync.InitializeTeamsGraphAsync();
sync.InitializeNetphoneAsync();
sync.InitializeTeamsLocalAPIAsync();
}
}
}