namespace VideoBrowserTestApp.ViewModels
{
using System.Collections.Generic;
using System.Windows;
using System.Windows.Input;
using VideoBrowser.Common;
using VideoBrowserTestApp.Helpers;
using VideoBrowserTestApp.Tests;
///
/// Defines the .
///
public class MainWindowViewModel
{
#region Constructors
///
/// Initializes a new instance of the class.
///
internal MainWindowViewModel()
{
this.Tests = ReflectionHelper.GetInstances();
this.LoadedCommand = new RelayCommand(this.OnLoaded);
this.ClosedCommand = new RelayCommand(this.OnClosed);
}
#endregion Constructors
#region Properties
///
/// Gets the ClosedCommand.
///
public ICommand ClosedCommand { get; }
///
/// Gets the LoadedCommand.
///
public ICommand LoadedCommand { get; }
///
/// Gets the Tests.
///
public IList Tests { get; }
///
/// Gets or sets the MainWindow.
///
private Window MainWindow { get; set; }
#endregion Properties
#region Methods
///
/// The OnClosed.
///
/// The obj.
private void OnClosed(object obj)
{
Properties.Settings.Default.Save();
}
///
/// The OnLoaded.
///
/// The obj.
private void OnLoaded(object obj)
{
this.MainWindow = obj as Window;
var lastTest = Properties.Settings.Default.LastTest;
if (!string.IsNullOrEmpty(lastTest))
{
foreach (var test in this.Tests)
{
if (test.Name == lastTest)
{
test.TestCommand.Execute(this.MainWindow);
break;
}
}
}
}
#endregion Methods
}
}