General improvements

This commit is contained in:
CreepyCrafter24 2019-11-09 20:51:53 +01:00
parent 77637d1d8a
commit 66b832a283
4 changed files with 79 additions and 39 deletions

View File

@ -1,5 +1,6 @@
More Icons for Apps
More apps: Laptop Sim (when done)
Fix installing apps (command prompt suprises users, which may close it)
Use background colors for status indication, ignore repos
Fix opening Folder instead of running program when clicking "Run"
Split up main File (MainForm.cs) to (more or less) independent modules
Allow Repos to contain "Links" to seperate Repos/App files (Repo with only one app & without a repo tag)
NOTE: All command prompts will be removed soon (tm) Update your scripts to reflect this change (there may be some things provided for dialogs)

View File

@ -8,6 +8,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9841227C-3F1B-4C32-8123-3DB2CF4E15EE}"
ProjectSection(SolutionItems) = preProject
FolderLayout.txt = FolderLayout.txt
.github\workflows\main.yml = .github\workflows\main.yml
ToDo.txt = ToDo.txt
EndProjectSection
EndProject

View File

@ -39,12 +39,12 @@
this.infoPanel_Title = new System.Windows.Forms.Label();
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.optionsPanel = new System.Windows.Forms.Panel();
this.controls_upload = new System.Windows.Forms.Button();
this.filterBox = new System.Windows.Forms.ComboBox();
this.searchBox = new System.Windows.Forms.TextBox();
this.controls_settings = new System.Windows.Forms.Button();
this.controls_reload = new System.Windows.Forms.Button();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.controls_upload = new System.Windows.Forms.Button();
this.searchPackageDialog = new System.Windows.Forms.OpenFileDialog();
this.infoPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
@ -175,6 +175,17 @@
this.optionsPanel.Size = new System.Drawing.Size(268, 59);
this.optionsPanel.TabIndex = 0;
//
// controls_upload
//
this.controls_upload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.controls_upload.Location = new System.Drawing.Point(242, 5);
this.controls_upload.Name = "controls_upload";
this.controls_upload.Size = new System.Drawing.Size(23, 23);
this.controls_upload.TabIndex = 4;
this.controls_upload.Text = "↑";
this.controls_upload.UseVisualStyleBackColor = true;
this.controls_upload.Click += new System.EventHandler(this.controls_upload_Click);
//
// filterBox
//
this.filterBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@ -224,17 +235,6 @@
this.toolTip.ReshowDelay = 100;
this.toolTip.ShowAlways = true;
//
// controls_upload
//
this.controls_upload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.controls_upload.Location = new System.Drawing.Point(242, 5);
this.controls_upload.Name = "controls_upload";
this.controls_upload.Size = new System.Drawing.Size(23, 23);
this.controls_upload.TabIndex = 4;
this.controls_upload.Text = "↑";
this.controls_upload.UseVisualStyleBackColor = true;
this.controls_upload.Click += new System.EventHandler(this.controls_upload_Click);
//
// searchPackageDialog
//
this.searchPackageDialog.Filter = "Packages (*.zip)|*.zip";

View File

