2024-08-22 20:24:31 -07:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text.Json.Serialization;
|
2024-03-17 18:37:06 -07:00
|
|
|
|
|
2024-02-05 23:08:37 -08:00
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
namespace SourceGit.ViewModels
|
|
|
|
|
{
|
|
|
|
|
public class RepositoryNode : ObservableObject
|
|
|
|
|
{
|
|
|
|
|
public string Id
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get => _id;
|
2024-03-17 18:37:06 -07:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-02-29 21:40:12 -08:00
|
|
|
|
var normalized = value.Replace('\\', '/');
|
|
|
|
|
SetProperty(ref _id, normalized);
|
|
|
|
|
}
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public string Name
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get => _name;
|
|
|
|
|
set => SetProperty(ref _name, value);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public int Bookmark
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get => _bookmark;
|
|
|
|
|
set => SetProperty(ref _bookmark, value);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public bool IsRepository
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get => _isRepository;
|
|
|
|
|
set => SetProperty(ref _isRepository, value);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public bool IsExpanded
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get => _isExpanded;
|
|
|
|
|
set => SetProperty(ref _isExpanded, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonIgnore]
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public bool IsVisible
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get => _isVisible;
|
|
|
|
|
set => SetProperty(ref _isVisible, value);
|
|
|
|
|
}
|
2024-03-17 18:37:06 -07:00
|
|
|
|
|
2024-08-22 06:10:23 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public int Depth
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
} = 0;
|
|
|
|
|
|
2024-08-22 20:24:31 -07:00
|
|
|
|
public List<RepositoryNode> SubNodes
|
2024-03-17 18:37:06 -07:00
|
|
|
|
{
|
2024-08-22 20:24:31 -07:00
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
} = [];
|
2024-02-05 23:08:37 -08:00
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public void Edit()
|
|
|
|
|
{
|
2024-03-31 01:54:29 -07:00
|
|
|
|
if (PopupHost.CanCreatePopup())
|
|
|
|
|
PopupHost.ShowPopup(new EditRepositoryNode(this));
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public void AddSubFolder()
|
|
|
|
|
{
|
2024-03-31 01:54:29 -07:00
|
|
|
|
if (PopupHost.CanCreatePopup())
|
|
|
|
|
PopupHost.ShowPopup(new CreateGroup(this));
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public void OpenInFileManager()
|
|
|
|
|
{
|
2024-03-31 01:54:29 -07:00
|
|
|
|
if (!IsRepository)
|
|
|
|
|
return;
|
2024-02-05 23:08:37 -08:00
|
|
|
|
Native.OS.OpenInFileManager(_id);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public void OpenTerminal()
|
|
|
|
|
{
|
2024-03-31 01:54:29 -07:00
|
|
|
|
if (!IsRepository)
|
|
|
|
|
return;
|
2024-02-05 23:08:37 -08:00
|
|
|
|
Native.OS.OpenTerminal(_id);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public void Delete()
|
|
|
|
|
{
|
2024-03-31 01:54:29 -07:00
|
|
|
|
if (PopupHost.CanCreatePopup())
|
|
|
|
|
PopupHost.ShowPopup(new DeleteRepositoryNode(this));
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string _id = string.Empty;
|
|
|
|
|
private string _name = string.Empty;
|
|
|
|
|
private bool _isRepository = false;
|
|
|
|
|
private int _bookmark = 0;
|
|
|
|
|
private bool _isExpanded = false;
|
|
|
|
|
private bool _isVisible = true;
|
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|