// --------------------------------------------------------------------------------------------------------------------
//
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
//
//
// A Base Class for the View Models which contains reusable code.
//
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.ViewModels
{
using Caliburn.Micro;
using HandBrakeWPF.ViewModels.Interfaces;
///
/// A Base Class for the View Models which contains reusable code.
///
public class ViewModelBase : Screen, IViewModelBase
{
///
/// Backing Field to prevent the Load method being called more than once.
///
private bool hasLoaded;
///
/// Initializes a new instance of the class.
///
///
/// The window manager.
///
public ViewModelBase(IWindowManager windowManager)
{
this.WindowManager = windowManager;
}
///
/// Gets WindowManager.
///
public IWindowManager WindowManager { get; private set; }
///
/// Perform any Initialisation for this ViewModelBase.
///
public void Load()
{
if (!hasLoaded)
{
hasLoaded = true;
// Initialise the ViewModels OnLoad method if it exists.
this.OnLoad();
}
}
///
/// Load Method for the ViewModel
///
public virtual void OnLoad()
{
// Impliment in the ViewModel to perform viewmodel specific code.
}
}
}