Reworked Settings view

This commit is contained in:
CreepyCrafter24 2019-10-21 15:18:08 +02:00
parent 4e654eebf6
commit 43fe5c4117
9 changed files with 151 additions and 198 deletions

View File

@ -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)
Test Updates

View File

@ -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()

View File

@ -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)

View File

@ -1,122 +0,0 @@
namespace UpTool2
{
partial class SettingsForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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<object>().ToArray());
}
}
}

86
UpTool2/SourcesForm.Designer.cs generated Normal file
View File

@ -0,0 +1,86 @@
namespace UpTool2
{
partial class SettingsForms
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

50
UpTool2/SourcesForm.cs Normal file
View File

@ -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);
}
}
}

View File

@ -117,7 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
<metadata name="sbName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="sbLink.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -66,11 +66,11 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingsForm.cs">
<Compile Include="SourcesForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SettingsForm.Designer.cs">
<DependentUpon>SettingsForm.cs</DependentUpon>
<Compile Include="SourcesForm.Designer.cs">
<DependentUpon>SourcesForm.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="DownloadDialog.resx">
<DependentUpon>DownloadDialog.cs</DependentUpon>
@ -88,8 +88,8 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="SettingsForm.resx">
<DependentUpon>SettingsForm.cs</DependentUpon>
<EmbeddedResource Include="SourcesForm.resx">
<DependentUpon>SourcesForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>