using System.Diagnostics; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using TeamsNetphoneLink.WPF.MVVM; namespace TeamsNetphoneLink.WPF { /// /// Interaction logic for MainWindow.xaml /// /// public partial class DashboardWindow : Window { private bool isDarkMode = true; private Syncronisation sync; private Task graphAuthenticationTask; public DashboardViewModel _dashboardViewModel { get; } public DashboardWindow(Syncronisation _syncronisation) { InitializeComponent(); sync = _syncronisation; _dashboardViewModel = sync._dashboardViewModel; DataContext = _dashboardViewModel; // Set the ViewModel instance & Set the DataContext to the ViewModel //Set the DataContext to the ViewModel Log.DataContext = sync.LogEntries; } private void ToggleDarkMode(object sender, RoutedEventArgs e) { isDarkMode = !isDarkMode; if (isDarkMode) { this.Style = (Style)FindResource("DarkModeStyle"); } else { this.Style = (Style)FindResource("LightModeStyle"); } } private void SettingsButton_Click(object sender, RoutedEventArgs e) { // Einstellungsfenster öffnen SettingsWindow settingsWindow = new SettingsWindow(sync); settingsWindow.ShowDialog(); } private async void TeamsGraphAPIBorder_MouseDown(object sender, MouseButtonEventArgs e) { if (!Teams.TeamsGraph.IsGuid(Settings.Default.AppID) || !Teams.TeamsGraph.IsGuid(Settings.Default.TenantID)) { SettingsWindow settingsWindow = new SettingsWindow(sync); settingsWindow.ShowDialog(); return; }; if (sync.TeamsGraphAuthenticationSemaphore.CurrentCount == 0) return; bool saveCredentials = Settings.Default.SaveEntraCredentials; if (!sync.TeamsGraph.Authenticated) { await sync.TeamsGraphAuthenticationSemaphore.WaitAsync(); _ = await sync.GraphAuthenticate(saveCredentials); sync.TeamsGraphAuthenticationSemaphore.Release(); } } private void TeamsLocalAPIBorder_MouseDown(object sender, MouseButtonEventArgs e) { if (!Settings.Default.TeamsPermission) { var setupLocalTeams = new WPF.SetupLocalTeamsAPI(sync); setupLocalTeams.ShowDialog(); } } private void VersionBorder_MouseDown(object sender, MouseButtonEventArgs e) { if(UpdateCheck.UpdateAvailable) { var latestTag = UpdateCheck.GetLatestReleaseTagAsync().GetAwaiter().GetResult(); var currentTag = UpdateCheck.GetCurrentVersion(); // Erstellen und Anzeigen des Update-Fensters var updateWindow = new WPF.UpdateWindow(currentTag, latestTag); updateWindow.ShowDialog(); } } private void Credit_MouseDown(object sender, MouseButtonEventArgs e) { Process.Start(new ProcessStartInfo("https://jan.sx") { UseShellExecute = true }); } } }