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

40 lines
1.2 KiB
C#
Raw Normal View History

2020-02-28 12:59:59 +01:00
using System.Linq;
2019-10-21 15:18:08 +02:00
using System.Windows.Forms;
using System.Xml.Linq;
2020-02-28 12:59:59 +01:00
using UpTool2.Tool;
2019-10-21 15:18:08 +02:00
namespace UpTool2
{
public partial class SettingsForms : Form
{
2020-02-28 12:59:59 +01:00
private XDocument doc;
private XElement meta;
private XElement repos;
2019-10-21 15:18:08 +02:00
public SettingsForms()
{
InitializeComponent();
2020-02-28 13:25:20 +01:00
Program.FixXML();
2020-02-28 12:59:59 +01:00
doc = XDocument.Load(PathTool.infoXML);
2019-10-21 15:18:08 +02:00
meta = doc.Element("meta");
repos = meta.Element("Repos");
foreach (XElement repo in repos.Elements("Repo"))
{
sourceGrid.Rows.Add(repo.Element("Name").Value, repo.Element("Link").Value);
}
}
private void SettingsForms_FormClosing(object sender, FormClosingEventArgs e)
{
repos.RemoveNodes();
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), new XElement("Link", (string)sourceGrid.Rows[y].Cells[1].Value)));
}
}
2020-02-28 12:59:59 +01:00
doc.Save(PathTool.infoXML);
2019-10-21 15:18:08 +02:00
}
}
2020-02-28 12:59:59 +01:00
}