203 lines
7.2 KiB
C#
203 lines
7.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Threading.Tasks;
|
|
using DTS.Common.Base;
|
|
using DTS.Common.Classes.TestMetadata;
|
|
using DTS.Common.Events;
|
|
using DTS.Common.Interface;
|
|
using DTS.Common.Interface.TestDefinition;
|
|
using DTS.Viewer.TestSummaryList.Model;
|
|
using Microsoft.Practices.Prism.Events;
|
|
using Microsoft.Practices.Prism.Interactivity.InteractionRequest;
|
|
using Microsoft.Practices.Prism.Regions;
|
|
using Microsoft.Practices.Unity;
|
|
|
|
// ReSharper disable ConvertToAutoProperty
|
|
|
|
namespace DTS.Viewer.TestSummaryList.ViewModel
|
|
{
|
|
public class TestSummaryViewModel : BaseViewModel<ITestSummaryListViewModel>, ITestSummaryListViewModel
|
|
{
|
|
public ITestSummaryListView TestSummaryListView { get; private set; }
|
|
private IBaseWindowModel Parent { get; set; }
|
|
private IEventAggregator _eventAggregator { get; set; }
|
|
|
|
private IRegionManager _regionManager;
|
|
private IUnityContainer UnityContainer { get; set; }
|
|
public InteractionRequest<Notification> NotificationRequest { get; private set; }
|
|
public InteractionRequest<Confirmation> ConfirmationRequest { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Creates a new instance of the TechnologyDoFrontEditViewModel.
|
|
/// </summary>
|
|
/// <param name="view">The TestListView View.</param>
|
|
/// <param name="regionManager">The logical placeholder defined within the application's UI (in the shell or within views) into which views are displayed.</param>
|
|
/// <param name="eventAggregator">The EventAggregator which allows different components to publish/subscribe to events without being coupled to each other.</param>
|
|
/// <param name="unityContainer">The unityContainer.</param>
|
|
public TestSummaryViewModel(ITestSummaryListView view, IRegionManager regionManager, IEventAggregator eventAggregator,
|
|
IUnityContainer unityContainer)
|
|
: base(regionManager, eventAggregator, unityContainer)
|
|
{
|
|
TestSummaryListView = view;
|
|
TestSummaryListView.DataContext = this;
|
|
NotificationRequest = new InteractionRequest<Notification>();
|
|
ConfirmationRequest = new InteractionRequest<Confirmation>();
|
|
|
|
_eventAggregator = eventAggregator;
|
|
UnityContainer = unityContainer;
|
|
_regionManager = regionManager;
|
|
_eventAggregator.GetEvent<RaiseNotification>().Subscribe(OnRaiseNotification);
|
|
_eventAggregator.GetEvent<DataFolderChangedEvent>().Subscribe(OnDataFolderChanged);
|
|
|
|
}
|
|
|
|
#region Methods
|
|
|
|
public override void Initialize()
|
|
{
|
|
|
|
}
|
|
|
|
public override void Initialize(object parameter)
|
|
{
|
|
Parent = (IBaseWindowModel)parameter;
|
|
|
|
}
|
|
|
|
private void OnDataFolderChanged(string path)
|
|
{
|
|
if (String.IsNullOrEmpty(path)) return;
|
|
|
|
IsBusy = true;
|
|
_eventAggregator.GetEvent<ShowStatus>().Publish(new StatusInfo(StatusInfo.StatusState.Busy, "Please wait..."));
|
|
var td = new TestSummaryModel { Parent = this, _eventAggregator = _eventAggregator };
|
|
td.GetTestSummary(path);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Private Event handler for RaiseNotification event.
|
|
/// </summary>
|
|
private void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle)
|
|
{
|
|
// Notification object expects a NotificationContentEventArgsWithoutTitle object and a Title string.
|
|
var eventArgsWithoutTitle = new NotificationContentEventArgs(eventArgsWithTitle.Message, eventArgsWithTitle.MessageDetails, eventArgsWithTitle.Image);
|
|
|
|
NotificationRequest.Raise(new Notification
|
|
{
|
|
Content = eventArgsWithoutTitle,
|
|
Title = eventArgsWithTitle.Title
|
|
});
|
|
}
|
|
|
|
public override void Activated()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override void Cleanup()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public new Task CleanupAsync()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override Task InitializeAsync()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override Task InitializeAsync(object parameter)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void PublishSelectedTestSummaryList()
|
|
{
|
|
_eventAggregator.GetEvent<TestSummaryChangeNotification>().Publish(SelectedTestSummaryList);
|
|
_eventAggregator.GetEvent<TestSelectedChangedEvent>().Publish(SelectedTestSummaryList.Count);
|
|
}
|
|
#endregion
|
|
|
|
#region ContextRegion
|
|
|
|
public object ContextNavigationRegion
|
|
{
|
|
get => ((TestSummaryView)TestSummaryListView).TestListRegion.Content;
|
|
set
|
|
{
|
|
((TestSummaryView)TestSummaryListView).TestListRegion.Content = value;
|
|
OnPropertyChanged("ContextNavigationRegion");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
private TestSummary _selectedTestSummary = new TestSummary();
|
|
public TestSummary SelectedTestSummary
|
|
{
|
|
get => _selectedTestSummary;
|
|
set { _selectedTestSummary = value; OnPropertyChanged("SelectedTestSummary"); }
|
|
}
|
|
private List<ITestSummary> _selectedTestSummaryList = new List<ITestSummary>();
|
|
public List<ITestSummary> SelectedTestSummaryList
|
|
{
|
|
get => _selectedTestSummaryList;
|
|
set { _selectedTestSummaryList = value; OnPropertyChanged("SelectedTestSummaryList"); }
|
|
}
|
|
|
|
private ObservableCollection<ITestSummary> _testSummaryList = new ObservableCollection<ITestSummary>();
|
|
public ObservableCollection<ITestSummary> TestSummaryList
|
|
{
|
|
get => _testSummaryList;
|
|
set { _testSummaryList = value; OnPropertyChanged("TestSummaryList"); }
|
|
}
|
|
|
|
///<summary>
|
|
///Occurs when a property value changes.
|
|
///</summary>
|
|
public new event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
private new void OnPropertyChanged(string propertyName)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Gets the HeaderInfo.
|
|
/// </summary>
|
|
public string HeaderInfo => "TestSummaryRegion";
|
|
|
|
private bool _isBusy = false;
|
|
public new bool IsBusy
|
|
{
|
|
get => _isBusy;
|
|
set { _isBusy = value; OnPropertyChanged("IsBusy"); }
|
|
}
|
|
|
|
private bool _isDirty;
|
|
public new bool IsDirty
|
|
{
|
|
get => _isDirty;
|
|
set => _isDirty = value;
|
|
}
|
|
|
|
private bool _isNavigationIncluded;
|
|
public new bool IsNavigationIncluded
|
|
{
|
|
get => _isNavigationIncluded;
|
|
set => _isNavigationIncluded = value;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|