55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Eto.Forms;
|
|
using UpToolEto.Controls;
|
|
using UpToolLib.DataStructures;
|
|
using UpToolLib.v2;
|
|
|
|
namespace UpToolEto.Forms
|
|
{
|
|
public class RepoForm : Dialog
|
|
{
|
|
private readonly RepoManagement _management;
|
|
private List<Repo> _repos = new();
|
|
private StackLayout _layout;
|
|
public RepoForm(RepoManagement management)
|
|
{
|
|
_management = management;
|
|
_repos.AddRange(management.GetRepos());
|
|
Title = "Sources";
|
|
_layout = new StackLayout();
|
|
Content = _layout;
|
|
Update();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
_layout.Items.Clear();
|
|
_layout.Items.Add(new StackLayoutItem(new Button((_, _) =>
|
|
{
|
|
_repos.Add(new Repo
|
|
{
|
|
Name = "New repo",
|
|
Url = "https://example.com/repo.xml"
|
|
});
|
|
Update();
|
|
})
|
|
{
|
|
Text = "Add",
|
|
}, HorizontalAlignment.Stretch));
|
|
StackLayout reposLayout = new();
|
|
for (int i = 0; i < _repos.Count; i++)
|
|
reposLayout.Items.Add(new StackLayoutItem(new RepoItem(_repos[i], i, Update, _repos), HorizontalAlignment.Stretch));
|
|
_layout.Items.Add(new StackLayoutItem(new Scrollable{Content = reposLayout}, HorizontalAlignment.Stretch, true));
|
|
_layout.Items.Add(new StackLayoutItem(new Button((_, _) =>
|
|
{
|
|
_management.Save(_repos);
|
|
Close();
|
|
})
|
|
{
|
|
Text = "Save"
|
|
}, HorizontalAlignment.Stretch));
|
|
}
|
|
}
|
|
}
|