// -------------------------------------------------------------------------------------------------------------------- // // 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 HandBrake.ApplicationServices.Services.Interfaces; using HandBrakeWPF.ViewModels.Interfaces; /// /// A Base Class for the View Models which contains reusable code. /// public class ViewModelBase : Screen, IViewModelBase { #region Constants and Fields /// /// Backing Field to prevent the Load method being called more than once. /// private bool hasLoaded; /// /// The title. /// private string title; #endregion #region Constructors and Destructors /// /// Initializes a new instance of the class. /// public ViewModelBase() { } #endregion #region Properties /// /// Gets or sets Details. /// public string Title { get { return this.title; } set { this.title = value; this.NotifyOfPropertyChange("Title"); } } /// /// Gets or sets WindowManager. /// public IWindowManager WindowManager { get; set; } /// /// Gets or sets UserSettingService. /// public IUserSettingService UserSettingService { get; set; } #endregion #region Public Methods /// /// Perform any Initialisation for this ViewModelBase. /// public void Load() { if (!this.hasLoaded) { this.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. } #endregion } }