TeamsNetphoneLink/TeamsNetphoneLinkWPF/WPF/DashboardWindow.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

102 lines
3.4 KiB
C#

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
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///
public partial class DashboardWindow : Window
{
private bool isDarkMode = true;
private Syncronisation sync;
private Task<bool> 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 });
}
}
}