Files
TradeBlotter/ViewModels/WorkspaceViewModel.cs
2024-02-23 06:58:53 -05:00

86 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Windows.Input;
using System.Linq;
using System.Text;
using TradeBlotter.Command;
namespace TradeBlotter.ViewModels
{
public delegate void InstantiateWorkspace(SaveParameters saveParameters);
public abstract class WorkspaceViewModel : ViewModelBase
{
private RelayCommand closeCommand;
public event EventHandler RequestClose;
private InstantiateWorkspace workspaceInstantiator;
private bool canClose=true;
private bool isClosed=false;
private String title="WorkspaceViewModel";
public WorkspaceViewModel Referer{get;set;}
protected WorkspaceViewModel()
{
}
public InstantiateWorkspace WorkspaceInstantiator
{
get
{
return workspaceInstantiator;
}
set
{
workspaceInstantiator = value;
}
}
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");
}
}
}
public virtual String Title
{
get
{
return title;
}
set
{
title=value;
base.OnPropertyChanged("Title");
}
}
private void OnRequestClose()
{
EventHandler handler = this.RequestClose;
if (null != handler) handler(this, EventArgs.Empty);
}
}
}