This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
UpTool2/UpTool2/SourcesForm.cs

35 lines
1.2 KiB
C#
Raw Normal View History

2020-02-28 14:26:16 +01:00
using System.Windows.Forms;
2019-10-21 15:18:08 +02:00
using System.Xml.Linq;
2020-03-24 20:53:23 +01:00
using UpToolLib.Tool;
2019-10-21 15:18:08 +02:00
namespace UpTool2
{
public partial class SettingsForms : Form
{
private readonly XDocument _doc;
private readonly XElement _repos;
2020-02-28 12:59:59 +01:00
2019-10-21 15:18:08 +02:00
public SettingsForms()
{
InitializeComponent();
2020-02-28 14:26:16 +01:00
Program.FixXml();
_doc = XDocument.Load(PathTool.InfoXml);
_repos = _doc.Element("meta").Element("Repos");
2020-05-16 17:59:44 +02:00
sourceGrid.Columns.Clear();
sourceGrid.Columns.Add("name", "Name");
sourceGrid.Columns.Add("link", "Link");
foreach (XElement repo in _repos.Elements("Repo"))
2019-10-21 15:18:08 +02:00
sourceGrid.Rows.Add(repo.Element("Name").Value, repo.Element("Link").Value);
}
private void SettingsForms_FormClosing(object sender, FormClosingEventArgs e)
{
_repos.RemoveNodes();
2019-10-21 15:18:08 +02:00
for (int y = 0; y < sourceGrid.Rows.Count; y++)
if (y + 1 < sourceGrid.Rows.Count)
_repos.Add(new XElement("Repo", new XElement("Name", (string) sourceGrid.Rows[y].Cells[0].Value),
2020-02-28 14:26:16 +01:00
new XElement("Link", (string) sourceGrid.Rows[y].Cells[1].Value)));
_doc.Save(PathTool.InfoXml);
2019-10-21 15:18:08 +02:00
}
}
2020-02-28 12:59:59 +01:00
}