95 lines
3.2 KiB
C#
95 lines
3.2 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
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 LogListView_UpdateColumnsWidth(object sender, SizeChangedEventArgs e)
|
|
{
|
|
ListView _ListView = sender as ListView;
|
|
GridView _GridView = _ListView.View as GridView;
|
|
var _ActualWidth = _ListView.ActualWidth - SystemParameters.VerticalScrollBarWidth;
|
|
for (Int32 i = 1; i < _GridView.Columns.Count; i++)
|
|
{
|
|
_ActualWidth = _ActualWidth - _GridView.Columns[i].ActualWidth;
|
|
}
|
|
_GridView.Columns[0].Width = _ActualWidth;
|
|
}
|
|
}
|
|
} |