2024-09-09 03:26:43 -07:00
|
|
|
|
using System;
|
|
|
|
|
using Avalonia.Collections;
|
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
|
|
|
|
|
namespace SourceGit.ViewModels
|
|
|
|
|
{
|
|
|
|
|
public class ConfigureWorkspace : ObservableObject
|
|
|
|
|
{
|
|
|
|
|
public AvaloniaList<Workspace> Workspaces
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
private set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Workspace Selected
|
|
|
|
|
{
|
|
|
|
|
get => _selected;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (SetProperty(ref _selected, value))
|
|
|
|
|
CanDeleteSelected = value != null && !value.IsActive;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanDeleteSelected
|
|
|
|
|
{
|
|
|
|
|
get => _canDeleteSelected;
|
|
|
|
|
private set => SetProperty(ref _canDeleteSelected, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ConfigureWorkspace()
|
|
|
|
|
{
|
|
|
|
|
Workspaces = new AvaloniaList<Workspace>();
|
|
|
|
|
Workspaces.AddRange(Preference.Instance.Workspaces);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add()
|
|
|
|
|
{
|
2024-09-18 06:35:33 -07:00
|
|
|
|
var workspace = new Workspace() { Name = $"Unnamed {DateTime.Now:yyyy-MM-dd HH:mm:ss}" };
|
2024-09-09 03:26:43 -07:00
|
|
|
|
Preference.Instance.Workspaces.Add(workspace);
|
|
|
|
|
Workspaces.Add(workspace);
|
|
|
|
|
Selected = workspace;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Delete()
|
|
|
|
|
{
|
|
|
|
|
if (_selected == null || _selected.IsActive)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Preference.Instance.Workspaces.Remove(_selected);
|
|
|
|
|
Workspaces.Remove(_selected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Workspace _selected = null;
|
|
|
|
|
private bool _canDeleteSelected = false;
|
|
|
|
|
}
|
|
|
|
|
}
|