using System; using System.Collections.Generic; using System.Linq; 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.Markup; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Tango.Core.DI; using Tango.FSE.Common.Notifications; namespace Tango.FSE.UI.Controls { /// /// Interaction logic for NotificationsControl.xaml /// public partial class NotificationsControl : UserControl { private UIElement _previousFocusedElement; [TangoInject] private INotificationProvider _notificationProvider; public NotificationsControl() { InitializeComponent(); Loaded += NotificationsControl_Loaded; } private void NotificationsControl_Loaded(object sender, RoutedEventArgs e) { TangoIOC.Default.Inject(this); } private async void GridMessageBox_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if (gridMessageBox.IsVisible) { _previousFocusedElement = Keyboard.FocusedElement as UIElement; await Task.Delay(100); btnOK.Focus(); } else { _previousFocusedElement?.Focus(); } } private async void GridDialog_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if (btnDialogOK.IsDefault) { if (gridDialog.IsVisible) { _previousFocusedElement = Keyboard.FocusedElement as UIElement; await Task.Delay(100); btnDialogOK.Focus(); } else { _previousFocusedElement?.Focus(); } } } private async void GridInputBox_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if (gridInputBox.IsVisible) { _previousFocusedElement = Keyboard.FocusedElement as UIElement; await Task.Delay(100); txtInput.Focus(); Keyboard.Focus(txtInput); txtInput.SelectAll(); btnInputOK.IsDefault = true; } else { _previousFocusedElement?.Focus(); } } private void TxtInput_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (btnInputOK.Command != null) { if (btnInputOK.Command.CanExecute(null)) { btnInputOK.Command.Execute(null); } } e.Handled = true; } else if (e.Key == Key.Escape) { if (btnInputCancel.Command != null) { if (btnInputCancel.Command.CanExecute(null)) { btnInputCancel.Command.Execute(null); } } e.Handled = true; } } private void SnackbarItems_ScrollViewer_MouseEnter(object sender, MouseEventArgs e) { _notificationProvider.HoldSnackbarItemsTimeout = true; } private void SnackbarItems_ScrollViewer_MouseLeave(object sender, MouseEventArgs e) { _notificationProvider.HoldSnackbarItemsTimeout = false; } } }