109 lines
2.0 KiB
C#
109 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Input;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using TradeBlotter.Command;
|
|
using Telerik.Windows.Input.Touch;
|
|
|
|
namespace TradeBlotter.ViewModels
|
|
{
|
|
public delegate void InstantiateWorkspace(SaveParameters saveParameters);
|
|
public abstract class WorkspaceViewModel : ViewModelBase
|
|
{
|
|
// Relay Command
|
|
private RelayCommand closeCommand;
|
|
|
|
// Events
|
|
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");
|
|
}
|
|
}
|
|
|
|
public virtual String Header
|
|
{
|
|
get
|
|
{
|
|
return title;
|
|
}
|
|
}
|
|
|
|
private void OnRequestClose()
|
|
{
|
|
EventHandler handler = this.RequestClose;
|
|
if (null != handler) handler(this, EventArgs.Empty);
|
|
}
|
|
}
|
|
}
|