using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.DI;
using Tango.SharedUI;
namespace Tango.MachineStudio.Common
{
///
/// Represents a Machine Studio view model
///
///
///
public abstract class StudioViewModel : ViewModel, IStudioViewModel
{
private bool _isVisible;
///
/// Gets or sets a value indicating whether this view model view's is visible.
///
public bool IsVisible
{
get { return _isVisible; }
set { _isVisible = value; RaisePropertyChangedAuto(); }
}
///
/// Initializes a new instance of the class.
///
public StudioViewModel() : base()
{
}
///
/// Called when the user has navigated out of this view model.
///
public virtual void OnNavigatedFrom()
{
IsVisible = false;
}
///
/// Called when the user has navigated in to this view model.
///
public virtual void OnNavigatedTo()
{
IsVisible = true;
}
///
/// Called before the application is shutting down.
/// Return false to cancel the shutdown in case an important process is in progress.
///
///
public virtual Task OnShutdownRequest()
{
return Task.FromResult(true);
}
///
/// Called when application is shutting down.
///
public virtual void OnShuttingDown()
{
}
///
/// Called when the application has been started
///
public virtual void OnApplicationStarted()
{
}
///
/// Called when the application is ready and all modules are loaded.
///
public abstract void OnApplicationReady();
}
///
/// Represents a Machine Studio view model with a support for a view contract.
///
///
///
public abstract class StudioViewModel : StudioViewModel where TView : IView
{
///
/// Gets the view model's view.
///
public TView View { get; private set; }
///
/// Initializes a new instance of the class.
///
public StudioViewModel() : base()
{
TangoIOC.Default.GetInstanceWhenAvailable((view) =>
{
View = view;
OnViewAttached(view);
});
}
///
/// Called when the view has been attached
///
/// The view.
protected virtual void OnViewAttached(TView view)
{
//Do Nothing.
}
}
}