You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
using Common.StartupHelpers;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace MultiTerm.Core.ViewModel;
|
|
|
|
public partial class ShellViewModel : ObservableObject
|
|
{
|
|
private readonly IAbstractFactory<SendReceiveViewModel> sendReceiveViewModelFactory;
|
|
|
|
[ObservableProperty]
|
|
private string title = "ShellView Test";
|
|
|
|
[ObservableProperty]
|
|
private ObservableCollection<ITerminalViewModel> terminalViewModels = new();
|
|
|
|
[ObservableProperty]
|
|
private ITerminalViewModel? selectedTerminalViewModel;
|
|
|
|
public ShellViewModel(IAbstractFactory<SendReceiveViewModel> sendReceiveViewModelFactory)
|
|
{
|
|
this.sendReceiveViewModelFactory = sendReceiveViewModelFactory;
|
|
// create a new terminal
|
|
this.AppendTerminal(this.sendReceiveViewModelFactory.Create());
|
|
}
|
|
|
|
public void AppendTerminal(ITerminalViewModel newTerminal)
|
|
{
|
|
// guard null value
|
|
if(newTerminal == null)
|
|
{
|
|
return;
|
|
}
|
|
// add to collection and set as selected
|
|
this.TerminalViewModels.Add(newTerminal);
|
|
this.SelectedTerminalViewModel = newTerminal;
|
|
}
|
|
}
|
|
|