Files

49 lines
1.7 KiB
C#
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
using DTS.Common.Base;
using DTS.Common.Events;
using DTS.Common.Interface;
using Prism.Ioc;
using Prism.Events;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace DTS.Viewer.PSDReport
{
/// <summary>
/// Interaction logic for PSDReportMainViewGrid.xaml
/// </summary>
public partial class PSDReportMainViewGrid : IPSDReportMainViewGrid
{
public PSDReportMainViewGrid()
{
InitializeComponent();
Loaded += PSDReportMainViewGrid_Loaded;
}
private IEventAggregator _eventAggregator { get; set; }
private void SetFocus()
{
chartResultsTab.IsSelected = true;
chartResultsTab.Focusable = true;
chartResultsTab.Focus();
}
//FB 14797 Subscribe to event after the page loaded to make sure eventAggregator is available
private void PSDReportMainViewGrid_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
_eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
_eventAggregator?.GetEvent<GraphLoadedCountNotification>().Subscribe(OnGraphLoadedCountNotification);
}
//FB 14797 Set the focus to first tab (chartOptTab) after the graph is fully loaded (3 sec)
private void OnGraphLoadedCountNotification(GraphLoadedCountNotificationArg arg)
{
if (null != DataContext && (IBaseViewModel)DataContext != arg.ParentVM) return;
Task.Run(() =>
{
Thread.Sleep(TimeSpan.FromSeconds(3));
Dispatcher.BeginInvoke((Action)SetFocus);
});
}
}
}