using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using MultiTerm.Core.Common;
namespace MultiTerm.Core.ViewModel;
public abstract partial class TerminalViewModel : ObservableObject, ITerminalViewModel
{
public abstract string Title { get; }
public abstract TerminalViewType ViewType { get; }
public ProtocolType ProtocolType { get; private set; }
public event EventHandler? ClosingEvent;
public TerminalViewModel(ProtocolType protocolType)
{
this.ProtocolType = protocolType;
}
///
/// Method to override if any closing actions are required.
/// Closing can be cancelled using the return value.
///
/// true if closing is allowed. false if it shall be cancelled.
protected virtual bool ClosingActions() { return true; }
[RelayCommand]
public void CloseRequest()
{
if (this.ClosingActions() == true)
{
ClosingEvent?.Invoke(this, EventArgs.Empty);
}
}
}