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().ToArray()); - } - } -} diff --git a/UpTool2/SourcesForm.Designer.cs b/UpTool2/SourcesForm.Designer.cs new file mode 100644 index 0000000..8d1cb1d --- /dev/null +++ b/UpTool2/SourcesForm.Designer.cs @@ -0,0 +1,86 @@ +namespace UpTool2 +{ + partial class SettingsForms + { + /// + /// 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.sourceGrid = new System.Windows.Forms.DataGridView(); + this.sbName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.sbLink = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.sourceGrid)).BeginInit(); + this.SuspendLayout(); + // + // sourceGrid + // + this.sourceGrid.BackgroundColor = System.Drawing.Color.White; + this.sourceGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.sourceGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.sbName, + this.sbLink}); + this.sourceGrid.Dock = System.Windows.Forms.DockStyle.Fill; + this.sourceGrid.GridColor = System.Drawing.Color.White; + this.sourceGrid.Location = new System.Drawing.Point(0, 0); + this.sourceGrid.MultiSelect = false; + this.sourceGrid.Name = "sourceGrid"; + this.sourceGrid.Size = new System.Drawing.Size(800, 450); + this.sourceGrid.TabIndex = 0; + // + // sbName + // + this.sbName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.sbName.HeaderText = "Name"; + this.sbName.Name = "sbName"; + this.sbName.Width = 60; + // + // sbLink + // + this.sbLink.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.sbLink.HeaderText = "Link"; + this.sbLink.Name = "sbLink"; + this.sbLink.Width = 52; + // + // SettingsForms + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.sourceGrid); + this.Name = "SettingsForms"; + this.Text = "Sources"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SettingsForms_FormClosing); + ((System.ComponentModel.ISupportInitialize)(this.sourceGrid)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.DataGridView sourceGrid; + private System.Windows.Forms.DataGridViewTextBoxColumn sbName; + private System.Windows.Forms.DataGridViewTextBoxColumn sbLink; + } +} \ No newline at end of file diff --git a/UpTool2/SourcesForm.cs b/UpTool2/SourcesForm.cs new file mode 100644 index 0000000..687930a --- /dev/null +++ b/UpTool2/SourcesForm.cs @@ -0,0 +1,50 @@ +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 System.Xml.Linq; + +namespace UpTool2 +{ + public partial class SettingsForms : Form + { + string dir => Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\UpTool2"; + string xml => dir + @"\info.xml"; + XDocument doc; + XElement meta; + XElement repos; + public SettingsForms() + { + InitializeComponent(); + doc = XDocument.Load(xml); + meta = doc.Element("meta"); + 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", new XElement("Name", "UpTool2 official Repo"), new XElement("Link", "https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Repo.xml"))); + 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))); + } + } + doc.Save(xml); + } + } +} diff --git a/UpTool2/SettingsForm.resx b/UpTool2/SourcesForm.resx similarity index 94% rename from UpTool2/SettingsForm.resx rename to UpTool2/SourcesForm.resx index 8766f29..2451d91 100644 --- a/UpTool2/SettingsForm.resx +++ b/UpTool2/SourcesForm.resx @@ -117,7 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 + + True + + + True \ No newline at end of file diff --git a/UpTool2/UpTool2.csproj b/UpTool2/UpTool2.csproj index b88ade8..466e95a 100644 --- a/UpTool2/UpTool2.csproj +++ b/UpTool2/UpTool2.csproj @@ -66,11 +66,11 @@ - + Form - - SettingsForm.cs + + SourcesForm.cs DownloadDialog.cs @@ -88,8 +88,8 @@ Resources.resx True - - SettingsForm.cs + + SourcesForm.cs