using System;
using System.Windows.Input;

namespace Navigator.Core
{
  public abstract class WorkspaceViewModel : BaseViewModel
  {
    private RelayCommand closeCommand;
    public event EventHandler RequestClose;
    private bool canClose=true;
    private bool isClosed=false;
    public WorkspaceViewModel Referer{get;set;}

    protected WorkspaceViewModel()
    {
      Title="WorkspaceViewModel";
    }
    public ICommand CloseCommand
    {
      get
      {
        if (null == closeCommand) closeCommand = new RelayCommand(param => this.OnRequestClose());
        return closeCommand;
      }
    }
    public bool IsClosed
    {
      get { return isClosed; }
      set
      {
        if (isClosed != value)
        {
          isClosed = value;
          base.OnPropertyChanged("IsClosed");
        }
      }
    }
    public bool CanClose
    {
      get { return canClose; }
      set
      {
        if (canClose != value)
        {
          canClose = value;
          base.OnPropertyChanged("CanClose");
        }
      }
    }
    private void OnRequestClose()
    {
      EventHandler handler = this.RequestClose;
      if (null != handler) handler(this, EventArgs.Empty);
    }
  }
}
