using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using C4IT.AdaptableIcons; namespace C4IT_CustomerPanel.forms.AuthenticationSettings; public partial class AuthenticationSettings : Window { private CPM42FormsAuthentication FormsAuthentication; public AuthenticationSettings() { InitializeComponent(); if (this.DataContext is cAuthenticationSettingsController controller) controller.Init(false); } private void CloseButton_TouchDown(object sender, TouchEventArgs e) { Close(); } private void CloseButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { Close(); } private void iconPasswordShow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { } private void ConfirmButton_MouseDown(object sender, MouseButtonEventArgs e) { ConfirmButton_Click(sender); } private void ConfirmButton_TouchDown(object sender, TouchEventArgs e) { ConfirmButton_Click(sender); } private async void ConfirmButton_Click(object sender) { if (this.DataContext is cAuthenticationSettingsController controller) controller.SaveSettings(); Close(); } private void DoFormsAuthentication_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { ShowFormBasedAuthentication(); } private void DoFormsAuthentication_KeyUp(object sender, KeyEventArgs e) { ShowFormBasedAuthentication(); } private void DoFormsAuthentication_TouchUp(object sender, TouchEventArgs e) { ShowFormBasedAuthentication(); } private void ShowFormBasedAuthentication() { Cursor = Cursors.Wait; if (this.DataContext is cAuthenticationSettingsController controller) controller.FormsAuthenticationStart(); FormsAuthentication = new CPM42FormsAuthentication(); FormsAuthentication.AuthenticationCompleted += FormsAuthenticationFinished; FormsAuthentication.Show(); } public async void FormsAuthenticationFinished(object sender, EventArgs e) { string _token = null; if (sender is CPM42FormsAuthentication _formsAuth) _token = _formsAuth.AccessToken; if (this.DataContext is cAuthenticationSettingsController controller) await controller.FormsAuthenticationFinished(_token); FormsAuthentication = null; Cursor = null; } private void _this_Closed(object sender, EventArgs e) { if (FormsAuthentication != null) FormsAuthentication.Close(); } }