From 43fe5c4117ad8405f6b22b0a8db9ee7123bb2fe6 Mon Sep 17 00:00:00 2001
From: CreepyCrafter24 <33260128+CreepyCrafter24@users.noreply.github.com>
Date: Mon, 21 Oct 2019 15:18:08 +0200
Subject: [PATCH] Reworked Settings view
---
ToDo.txt | 4 +-
UpTool2/MainForm.cs | 6 +-
UpTool2/Program.cs | 2 +-
UpTool2/SettingsForm.Designer.cs | 122 ------------------
UpTool2/SettingsForm.cs | 62 ---------
UpTool2/SourcesForm.Designer.cs | 86 ++++++++++++
UpTool2/SourcesForm.cs | 50 +++++++
.../{SettingsForm.resx => SourcesForm.resx} | 7 +-
UpTool2/UpTool2.csproj | 10 +-
9 files changed, 151 insertions(+), 198 deletions(-)
delete mode 100644 UpTool2/SettingsForm.Designer.cs
delete mode 100644 UpTool2/SettingsForm.cs
create mode 100644 UpTool2/SourcesForm.Designer.cs
create mode 100644 UpTool2/SourcesForm.cs
rename UpTool2/{SettingsForm.resx => SourcesForm.resx} (94%)
diff --git a/ToDo.txt b/ToDo.txt
index 8dd589a..236e22a 100644
--- a/ToDo.txt
+++ b/ToDo.txt
@@ -1,6 +1,4 @@
More Icons for Apps
More apps: Laptop Sim (when done)
Decent app Installer (Do not open CMD)
-Save Images on disk to allow offline usage
-Test Updates
-Remove Settings.settings (move to main XML)
\ No newline at end of file
+Test Updates
\ No newline at end of file
diff --git a/UpTool2/MainForm.cs b/UpTool2/MainForm.cs
index 9238a2c..39f1865 100644
--- a/UpTool2/MainForm.cs
+++ b/UpTool2/MainForm.cs
@@ -228,8 +228,8 @@ namespace UpTool2
if (meta.Element("Repos") == null)
meta.Add(new XElement("Repos"));
if (meta.Element("Repos").Elements("Repo").Count() == 0)
- meta.Element("Repos").Add(new XElement("Repo", "https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Repo.xml"));
- string[] repArr = meta.Element("Repos").Elements("Repo").Select(s => s.Value).ToArray();
+ meta.Element("Repos").Add(new XElement("Repo", new XElement("Name", "UpTool2 official Repo"), new XElement("Link", "https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Repo.xml")));
+ string[] repArr = meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link").Value).ToArray();
using (WebClient client = new WebClient())
{
for (int i = 0; i < repArr.Length; i++)
@@ -342,7 +342,7 @@ namespace UpTool2
reloadElements();
}
- private void Controls_settings_Click(object sender, EventArgs e) => new SettingsForm().Show();
+ private void Controls_settings_Click(object sender, EventArgs e) => new SettingsForms().Show();
#endregion
#region GUI (stuff only present for GUI)
void clearSelection()
diff --git a/UpTool2/Program.cs b/UpTool2/Program.cs
index 86a0ce5..1139bd4 100644
--- a/UpTool2/Program.cs
+++ b/UpTool2/Program.cs
@@ -80,7 +80,7 @@ namespace UpTool2
Directory.CreateDirectory(dir + @"\Apps");
string xml = dir + @"\info.xml";
if (!File.Exists(xml))
- new XElement("meta", new XElement("Version", 0), new XElement("Repos", new XElement("Repo", "https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Repo.xml")), new XElement("LocalRepo")).Save(xml);
+ new XElement("meta", new XElement("Version", 0), new XElement("Repos", new XElement("Repo", new XElement("Name", "UpTool2 official Repo"), new XElement("Link", "https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Repo.xml"))), new XElement("LocalRepo")).Save(xml);
XElement meta = XDocument.Load("https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Meta.xml").Element("meta");
int version = int.Parse(meta.Element("Version").Value);
if (int.Parse(XDocument.Load(xml).Element("meta").Element("Version").Value) < version)
diff --git a/UpTool2/SettingsForm.Designer.cs b/UpTool2/SettingsForm.Designer.cs
deleted file mode 100644
index 1b1c18d..0000000
--- a/UpTool2/SettingsForm.Designer.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-namespace UpTool2
-{
- partial class SettingsForm
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.repoList = new System.Windows.Forms.ListBox();
- this.minusButton = new System.Windows.Forms.Button();
- this.plusButton = new System.Windows.Forms.Button();
- this.repoBox = new System.Windows.Forms.TextBox();
- this.okButton = new System.Windows.Forms.Button();
- this.toolTip = new System.Windows.Forms.ToolTip(this.components);
- this.SuspendLayout();
- //
- // repoList
- //
- this.repoList.FormattingEnabled = true;
- this.repoList.Location = new System.Drawing.Point(12, 12);
- this.repoList.Name = "repoList";
- this.repoList.Size = new System.Drawing.Size(432, 95);
- this.repoList.TabIndex = 0;
- this.repoList.SelectedIndexChanged += new System.EventHandler(this.RepoList_SelectedIndexChanged);
- //
- // minusButton
- //
- this.minusButton.Location = new System.Drawing.Point(421, 113);
- this.minusButton.Name = "minusButton";
- this.minusButton.Size = new System.Drawing.Size(23, 23);
- this.minusButton.TabIndex = 1;
- this.minusButton.Text = "-";
- this.minusButton.UseVisualStyleBackColor = true;
- this.minusButton.Click += new System.EventHandler(this.MinusButton_Click);
- //
- // plusButton
- //
- this.plusButton.Location = new System.Drawing.Point(392, 113);
- this.plusButton.Name = "plusButton";
- this.plusButton.Size = new System.Drawing.Size(23, 23);
- this.plusButton.TabIndex = 2;
- this.plusButton.Text = "+";
- this.plusButton.UseVisualStyleBackColor = true;
- this.plusButton.Click += new System.EventHandler(this.PlusButton_Click);
- //
- // repoBox
- //
- this.repoBox.Location = new System.Drawing.Point(12, 115);
- this.repoBox.Name = "repoBox";
- this.repoBox.Size = new System.Drawing.Size(320, 20);
- this.repoBox.TabIndex = 3;
- //
- // okButton
- //
- this.okButton.Location = new System.Drawing.Point(338, 113);
- this.okButton.Name = "okButton";
- this.okButton.Size = new System.Drawing.Size(48, 23);
- this.okButton.TabIndex = 4;
- this.okButton.Text = "OK";
- this.okButton.UseVisualStyleBackColor = true;
- this.okButton.Click += new System.EventHandler(this.OkButton_Click);
- //
- // toolTip
- //
- this.toolTip.ShowAlways = true;
- //
- // SettingsForm
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(456, 146);
- this.Controls.Add(this.okButton);
- this.Controls.Add(this.repoBox);
- this.Controls.Add(this.plusButton);
- this.Controls.Add(this.minusButton);
- this.Controls.Add(this.repoList);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "SettingsForm";
- this.ShowIcon = false;
- this.ShowInTaskbar = false;
- this.Text = "Settings";
- this.TopMost = true;
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.ListBox repoList;
- private System.Windows.Forms.Button minusButton;
- private System.Windows.Forms.Button plusButton;
- private System.Windows.Forms.TextBox repoBox;
- private System.Windows.Forms.Button okButton;
- private System.Windows.Forms.ToolTip toolTip;
- }
-}
\ No newline at end of file
diff --git a/UpTool2/SettingsForm.cs b/UpTool2/SettingsForm.cs
deleted file mode 100644
index 041031e..0000000
--- a/UpTool2/SettingsForm.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using UpTool2.Properties;
-
-namespace UpTool2
-{
- public partial class SettingsForm : Form
- {
- int ind;
- public SettingsForm()
- {
- InitializeComponent();
- toolTip.SetToolTip(repoList, "Select the repository which you want to edit");
- toolTip.SetToolTip(repoBox, "Link of the selected repository (apply with OK)");
- toolTip.SetToolTip(okButton, "Set the repositorys link");
- toolTip.SetToolTip(plusButton, "Add a new repository");
- toolTip.SetToolTip(minusButton, "Remove the selected repository");
- SaveAndReload();
- }
-
- private void RepoList_SelectedIndexChanged(object sender, EventArgs e)
- {
- repoBox.Text = (string)repoList.SelectedItem;
- ind = repoList.SelectedIndex;
- }
-
- private void OkButton_Click(object sender, EventArgs e)
- {
- if (!string.IsNullOrWhiteSpace(repoBox.Text))
- {
- Settings.Default.Repos[ind] = repoBox.Text;
- SaveAndReload();
- }
- }
-
- private void PlusButton_Click(object sender, EventArgs e)
- {
- Settings.Default.Repos.Add("New Repo");
- SaveAndReload();
- }
-
- private void MinusButton_Click(object sender, EventArgs e)
- {
- Settings.Default.Repos.RemoveAt(ind);
- SaveAndReload();
- }
-
- void SaveAndReload()
- {
- Settings.Default.Save();
- repoList.Items.Clear();
- repoList.Items.AddRange(Settings.Default.Repos.Cast