@ -13,6 +13,7 @@ using System.Linq;
using Microsoft.VisualBasic;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Threading;
namespace UpTool2
{
@ -198,19 +199,26 @@ namespace UpTool2
string xml = dir + @"\info.xml";
XDocument.Load(xml).Element("meta").Element("LocalRepo").Elements().ToList().ForEach(app =>
{
apps.Add(Guid.Parse(app.Element("ID").Value), new App(
app.Element("Name").Value,
app.Element("Description").Value,
int.Parse(app.Element("Version").Value),
app.Element("File").Value,
false,
app.Element("Hash").Value,
Guid.Parse(app.Element("ID").Value),
ColorTranslator.FromHtml(app.Element("Color").Value),
app.Element("Icon") == null ? Resources.C_64.ToBitmap() : (Bitmap)new ImageConverter().ConvertFrom(Convert.FromBase64String(app.Element("Icon").Value)),
app.Element("MainFile") != null,
app.Element("MainFile") != null ? "" : app.Element("MainFile").Value
Guid id = Guid.Parse(app.Element("ID").Value);
string locInPath = getAppPath(id) + "\\info.xml";
XElement locIn = File.Exists(locInPath) ? XDocument.Load(locInPath).Element("app") : app;
apps.Add(id, new App(
name: locIn.Element("Name").Value,
description: locIn.Element("Description").Value,
version: int.Parse(app.Element("Version").Value),
file: app.Element("File").Value,
local: false,
hash: app.Element("Hash").Value,
iD: id,
color: Color.White,
icon: app.Element("Icon") == null ? Resources.C_64.ToBitmap() : (Bitmap)new ImageConverter().ConvertFrom(Convert.FromBase64String(app.Element("Icon").Value)),
runnable: locIn.Element("MainFile") != null || app.Element("MainFile") != null,
mainFile: locIn.Element("MainFile") == null ? (app.Element("MainFile") == null ? "" : app.Element("MainFile").Value) : locIn.Element("MainFile").Value
));
#if DEBUG
Console.WriteLine(locIn.Element("MainFile") == null ? "NULL" : locIn.Element("MainFile").Value);
Console.WriteLine(apps[id].mainFile);
#endif
});
Directory.GetDirectories(dir + @"\Apps\").Where(s => !apps.ContainsKey(Guid.Parse(Path.GetFileName(s)))).ToList().ForEach(s =>
{
@ -248,7 +256,6 @@ namespace UpTool2
//"Sanity check"
int.Parse(app.Element("Version").Value);
Guid.Parse(app.Element("ID").Value);
ColorTranslator.FromHtml(app.Element("Color").Value);
//Create XElement
tmp_apps_list.Add(new XElement("App",
new XElement("Name", app.Element("Name").Value),
@ -293,10 +300,6 @@ namespace UpTool2
catch { }
#endif
}
if (app.Element("Color") == null)
tmp_apps_list.Last().Add(new XElement("Color", "#FFFFFF"));
else
tmp_apps_list.Last().Add(new XElement("Color", app.Element("Color").Value));
if (tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value).Count() > 1)
tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value).Reverse().Skip(1).ToList().ForEach(a => tmp_apps_list.Remove(a));
}
@ -320,7 +323,21 @@ namespace UpTool2
}
#endregion
#region Run/Update/Reload/Settings (Small links to other stuff)
private void Action_run_Click(object sender, EventArgs e) => _ = Process.Start(new ProcessStartInfo { FileName = getDataPath((App)action_run.Tag) + "\\" + ((App)action_run.Tag).mainFile, WorkingDirectory = getDataPath((App)action_run.Tag) });
private void Action_run_Click(object sender, EventArgs e)
{
Console.WriteLine(new string('-', 10));
Console.WriteLine(getDataPath((App)action_run.Tag));
Console.WriteLine("\\");
Console.WriteLine(((App)action_run.Tag).mainFile);
Console.WriteLine(getDataPath((App)action_run.Tag));
_ = Process.Start(
new ProcessStartInfo {
FileName = getDataPath((App)action_run.Tag) + "\\" +
((App)action_run.Tag).mainFile,
WorkingDirectory = getDataPath((App)action_run.Tag)
});
}
private void Action_update_Click(object sender, EventArgs e)
{
try
@ -356,14 +373,31 @@ namespace UpTool2
}
private void updateSidebarV(object sender, EventArgs e)
{
Enum.TryParse(filterBox.SelectedValue.ToString(), out Status status);
for (int i = 0; i < sidebarPanel.Controls.Count; i++)
#if DEBUG
if (searchBox.Text == "!DEBUG:PRINT!")
{
Panel sidebarIcon = (Panel)sidebarPanel.Controls[i];
App app = (App)sidebarIcon.Tag;
sidebarIcon.Visible = app.name.Contains(searchBox.Text) && ((int)app.status & (int)(Program.online ? status : Status.Installed)) != 0;
searchBox.Text = "!DEBUG:PRINT";
string _tmp_file = Path.GetTempFileName();
File.WriteAllText(_tmp_file, string.Join("\r\n\r\n", apps.Select(app => app.Value).Select(app => app.ToString()).ToArray()));
new Thread(() => {
Process.Start("notepad", _tmp_file).WaitForExit();
File.Delete(_tmp_file);
}).Start();
}
clearSelection();
else
{
#endif
Enum.TryParse(filterBox.SelectedValue.ToString(), out Status status);
for (int i = 0; i < sidebarPanel.Controls.Count; i++)
{
Panel sidebarIcon = (Panel)sidebarPanel.Controls[i];
App app = (App)sidebarIcon.Tag;
sidebarIcon.Visible = app.name.Contains(searchBox.Text) && ((int)app.status & (int)(Program.online ? status : Status.Installed)) != 0;
}
clearSelection();
#if DEBUG
}
#endif
}
public MainForm()
{
@ -416,6 +450,9 @@ namespace UpTool2
this.icon = icon ?? throw new ArgumentNullException(nameof(icon));
this.runnable = runnable;
this.mainFile = mainFile ?? throw new ArgumentNullException(nameof(mainFile));
#if DEBUG
Console.WriteLine(";" + mainFile + ";" + this.mainFile);
#endif
}
public Status status
@ -440,6 +477,7 @@ namespace UpTool2
public override bool Equals(object obj) => obj is App app && Equals(app);
public bool Equals(App other) => ID.Equals(other.ID);
public override int GetHashCode() => 1213502048 + EqualityComparer<Guid>.Default.GetHashCode(ID);
public override string ToString() => "Name: " + name + "\r\nDescription:\r\n" + string.Join("\r\n", description.Split('\n').Select(s => { if (s.EndsWith("\r")) s.Remove(s.Length - 1, 1); return "> " + s; })) + "\r\nVersion: " + version + "\r\nFile: " + file + "\r\nLocal: " + local.ToString() + "\r\nHash: " + hash + "\r\nID: " + ID.ToString() + "\r\nColor: " + color.ToKnownColor().ToString() + "\r\nRunnable: " + runnable + "\r\nMainFile: " + mainFile + "\r\nStatus: " + status.ToString() + "\r\nObject Hash Code: " + GetHashCode();
public static bool operator ==(App left, App right) => left.Equals(right);
public static bool operator !=(App left, App right) => !(left == right);
}