using System.Runtime.InteropServices; using System.Windows; using System.Windows.Media; using TeamsNetphoneLink.WPF.MVVM; namespace TeamsNetphoneLink { /// /// Interaction logic for App.xaml /// 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(); } } }