Maybe fix everything
This commit is contained in:
parent
46a9bf099b
commit
fea9f80001
0
.idea/.gitignore
vendored
Normal file
0
.idea/.gitignore
vendored
Normal file
2
.idea/.idea.UpTool2/.idea/.gitignore
vendored
Normal file
2
.idea/.idea.UpTool2/.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# Default ignored files
|
||||||
|
/workspace.xml
|
9
.idea/.idea.UpTool2/.idea/discord.xml
Normal file
9
.idea/.idea.UpTool2/.idea/discord.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DiscordProjectSettings">
|
||||||
|
<option name="show" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectNotificationSettings">
|
||||||
|
<option name="askShowProject" value="false" />
|
||||||
|
</component>
|
||||||
|
</project>
|
4
.idea/.idea.UpTool2/.idea/encodings.xml
Normal file
4
.idea/.idea.UpTool2/.idea/encodings.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
8
.idea/.idea.UpTool2/.idea/indexLayout.xml
Normal file
8
.idea/.idea.UpTool2/.idea/indexLayout.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ContentModelUserStore">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/.idea.UpTool2/.idea/projectSettingsUpdater.xml
Normal file
6
.idea/.idea.UpTool2/.idea/projectSettingsUpdater.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RiderProjectSettingsUpdater">
|
||||||
|
<option name="vcsConfiguration" value="1" />
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/.idea.UpTool2/.idea/vcs.xml
Normal file
6
.idea/.idea.UpTool2/.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -1,77 +1,73 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using UpTool2.Tool;
|
using UpTool2.Tool;
|
||||||
using static System.Environment;
|
using static System.Environment;
|
||||||
using Version = System.Version;
|
|
||||||
|
|
||||||
namespace UpTool2.Data
|
namespace UpTool2.DataStructures
|
||||||
{
|
{
|
||||||
public struct App : IEquatable<App>
|
public struct App : IEquatable<App>
|
||||||
{
|
{
|
||||||
public string name;
|
public readonly string Name;
|
||||||
public string description;
|
public readonly string Description;
|
||||||
public Version version;
|
public readonly Version Version;
|
||||||
public string file;
|
public readonly string File;
|
||||||
public bool local;
|
public readonly bool Local;
|
||||||
public string hash;
|
public readonly string Hash;
|
||||||
public Guid ID;
|
private Guid _id;
|
||||||
public Color color;
|
public Color Color;
|
||||||
public Image icon;
|
public readonly Image Icon;
|
||||||
public bool runnable;
|
public readonly bool Runnable;
|
||||||
public string mainFile;
|
public readonly string MainFile;
|
||||||
|
|
||||||
public App(string name, string description, Version version, string file, bool local, string hash, Guid iD, Color color, Image icon, bool runnable, string mainFile)
|
public App(string name, string description, Version version, string file, bool local, string hash, Guid iD,
|
||||||
|
Color color, Image icon, bool runnable, string mainFile)
|
||||||
{
|
{
|
||||||
this.name = name ?? throw new ArgumentNullException(nameof(name));
|
Name = name ?? throw new ArgumentNullException(nameof(name));
|
||||||
this.description = description ?? throw new ArgumentNullException(nameof(description));
|
Description = description ?? throw new ArgumentNullException(nameof(description));
|
||||||
this.version = version;
|
Version = version;
|
||||||
this.file = file ?? throw new ArgumentNullException(nameof(file));
|
File = file ?? throw new ArgumentNullException(nameof(file));
|
||||||
this.local = local;
|
Local = local;
|
||||||
this.hash = hash ?? throw new ArgumentNullException(nameof(hash));
|
Hash = hash ?? throw new ArgumentNullException(nameof(hash));
|
||||||
ID = iD;
|
_id = iD;
|
||||||
this.color = color;
|
Color = color;
|
||||||
this.icon = icon ?? throw new ArgumentNullException(nameof(icon));
|
Icon = icon ?? throw new ArgumentNullException(nameof(icon));
|
||||||
this.runnable = runnable;
|
Runnable = runnable;
|
||||||
this.mainFile = mainFile ?? throw new ArgumentNullException(nameof(mainFile));
|
MainFile = mainFile ?? throw new ArgumentNullException(nameof(mainFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Status status
|
public Status status
|
||||||
{
|
{
|
||||||
get {
|
get
|
||||||
string xml = PathTool.getInfoPath(ID);
|
{
|
||||||
if (File.Exists(xml))
|
if (!System.IO.File.Exists(infoPath))
|
||||||
{
|
|
||||||
if (Version.TryParse(XDocument.Load(xml).Element("app").Element("Version").Value, out Version ver) && ver >= version)
|
|
||||||
return local ? (Status.Installed | Status.Local) : Status.Installed;
|
|
||||||
else
|
|
||||||
return Status.Installed | Status.Updatable;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return Status.Not_Installed;
|
return Status.Not_Installed;
|
||||||
|
if (Version.TryParse(XDocument.Load(infoPath).Element("app").Element("Version").Value,
|
||||||
|
out Version ver) && ver >= Version)
|
||||||
|
return Local ? Status.Installed | Status.Local : Status.Installed;
|
||||||
|
return Status.Installed | Status.Updatable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj) => obj is App app && Equals(app);
|
public override bool Equals(object obj) => obj is App app && Equals(app);
|
||||||
|
|
||||||
public bool Equals(App other) => ID.Equals(other.ID);
|
public bool Equals(App other) => _id.Equals(other._id);
|
||||||
|
|
||||||
public override int GetHashCode() => 1213502048 + EqualityComparer<Guid>.Default.GetHashCode(ID);
|
public override int GetHashCode() => 1213502048 + EqualityComparer<Guid>.Default.GetHashCode(_id);
|
||||||
|
|
||||||
public override string ToString() => $@"Name: {name}
|
public override string ToString() => $@"Name: {Name}
|
||||||
Description:
|
Description:
|
||||||
{string.Join(NewLine, description.Split('\n').Select(s => { if (s.EndsWith("\r")) s.Remove(s.Length - 1, 1); return "> " + s; }))}
|
{string.Join(NewLine, Description.Split('\n').Select(s => { if (s.EndsWith("\r")) s.Remove(s.Length - 1, 1); return "> " + s; }))}
|
||||||
Version: {version}
|
Version: {Version}
|
||||||
File: {file}
|
File: {File}
|
||||||
Local: {local.ToString()}
|
Local: {Local.ToString()}
|
||||||
Hash: {hash}
|
Hash: {Hash}
|
||||||
ID: {ID.ToString()}
|
ID: {_id.ToString()}
|
||||||
Color: {color.ToKnownColor().ToString()}
|
Color: {Color.ToKnownColor().ToString()}
|
||||||
Runnable: {runnable}
|
Runnable: {Runnable}
|
||||||
MainFile: {mainFile}
|
MainFile: {MainFile}
|
||||||
Status: {status.ToString()}
|
Status: {status.ToString()}
|
||||||
Object Hash Code: {GetHashCode()}";
|
Object Hash Code: {GetHashCode()}";
|
||||||
|
|
||||||
|
@ -79,8 +75,8 @@ Object Hash Code: {GetHashCode()}";
|
||||||
|
|
||||||
public static bool operator !=(App left, App right) => !(left == right);
|
public static bool operator !=(App left, App right) => !(left == right);
|
||||||
|
|
||||||
public string appPath => PathTool.getAppPath(this.ID);
|
public string appPath => PathTool.GetAppPath(_id);
|
||||||
public string dataPath => PathTool.getDataPath(this.ID);
|
public string dataPath => PathTool.GetDataPath(_id);
|
||||||
public string infoPath => PathTool.getInfoPath(this.ID);
|
public string infoPath => PathTool.GetInfoPath(_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
namespace UpTool2.Data
|
using System;
|
||||||
|
|
||||||
|
namespace UpTool2.DataStructures
|
||||||
{
|
{
|
||||||
|
[Flags]
|
||||||
public enum Status
|
public enum Status
|
||||||
{
|
{
|
||||||
Not_Installed = 1,
|
Not_Installed = 1,
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UpTool2.Data;
|
using UpTool2.DataStructures;
|
||||||
|
|
||||||
namespace UpTool2
|
namespace UpTool2
|
||||||
{
|
{
|
||||||
static partial class GlobalVariables
|
internal static class GlobalVariables
|
||||||
{
|
{
|
||||||
public static Dictionary<Guid, App> apps = new Dictionary<Guid, App>();
|
public static readonly Dictionary<Guid, App> Apps = new Dictionary<Guid, App>();
|
||||||
public static bool relE = true;
|
public static bool RelE = true;
|
||||||
public static Action reloadElements;
|
public static Action ReloadElements;
|
||||||
public static Version minimumVer => Version.Parse("0.0.0.0");
|
public static Version minimumVer => Version.Parse("0.0.0.0");
|
||||||
}
|
}
|
||||||
}
|
}
|
103
UpTool2/MainForm.Designer.cs
generated
103
UpTool2/MainForm.Designer.cs
generated
|
@ -47,7 +47,7 @@
|
||||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||||
this.searchPackageDialog = new System.Windows.Forms.OpenFileDialog();
|
this.searchPackageDialog = new System.Windows.Forms.OpenFileDialog();
|
||||||
this.infoPanel.SuspendLayout();
|
this.infoPanel.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
|
((System.ComponentModel.ISupportInitialize) (this.splitContainer)).BeginInit();
|
||||||
this.splitContainer.Panel1.SuspendLayout();
|
this.splitContainer.Panel1.SuspendLayout();
|
||||||
this.splitContainer.Panel2.SuspendLayout();
|
this.splitContainer.Panel2.SuspendLayout();
|
||||||
this.splitContainer.SuspendLayout();
|
this.splitContainer.SuspendLayout();
|
||||||
|
@ -59,9 +59,9 @@
|
||||||
this.sidebarPanel.AutoScroll = true;
|
this.sidebarPanel.AutoScroll = true;
|
||||||
this.sidebarPanel.BackColor = System.Drawing.SystemColors.ControlLight;
|
this.sidebarPanel.BackColor = System.Drawing.SystemColors.ControlLight;
|
||||||
this.sidebarPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.sidebarPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.sidebarPanel.Location = new System.Drawing.Point(0, 59);
|
this.sidebarPanel.Location = new System.Drawing.Point(0, 68);
|
||||||
this.sidebarPanel.Name = "sidebarPanel";
|
this.sidebarPanel.Name = "sidebarPanel";
|
||||||
this.sidebarPanel.Size = new System.Drawing.Size(268, 391);
|
this.sidebarPanel.Size = new System.Drawing.Size(312, 451);
|
||||||
this.sidebarPanel.TabIndex = 0;
|
this.sidebarPanel.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// infoPanel
|
// infoPanel
|
||||||
|
@ -75,15 +75,17 @@
|
||||||
this.infoPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.infoPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.infoPanel.Location = new System.Drawing.Point(0, 0);
|
this.infoPanel.Location = new System.Drawing.Point(0, 0);
|
||||||
this.infoPanel.Name = "infoPanel";
|
this.infoPanel.Name = "infoPanel";
|
||||||
this.infoPanel.Size = new System.Drawing.Size(528, 450);
|
this.infoPanel.Size = new System.Drawing.Size(616, 519);
|
||||||
this.infoPanel.TabIndex = 1;
|
this.infoPanel.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// action_run
|
// action_run
|
||||||
//
|
//
|
||||||
this.action_run.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.action_run.Anchor =
|
||||||
this.action_run.Location = new System.Drawing.Point(421, 5);
|
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
||||||
|
System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.action_run.Location = new System.Drawing.Point(491, 6);
|
||||||
this.action_run.Name = "action_run";
|
this.action_run.Name = "action_run";
|
||||||
this.action_run.Size = new System.Drawing.Size(23, 23);
|
this.action_run.Size = new System.Drawing.Size(27, 27);
|
||||||
this.action_run.TabIndex = 5;
|
this.action_run.TabIndex = 5;
|
||||||
this.action_run.Text = "↗";
|
this.action_run.Text = "↗";
|
||||||
this.action_run.UseVisualStyleBackColor = true;
|
this.action_run.UseVisualStyleBackColor = true;
|
||||||
|
@ -91,11 +93,13 @@
|
||||||
//
|
//
|
||||||
// action_remove
|
// action_remove
|
||||||
//
|
//
|
||||||
this.action_remove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.action_remove.Anchor =
|
||||||
|
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
||||||
|
System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.action_remove.Enabled = false;
|
this.action_remove.Enabled = false;
|
||||||
this.action_remove.Location = new System.Drawing.Point(448, 5);
|
this.action_remove.Location = new System.Drawing.Point(523, 6);
|
||||||
this.action_remove.Name = "action_remove";
|
this.action_remove.Name = "action_remove";
|
||||||
this.action_remove.Size = new System.Drawing.Size(23, 23);
|
this.action_remove.Size = new System.Drawing.Size(27, 27);
|
||||||
this.action_remove.TabIndex = 4;
|
this.action_remove.TabIndex = 4;
|
||||||
this.action_remove.Text = "🗑";
|
this.action_remove.Text = "🗑";
|
||||||
this.action_remove.UseVisualStyleBackColor = true;
|
this.action_remove.UseVisualStyleBackColor = true;
|
||||||
|
@ -103,11 +107,13 @@
|
||||||
//
|
//
|
||||||
// action_update
|
// action_update
|
||||||
//
|
//
|
||||||
this.action_update.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.action_update.Anchor =
|
||||||
|
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
||||||
|
System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.action_update.Enabled = false;
|
this.action_update.Enabled = false;
|
||||||
this.action_update.Location = new System.Drawing.Point(475, 5);
|
this.action_update.Location = new System.Drawing.Point(554, 6);
|
||||||
this.action_update.Name = "action_update";
|
this.action_update.Name = "action_update";
|
||||||
this.action_update.Size = new System.Drawing.Size(23, 23);
|
this.action_update.Size = new System.Drawing.Size(27, 27);
|
||||||
this.action_update.TabIndex = 3;
|
this.action_update.TabIndex = 3;
|
||||||
this.action_update.Text = "⭱";
|
this.action_update.Text = "⭱";
|
||||||
this.action_update.UseVisualStyleBackColor = true;
|
this.action_update.UseVisualStyleBackColor = true;
|
||||||
|
@ -115,11 +121,13 @@
|
||||||
//
|
//
|
||||||
// action_install
|
// action_install
|
||||||
//
|
//
|
||||||
this.action_install.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.action_install.Anchor =
|
||||||
|
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
||||||
|
System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.action_install.Enabled = false;
|
this.action_install.Enabled = false;
|
||||||
this.action_install.Location = new System.Drawing.Point(502, 5);
|
this.action_install.Location = new System.Drawing.Point(586, 6);
|
||||||
this.action_install.Name = "action_install";
|
this.action_install.Name = "action_install";
|
||||||
this.action_install.Size = new System.Drawing.Size(23, 23);
|
this.action_install.Size = new System.Drawing.Size(27, 27);
|
||||||
this.action_install.TabIndex = 2;
|
this.action_install.TabIndex = 2;
|
||||||
this.action_install.Text = "⭳";
|
this.action_install.Text = "⭳";
|
||||||
this.action_install.UseVisualStyleBackColor = true;
|
this.action_install.UseVisualStyleBackColor = true;
|
||||||
|
@ -127,15 +135,16 @@
|
||||||
//
|
//
|
||||||
// infoPanel_Description
|
// infoPanel_Description
|
||||||
//
|
//
|
||||||
this.infoPanel_Description.Location = new System.Drawing.Point(3, 44);
|
this.infoPanel_Description.Location = new System.Drawing.Point(3, 51);
|
||||||
this.infoPanel_Description.Name = "infoPanel_Description";
|
this.infoPanel_Description.Name = "infoPanel_Description";
|
||||||
this.infoPanel_Description.Size = new System.Drawing.Size(524, 397);
|
this.infoPanel_Description.Size = new System.Drawing.Size(611, 458);
|
||||||
this.infoPanel_Description.TabIndex = 1;
|
this.infoPanel_Description.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// infoPanel_Title
|
// infoPanel_Title
|
||||||
//
|
//
|
||||||
this.infoPanel_Title.AutoSize = true;
|
this.infoPanel_Title.AutoSize = true;
|
||||||
this.infoPanel_Title.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.infoPanel_Title.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F,
|
||||||
|
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (0)));
|
||||||
this.infoPanel_Title.Location = new System.Drawing.Point(2, 1);
|
this.infoPanel_Title.Location = new System.Drawing.Point(2, 1);
|
||||||
this.infoPanel_Title.Name = "infoPanel_Title";
|
this.infoPanel_Title.Name = "infoPanel_Title";
|
||||||
this.infoPanel_Title.Size = new System.Drawing.Size(0, 31);
|
this.infoPanel_Title.Size = new System.Drawing.Size(0, 31);
|
||||||
|
@ -157,8 +166,9 @@
|
||||||
//
|
//
|
||||||
this.splitContainer.Panel2.Controls.Add(this.infoPanel);
|
this.splitContainer.Panel2.Controls.Add(this.infoPanel);
|
||||||
this.splitContainer.Panel2MinSize = 160;
|
this.splitContainer.Panel2MinSize = 160;
|
||||||
this.splitContainer.Size = new System.Drawing.Size(800, 450);
|
this.splitContainer.Size = new System.Drawing.Size(933, 519);
|
||||||
this.splitContainer.SplitterDistance = 268;
|
this.splitContainer.SplitterDistance = 312;
|
||||||
|
this.splitContainer.SplitterWidth = 5;
|
||||||
this.splitContainer.TabIndex = 0;
|
this.splitContainer.TabIndex = 0;
|
||||||
this.splitContainer.TabStop = false;
|
this.splitContainer.TabStop = false;
|
||||||
//
|
//
|
||||||
|
@ -172,15 +182,17 @@
|
||||||
this.optionsPanel.Dock = System.Windows.Forms.DockStyle.Top;
|
this.optionsPanel.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
this.optionsPanel.Location = new System.Drawing.Point(0, 0);
|
this.optionsPanel.Location = new System.Drawing.Point(0, 0);
|
||||||
this.optionsPanel.Name = "optionsPanel";
|
this.optionsPanel.Name = "optionsPanel";
|
||||||
this.optionsPanel.Size = new System.Drawing.Size(268, 59);
|
this.optionsPanel.Size = new System.Drawing.Size(312, 68);
|
||||||
this.optionsPanel.TabIndex = 0;
|
this.optionsPanel.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// controls_upload
|
// controls_upload
|
||||||
//
|
//
|
||||||
this.controls_upload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.controls_upload.Anchor =
|
||||||
this.controls_upload.Location = new System.Drawing.Point(242, 5);
|
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
||||||
|
System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.controls_upload.Location = new System.Drawing.Point(282, 6);
|
||||||
this.controls_upload.Name = "controls_upload";
|
this.controls_upload.Name = "controls_upload";
|
||||||
this.controls_upload.Size = new System.Drawing.Size(23, 23);
|
this.controls_upload.Size = new System.Drawing.Size(27, 27);
|
||||||
this.controls_upload.TabIndex = 4;
|
this.controls_upload.TabIndex = 4;
|
||||||
this.controls_upload.Text = "↑";
|
this.controls_upload.Text = "↑";
|
||||||
this.controls_upload.UseVisualStyleBackColor = true;
|
this.controls_upload.UseVisualStyleBackColor = true;
|
||||||
|
@ -188,31 +200,35 @@
|
||||||
//
|
//
|
||||||
// filterBox
|
// filterBox
|
||||||
//
|
//
|
||||||
this.filterBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
this.filterBox.Anchor =
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top |
|
||||||
|
System.Windows.Forms.AnchorStyles.Left) |
|
||||||
|
System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.filterBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.filterBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.filterBox.FormattingEnabled = true;
|
this.filterBox.FormattingEnabled = true;
|
||||||
this.filterBox.Location = new System.Drawing.Point(58, 6);
|
this.filterBox.Location = new System.Drawing.Point(68, 7);
|
||||||
this.filterBox.Name = "filterBox";
|
this.filterBox.Name = "filterBox";
|
||||||
this.filterBox.Size = new System.Drawing.Size(178, 21);
|
this.filterBox.Size = new System.Drawing.Size(207, 23);
|
||||||
this.filterBox.TabIndex = 3;
|
this.filterBox.TabIndex = 3;
|
||||||
this.filterBox.SelectedIndexChanged += new System.EventHandler(this.updateSidebarV);
|
this.filterBox.SelectedIndexChanged += new System.EventHandler(this.UpdateSidebarV);
|
||||||
//
|
//
|
||||||
// searchBox
|
// searchBox
|
||||||
//
|
//
|
||||||
this.searchBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
this.searchBox.Anchor =
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Bottom |
|
||||||
this.searchBox.Location = new System.Drawing.Point(3, 33);
|
System.Windows.Forms.AnchorStyles.Left) |
|
||||||
|
System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.searchBox.Location = new System.Drawing.Point(3, 38);
|
||||||
this.searchBox.Name = "searchBox";
|
this.searchBox.Name = "searchBox";
|
||||||
this.searchBox.Size = new System.Drawing.Size(262, 20);
|
this.searchBox.Size = new System.Drawing.Size(305, 23);
|
||||||
this.searchBox.TabIndex = 2;
|
this.searchBox.TabIndex = 2;
|
||||||
this.searchBox.TextChanged += new System.EventHandler(this.updateSidebarV);
|
this.searchBox.TextChanged += new System.EventHandler(this.UpdateSidebarV);
|
||||||
//
|
//
|
||||||
// controls_settings
|
// controls_settings
|
||||||
//
|
//
|
||||||
this.controls_settings.Location = new System.Drawing.Point(3, 5);
|
this.controls_settings.Location = new System.Drawing.Point(3, 6);
|
||||||
this.controls_settings.Name = "controls_settings";
|
this.controls_settings.Name = "controls_settings";
|
||||||
this.controls_settings.Size = new System.Drawing.Size(23, 23);
|
this.controls_settings.Size = new System.Drawing.Size(27, 27);
|
||||||
this.controls_settings.TabIndex = 1;
|
this.controls_settings.TabIndex = 1;
|
||||||
this.controls_settings.Text = "⚙";
|
this.controls_settings.Text = "⚙";
|
||||||
this.controls_settings.UseVisualStyleBackColor = true;
|
this.controls_settings.UseVisualStyleBackColor = true;
|
||||||
|
@ -220,9 +236,9 @@
|
||||||
//
|
//
|
||||||
// controls_reload
|
// controls_reload
|
||||||
//
|
//
|
||||||
this.controls_reload.Location = new System.Drawing.Point(29, 5);
|
this.controls_reload.Location = new System.Drawing.Point(34, 6);
|
||||||
this.controls_reload.Name = "controls_reload";
|
this.controls_reload.Name = "controls_reload";
|
||||||
this.controls_reload.Size = new System.Drawing.Size(23, 23);
|
this.controls_reload.Size = new System.Drawing.Size(27, 27);
|
||||||
this.controls_reload.TabIndex = 0;
|
this.controls_reload.TabIndex = 0;
|
||||||
this.controls_reload.Text = "↻";
|
this.controls_reload.Text = "↻";
|
||||||
this.controls_reload.UseVisualStyleBackColor = true;
|
this.controls_reload.UseVisualStyleBackColor = true;
|
||||||
|
@ -241,12 +257,12 @@
|
||||||
//
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(933, 519);
|
||||||
this.Controls.Add(this.splitContainer);
|
this.Controls.Add(this.splitContainer);
|
||||||
this.HelpButton = true;
|
this.HelpButton = true;
|
||||||
this.MinimumSize = new System.Drawing.Size(543, 238);
|
this.MinimumSize = new System.Drawing.Size(631, 269);
|
||||||
this.Name = "MainForm";
|
this.Name = "MainForm";
|
||||||
this.ShowIcon = false;
|
this.ShowIcon = false;
|
||||||
this.Text = "UpTool 2";
|
this.Text = "UpTool 2";
|
||||||
|
@ -256,12 +272,11 @@
|
||||||
this.infoPanel.PerformLayout();
|
this.infoPanel.PerformLayout();
|
||||||
this.splitContainer.Panel1.ResumeLayout(false);
|
this.splitContainer.Panel1.ResumeLayout(false);
|
||||||
this.splitContainer.Panel2.ResumeLayout(false);
|
this.splitContainer.Panel2.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
|
((System.ComponentModel.ISupportInitialize) (this.splitContainer)).EndInit();
|
||||||
this.splitContainer.ResumeLayout(false);
|
this.splitContainer.ResumeLayout(false);
|
||||||
this.optionsPanel.ResumeLayout(false);
|
this.optionsPanel.ResumeLayout(false);
|
||||||
this.optionsPanel.PerformLayout();
|
this.optionsPanel.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -1,34 +1,52 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using UpTool2.Properties;
|
|
||||||
using System.IO;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using Microsoft.VisualBasic;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Microsoft.VisualBasic;
|
||||||
|
using UpTool2.DataStructures;
|
||||||
|
using UpTool2.Properties;
|
||||||
using UpTool2.Tool;
|
using UpTool2.Tool;
|
||||||
using UpTool2.Data;
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace UpTool2
|
namespace UpTool2
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
{
|
{
|
||||||
|
public MainForm()
|
||||||
|
{
|
||||||
|
GlobalVariables.ReloadElements = ReloadElements;
|
||||||
|
InitializeComponent();
|
||||||
|
filterBox.DataSource = Enum.GetValues(typeof(Status));
|
||||||
|
if (Program.Online)
|
||||||
|
{
|
||||||
|
RepoManagement.FetchRepos();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Starting in offline mode!");
|
||||||
|
controls_reload.Enabled = false;
|
||||||
|
filterBox.Enabled = false;
|
||||||
|
filterBox.SelectedIndex = 2;
|
||||||
|
}
|
||||||
|
ReloadElements();
|
||||||
|
if (!Directory.Exists(PathTool.appsPath))
|
||||||
|
Directory.CreateDirectory(PathTool.appsPath);
|
||||||
|
}
|
||||||
|
|
||||||
private void Action_install_Click(object sender, EventArgs e)
|
private void Action_install_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
AppInstall.Install((App)action_install.Tag);
|
AppInstall.Install((App) action_install.Tag);
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
|
@ -44,21 +62,25 @@ namespace UpTool2
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string app = ((App)action_remove.Tag).appPath;
|
string app = ((App) action_remove.Tag).appPath;
|
||||||
string tmp = PathTool.tempPath;
|
string tmp = PathTool.tempPath;
|
||||||
if (Directory.Exists(tmp))
|
if (Directory.Exists(tmp))
|
||||||
Directory.Delete(tmp, true);
|
Directory.Delete(tmp, true);
|
||||||
Directory.CreateDirectory(tmp);
|
Directory.CreateDirectory(tmp);
|
||||||
ZipFile.ExtractToDirectory(Path.Combine(app, "package.zip"), tmp);
|
ZipFile.ExtractToDirectory(Path.Combine(app, "package.zip"), tmp);
|
||||||
Process.Start(new ProcessStartInfo { FileName = "cmd.exe", Arguments = $"/C \"{Path.Combine(tmp, "Remove.bat")}\"", WorkingDirectory = Path.Combine(app, "app") }).WaitForExit();
|
Process.Start(new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "cmd.exe", Arguments = $"/C \"{Path.Combine(tmp, "Remove.bat")}\"",
|
||||||
|
WorkingDirectory = Path.Combine(app, "app")
|
||||||
|
}).WaitForExit();
|
||||||
Directory.Delete(tmp, true);
|
Directory.Delete(tmp, true);
|
||||||
Directory.Delete(app, true);
|
Directory.Delete(app, true);
|
||||||
if (GlobalVariables.relE)
|
if (GlobalVariables.RelE)
|
||||||
reloadElements();
|
ReloadElements();
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
if (!GlobalVariables.relE)
|
if (!GlobalVariables.RelE)
|
||||||
throw;
|
throw;
|
||||||
MessageBox.Show(e1.ToString(), "Removal failed");
|
MessageBox.Show(e1.ToString(), "Removal failed");
|
||||||
}
|
}
|
||||||
|
@ -70,14 +92,14 @@ namespace UpTool2
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
if (searchPackageDialog.ShowDialog() == DialogResult.OK)
|
if (searchPackageDialog.ShowDialog() != DialogResult.OK)
|
||||||
{
|
return;
|
||||||
Guid ID = Guid.NewGuid();
|
Guid id = Guid.NewGuid();
|
||||||
while (GlobalVariables.apps.ContainsKey(ID) || Directory.Exists(PathTool.getAppPath(ID)))
|
while (GlobalVariables.Apps.ContainsKey(id) || Directory.Exists(PathTool.GetAppPath(id)))
|
||||||
ID = Guid.NewGuid();
|
id = Guid.NewGuid();
|
||||||
App appI = new App(Interaction.InputBox("Name:"), "Locally installed package, removal only", GlobalVariables.minimumVer, "", true, "", ID, Color.Red, Resources.C_64.ToBitmap(), false, "");
|
App appI = new App(Interaction.InputBox("Name:"), "Locally installed package, removal only",
|
||||||
AppInstall.installZip(searchPackageDialog.FileName, appI);
|
GlobalVariables.minimumVer, "", true, "", id, Color.Red, Resources.C_64.ToBitmap(), false, "");
|
||||||
}
|
AppInstall.InstallZip(searchPackageDialog.FileName, appI);
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
|
@ -89,19 +111,16 @@ namespace UpTool2
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reloadElements()
|
private void ReloadElements()
|
||||||
{
|
{
|
||||||
//remove
|
//remove
|
||||||
toolTip.RemoveAll();
|
toolTip.RemoveAll();
|
||||||
clearSelection();
|
ClearSelection();
|
||||||
infoPanel_Title.Invalidate();
|
infoPanel_Title.Invalidate();
|
||||||
infoPanel_Description.Invalidate();
|
infoPanel_Description.Invalidate();
|
||||||
int F = sidebarPanel.Controls.Count;
|
int F = sidebarPanel.Controls.Count;
|
||||||
for (int i = 0; i < F; i++)
|
for (int i = 0; i < F; i++) sidebarPanel.Controls[0].Dispose();
|
||||||
{
|
GlobalVariables.Apps.Clear();
|
||||||
sidebarPanel.Controls[0].Dispose();
|
|
||||||
}
|
|
||||||
GlobalVariables.apps.Clear();
|
|
||||||
//add
|
//add
|
||||||
toolTip.SetToolTip(controls_settings, "Settings");
|
toolTip.SetToolTip(controls_settings, "Settings");
|
||||||
toolTip.SetToolTip(controls_reload, "Refresh repositories");
|
toolTip.SetToolTip(controls_reload, "Refresh repositories");
|
||||||
|
@ -111,60 +130,73 @@ namespace UpTool2
|
||||||
toolTip.SetToolTip(action_remove, "Remove");
|
toolTip.SetToolTip(action_remove, "Remove");
|
||||||
toolTip.SetToolTip(action_update, "Update");
|
toolTip.SetToolTip(action_update, "Update");
|
||||||
toolTip.SetToolTip(action_run, "Run");
|
toolTip.SetToolTip(action_run, "Run");
|
||||||
RepoManagement.getReposFromDisk();
|
RepoManagement.GetReposFromDisk();
|
||||||
int availableUpdates = 0;
|
int availableUpdates = 0;
|
||||||
foreach (App app in GlobalVariables.apps.Values)
|
foreach (App app in GlobalVariables.Apps.Values)
|
||||||
{
|
{
|
||||||
Panel sidebarIcon = new Panel();
|
Panel sidebarIcon = new Panel();
|
||||||
sidebarIcon.Tag = app;
|
sidebarIcon.Tag = app;
|
||||||
sidebarIcon.BackColor = app.color;
|
sidebarIcon.BackColor = app.Color;
|
||||||
sidebarIcon.Size = new Size(70, 70);
|
sidebarIcon.Size = new Size(70, 70);
|
||||||
sidebarIcon.BackgroundImage = app.icon;
|
sidebarIcon.BackgroundImage = app.Icon;
|
||||||
sidebarIcon.BackgroundImageLayout = ImageLayout.Stretch;
|
sidebarIcon.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
bool updatable = (!app.local) && ((app.status & Status.Updatable) == Status.Updatable);
|
bool updatable = !app.Local && (app.status & Status.Updatable) == Status.Updatable;
|
||||||
sidebarIcon.Click += (object sender, EventArgs e) =>
|
sidebarIcon.Click += (sender, e) =>
|
||||||
{
|
{
|
||||||
infoPanel_Title.Text = app.name;
|
infoPanel_Title.Text = app.Name;
|
||||||
infoPanel_Title.ForeColor = app.local ? Color.Red : Color.Black;
|
infoPanel_Title.ForeColor = app.Local ? Color.Red : Color.Black;
|
||||||
infoPanel_Description.Text = app.description;
|
infoPanel_Description.Text = app.Description;
|
||||||
action_install.Tag = app;
|
action_install.Tag = app;
|
||||||
action_install.Enabled = !(app.local || Directory.Exists(app.appPath));
|
action_install.Enabled = !(app.Local || Directory.Exists(app.appPath));
|
||||||
action_remove.Tag = app;
|
action_remove.Tag = app;
|
||||||
action_remove.Enabled = Directory.Exists(app.appPath);
|
action_remove.Enabled = Directory.Exists(app.appPath);
|
||||||
action_update.Tag = app;
|
action_update.Tag = app;
|
||||||
action_update.Enabled = updatable;
|
action_update.Enabled = updatable;
|
||||||
action_run.Tag = app;
|
action_run.Tag = app;
|
||||||
action_run.Enabled = (!app.local) && app.runnable && Directory.Exists(app.appPath);
|
action_run.Enabled = !app.Local && app.Runnable && Directory.Exists(app.appPath);
|
||||||
};
|
};
|
||||||
if (updatable)
|
if (updatable)
|
||||||
availableUpdates++;
|
availableUpdates++;
|
||||||
toolTip.SetToolTip(sidebarIcon, app.name);
|
toolTip.SetToolTip(sidebarIcon, app.Name);
|
||||||
sidebarPanel.Controls.Add(sidebarIcon);
|
sidebarPanel.Controls.Add(sidebarIcon);
|
||||||
}
|
}
|
||||||
updateSidebarV(null, null);
|
UpdateSidebarV(null, null);
|
||||||
Text = $"UpTool2 {((availableUpdates == 0) ? "(All up-to-date)" : $"({availableUpdates.ToString()} Updates)")}";
|
Text =
|
||||||
|
$"UpTool2 {(availableUpdates == 0 ? "(All up-to-date)" : $"({availableUpdates.ToString()} Updates)")}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Action_run_Click(object sender, EventArgs e)
|
private void Action_run_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(new string('-', 10));
|
Console.WriteLine(new string('-', 10));
|
||||||
Console.WriteLine(((App)action_run.Tag).dataPath);
|
Console.WriteLine(((App) action_run.Tag).dataPath);
|
||||||
Console.WriteLine("\\");
|
Console.WriteLine("\\");
|
||||||
Console.WriteLine(((App)action_run.Tag).mainFile);
|
Console.WriteLine(((App) action_run.Tag).MainFile);
|
||||||
Console.WriteLine(((App)action_run.Tag).dataPath);
|
Console.WriteLine(((App) action_run.Tag).dataPath);
|
||||||
_ = Process.Start(
|
string path = Path.Combine(((App) action_run.Tag).dataPath, ((App) action_run.Tag).MainFile);
|
||||||
new ProcessStartInfo
|
try
|
||||||
{
|
{
|
||||||
FileName = Path.Combine(((App)action_run.Tag).dataPath, ((App)action_run.Tag).mainFile),
|
Process.Start(
|
||||||
WorkingDirectory = ((App)action_run.Tag).dataPath
|
new ProcessStartInfo
|
||||||
});
|
{
|
||||||
|
FileName = path,
|
||||||
|
WorkingDirectory = ((App) action_run.Tag).dataPath
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception e1)
|
||||||
|
{
|
||||||
|
MessageBox.Show(e1.ToString()
|
||||||
|
#if DEBUG
|
||||||
|
+ $"{Environment.NewLine}File was: {path}"
|
||||||
|
#endif
|
||||||
|
, "Failed to start!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Action_update_Click(object sender, EventArgs e)
|
private void Action_update_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GlobalVariables.relE = false;
|
GlobalVariables.RelE = false;
|
||||||
Action_remove_Click(sender, e);
|
Action_remove_Click(sender, e);
|
||||||
Action_install_Click(sender, e);
|
Action_install_Click(sender, e);
|
||||||
}
|
}
|
||||||
|
@ -172,19 +204,19 @@ namespace UpTool2
|
||||||
{
|
{
|
||||||
MessageBox.Show(e1.ToString(), "Install failed");
|
MessageBox.Show(e1.ToString(), "Install failed");
|
||||||
}
|
}
|
||||||
reloadElements();
|
ReloadElements();
|
||||||
GlobalVariables.relE = true;
|
GlobalVariables.RelE = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Controls_reload_Click(object sender, EventArgs e)
|
private void Controls_reload_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
RepoManagement.fetchRepos();
|
RepoManagement.FetchRepos();
|
||||||
reloadElements();
|
ReloadElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Controls_settings_Click(object sender, EventArgs e) => new SettingsForms().ShowDialog();
|
private void Controls_settings_Click(object sender, EventArgs e) => new SettingsForms().ShowDialog();
|
||||||
|
|
||||||
private void clearSelection()
|
private void ClearSelection()
|
||||||
{
|
{
|
||||||
action_install.Enabled = false;
|
action_install.Enabled = false;
|
||||||
action_remove.Enabled = false;
|
action_remove.Enabled = false;
|
||||||
|
@ -194,18 +226,21 @@ namespace UpTool2
|
||||||
infoPanel_Description.Text = "";
|
infoPanel_Description.Text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSidebarV(object sender, EventArgs e)
|
private void UpdateSidebarV(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (searchBox.Text == "!DEBUG:PRINT!")
|
if (searchBox.Text == "!DEBUG:PRINT!")
|
||||||
{
|
{
|
||||||
searchBox.Text = "!DEBUG:PRINT";
|
searchBox.Text = "!DEBUG:PRINT";
|
||||||
string _tmp_file = Path.GetTempFileName();
|
string tmpFile = Path.GetTempFileName();
|
||||||
File.WriteAllText(_tmp_file, string.Join("\r\n\r\n", GlobalVariables.apps.Values.Select(app => app.ToString()).Concat(new string[] { "Assembly version: " + Assembly.GetExecutingAssembly().GetName().Version.ToString() }).ToArray()));
|
File.WriteAllText(tmpFile,
|
||||||
|
string.Join("\r\n\r\n",
|
||||||
|
GlobalVariables.Apps.Values.Select(app => app.ToString()).Concat(new[]
|
||||||
|
{"Assembly version: " + Assembly.GetExecutingAssembly().GetName().Version}).ToArray()));
|
||||||
new Thread(() =>
|
new Thread(() =>
|
||||||
{
|
{
|
||||||
Process.Start("notepad", _tmp_file).WaitForExit();
|
Process.Start("notepad", tmpFile).WaitForExit();
|
||||||
File.Delete(_tmp_file);
|
File.Delete(tmpFile);
|
||||||
}).Start();
|
}).Start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -214,59 +249,30 @@ namespace UpTool2
|
||||||
Enum.TryParse(filterBox.SelectedValue.ToString(), out Status status);
|
Enum.TryParse(filterBox.SelectedValue.ToString(), out Status status);
|
||||||
for (int i = 0; i < sidebarPanel.Controls.Count; i++)
|
for (int i = 0; i < sidebarPanel.Controls.Count; i++)
|
||||||
{
|
{
|
||||||
Panel sidebarIcon = (Panel)sidebarPanel.Controls[i];
|
Panel sidebarIcon = (Panel) sidebarPanel.Controls[i];
|
||||||
App app = (App)sidebarIcon.Tag;
|
App app = (App) sidebarIcon.Tag;
|
||||||
sidebarIcon.Visible = app.name.Contains(searchBox.Text) && ((int)app.status & (int)(Program.online ? status : Status.Installed)) != 0;
|
sidebarIcon.Visible = app.Name.Contains(searchBox.Text) &&
|
||||||
|
((int) app.status & (int) (Program.Online ? status : Status.Installed)) != 0;
|
||||||
}
|
}
|
||||||
clearSelection();
|
ClearSelection();
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainForm()
|
|
||||||
{
|
|
||||||
GlobalVariables.reloadElements = reloadElements;
|
|
||||||
InitializeComponent();
|
|
||||||
filterBox.DataSource = Enum.GetValues(typeof(Status));
|
|
||||||
if (Program.online)
|
|
||||||
RepoManagement.fetchRepos();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Starting in offline mode!");
|
|
||||||
controls_reload.Enabled = false;
|
|
||||||
filterBox.Enabled = false;
|
|
||||||
filterBox.SelectedIndex = 2;
|
|
||||||
}
|
|
||||||
reloadElements();
|
|
||||||
if (!Directory.Exists(PathTool.appsPath))
|
|
||||||
Directory.CreateDirectory(PathTool.appsPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MainForm_Load(object sender, EventArgs e)
|
private void MainForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Program.splash.Hide();
|
Program.Splash.Hide();
|
||||||
BringToFront();
|
BringToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct _IMAGE_FILE_HEADER
|
|
||||||
{
|
|
||||||
public ushort Machine;
|
|
||||||
public ushort NumberOfSections;
|
|
||||||
public uint TimeDateStamp;
|
|
||||||
public uint PointerToSymbolTable;
|
|
||||||
public uint NumberOfSymbols;
|
|
||||||
public ushort SizeOfOptionalHeader;
|
|
||||||
public ushort Characteristics;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static DateTime GetBuildDateTime(Assembly assembly)
|
private static DateTime GetBuildDateTime(Assembly assembly)
|
||||||
{
|
{
|
||||||
var path = assembly.GetName().CodeBase;
|
string path = assembly.GetName().CodeBase;
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
{
|
{
|
||||||
var buffer = new byte[Math.Max(Marshal.SizeOf(typeof(_IMAGE_FILE_HEADER)), 4)];
|
byte[] buffer = new byte[Math.Max(Marshal.SizeOf(typeof(_IMAGE_FILE_HEADER)), 4)];
|
||||||
using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
|
using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||||
{
|
{
|
||||||
fileStream.Position = 0x3C;
|
fileStream.Position = 0x3C;
|
||||||
fileStream.Read(buffer, 0, 4);
|
fileStream.Read(buffer, 0, 4);
|
||||||
|
@ -274,12 +280,15 @@ namespace UpTool2
|
||||||
fileStream.Read(buffer, 0, 4); // "PE\0\0"
|
fileStream.Read(buffer, 0, 4); // "PE\0\0"
|
||||||
fileStream.Read(buffer, 0, buffer.Length);
|
fileStream.Read(buffer, 0, buffer.Length);
|
||||||
}
|
}
|
||||||
var pinnedBuffer = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
GCHandle pinnedBuffer = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var coffHeader = (_IMAGE_FILE_HEADER)Marshal.PtrToStructure(pinnedBuffer.AddrOfPinnedObject(), typeof(_IMAGE_FILE_HEADER));
|
_IMAGE_FILE_HEADER coffHeader =
|
||||||
|
(_IMAGE_FILE_HEADER) Marshal.PtrToStructure(pinnedBuffer.AddrOfPinnedObject(),
|
||||||
|
typeof(_IMAGE_FILE_HEADER));
|
||||||
|
|
||||||
return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1) + new TimeSpan(coffHeader.TimeDateStamp * TimeSpan.TicksPerSecond));
|
return TimeZone.CurrentTimeZone.ToLocalTime(
|
||||||
|
new DateTime(1970, 1, 1) + new TimeSpan(coffHeader.TimeDateStamp * TimeSpan.TicksPerSecond));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -293,9 +302,20 @@ namespace UpTool2
|
||||||
{
|
{
|
||||||
DateTime buildTime = GetBuildDateTime(Assembly.GetExecutingAssembly());
|
DateTime buildTime = GetBuildDateTime(Assembly.GetExecutingAssembly());
|
||||||
_ = MessageBox.Show($@"UpTool2 by CC24
|
_ = MessageBox.Show($@"UpTool2 by CC24
|
||||||
Version: {Assembly.GetExecutingAssembly().GetName().Version.ToString()}
|
Version: {Assembly.GetExecutingAssembly().GetName().Version}
|
||||||
Build Date: {buildTime.ToString("dd.MM.yyyy")}", "UpTool2");
|
Build Date: {buildTime:dd.MM.yyyy}", "UpTool2");
|
||||||
hlpevent.Handled = true;
|
hlpevent.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private struct _IMAGE_FILE_HEADER
|
||||||
|
{
|
||||||
|
public ushort Machine;
|
||||||
|
public ushort NumberOfSections;
|
||||||
|
public uint TimeDateStamp;
|
||||||
|
public uint PointerToSymbolTable;
|
||||||
|
public uint NumberOfSymbols;
|
||||||
|
public ushort SizeOfOptionalHeader;
|
||||||
|
public ushort Characteristics;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,14 +15,13 @@ using System.Windows.Forms;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using UpTool2.Tool;
|
using UpTool2.Tool;
|
||||||
using Shortcut = UpTool2.Tool.Shortcut;
|
|
||||||
|
|
||||||
namespace UpTool2
|
namespace UpTool2
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
public static Form splash;
|
public static Form Splash;
|
||||||
public static bool online;
|
public static bool Online;
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
private static void Main()
|
private static void Main()
|
||||||
|
@ -30,36 +29,38 @@ namespace UpTool2
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
ShowSplash();
|
ShowSplash();
|
||||||
string appGuid = ((GuidAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value.ToString();
|
string appGuid = ((GuidAttribute) Assembly.GetExecutingAssembly()
|
||||||
|
.GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value;
|
||||||
string mutexId = string.Format("Global\\{{{0}}}", appGuid);
|
string mutexId = string.Format("Global\\{{{0}}}", appGuid);
|
||||||
var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);
|
MutexAccessRule allowEveryoneRule = new MutexAccessRule(
|
||||||
var securitySettings = new MutexSecurity();
|
new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl,
|
||||||
|
AccessControlType.Allow);
|
||||||
|
MutexSecurity securitySettings = new MutexSecurity();
|
||||||
securitySettings.AddAccessRule(allowEveryoneRule);
|
securitySettings.AddAccessRule(allowEveryoneRule);
|
||||||
using (var mutex = new Mutex(false, mutexId, out bool createdNew, securitySettings))
|
using Mutex mutex = new Mutex(false, mutexId, out bool createdNew, securitySettings);
|
||||||
{
|
bool hasHandle = false;
|
||||||
var hasHandle = false;
|
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
hasHandle = mutex.WaitOne(5000, false);
|
hasHandle = mutex.WaitOne(5000, false);
|
||||||
if (hasHandle == false)
|
if (hasHandle == false)
|
||||||
throw new TimeoutException("Timeout waiting for exclusive access");
|
throw new TimeoutException("Timeout waiting for exclusive access");
|
||||||
}
|
}
|
||||||
catch (AbandonedMutexException)
|
catch (AbandonedMutexException)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Console.WriteLine("Mutex abandoned");
|
Console.WriteLine("Mutex abandoned");
|
||||||
#endif
|
#endif
|
||||||
hasHandle = true;
|
hasHandle = true;
|
||||||
}
|
}
|
||||||
if (!Directory.Exists(PathTool.dir))
|
if (!Directory.Exists(PathTool.dir))
|
||||||
Directory.CreateDirectory(PathTool.dir);
|
Directory.CreateDirectory(PathTool.dir);
|
||||||
FixXML();
|
FixXml();
|
||||||
string metaXML = XDocument.Load(PathTool.infoXML).Element("meta").Element("UpdateSource").Value;
|
string metaXml = XDocument.Load(PathTool.InfoXml).Element("meta").Element("UpdateSource").Value;
|
||||||
online = Ping(metaXML);
|
Online = Ping(metaXml);
|
||||||
|
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
if (Application.ExecutablePath != PathTool.GetProgPath("Install", "UpTool2.exe"))
|
if (Application.ExecutablePath != PathTool.GetProgPath("Install", "UpTool2.exe"))
|
||||||
|
@ -80,10 +81,10 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
|
||||||
if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk")))
|
if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk")))
|
||||||
Shortcut.Make(PathTool.GetProgPath("Install", "UpTool2.exe"), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk"));
|
Shortcut.Make(PathTool.GetProgPath("Install", "UpTool2.exe"), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk"));
|
||||||
#endif
|
#endif
|
||||||
if (!Directory.Exists(PathTool.GetProgPath("Apps")))
|
if (!Directory.Exists(PathTool.GetRelative("Apps")))
|
||||||
Directory.CreateDirectory(PathTool.GetProgPath("Apps"));
|
Directory.CreateDirectory(PathTool.GetRelative("Apps"));
|
||||||
if (!online || UpdateCheck(metaXML))
|
if (!Online || UpdateCheck(metaXml))
|
||||||
Application.Run(new MainForm());
|
Application.Run(new MainForm());
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
|
@ -96,12 +97,11 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
|
||||||
mutex.ReleaseMutex();
|
mutex.ReleaseMutex();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ShowSplash()
|
private static void ShowSplash()
|
||||||
{
|
{
|
||||||
splash = new Form
|
Splash = new Form
|
||||||
{
|
{
|
||||||
StartPosition = FormStartPosition.CenterScreen,
|
StartPosition = FormStartPosition.CenterScreen,
|
||||||
FormBorderStyle = FormBorderStyle.None,
|
FormBorderStyle = FormBorderStyle.None,
|
||||||
|
@ -114,8 +114,8 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
|
||||||
ForeColor = Color.Green,
|
ForeColor = Color.Green,
|
||||||
TopMost = true
|
TopMost = true
|
||||||
};
|
};
|
||||||
splash.MaximumSize = splash.Size;
|
Splash.MaximumSize = Splash.Size;
|
||||||
splash.MinimumSize = splash.Size;
|
Splash.MinimumSize = Splash.Size;
|
||||||
Label splashL = new Label
|
Label splashL = new Label
|
||||||
{
|
{
|
||||||
AutoSize = false,
|
AutoSize = false,
|
||||||
|
@ -124,101 +124,111 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
|
||||||
Text = "Loading",
|
Text = "Loading",
|
||||||
Font = new Font(FontFamily.GenericSansSerif, 40)
|
Font = new Font(FontFamily.GenericSansSerif, 40)
|
||||||
};
|
};
|
||||||
splash.Controls.Add(splashL);
|
Splash.Controls.Add(splashL);
|
||||||
splash.Show();
|
Splash.Show();
|
||||||
splash.BringToFront();
|
Splash.BringToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void FixXML(bool throwOnError = false)
|
public static void FixXml(bool throwOnError = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ((!File.Exists(PathTool.infoXML)) || XDocument.Load(PathTool.infoXML).Element("meta") == null)
|
if (!File.Exists(PathTool.InfoXml) || XDocument.Load(PathTool.InfoXml).Element("meta") == null)
|
||||||
new XElement("meta").Save(PathTool.infoXML);
|
new XElement("meta").Save(PathTool.InfoXml);
|
||||||
XDocument x = XDocument.Load(PathTool.infoXML);
|
XDocument x = XDocument.Load(PathTool.InfoXml);
|
||||||
XElement meta = x.Element("meta");
|
XElement meta = x.Element("meta");
|
||||||
if (meta.Element("UpdateSource") == null)
|
if (meta.Element("UpdateSource") == null)
|
||||||
meta.Add(new XElement("UpdateSource"));
|
meta.Add(new XElement("UpdateSource"));
|
||||||
if (new string[] { "", "https://raw.githubusercontent.com/CreepyCrafter24/UpTool2/master/Meta.xml",
|
if (new[]
|
||||||
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Meta.xml" }
|
{
|
||||||
|
"", "https://raw.githubusercontent.com/CreepyCrafter24/UpTool2/master/Meta.xml",
|
||||||
|
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Meta.xml"
|
||||||
|
}
|
||||||
.Contains(meta.Element("UpdateSource").Value))
|
.Contains(meta.Element("UpdateSource").Value))
|
||||||
meta.Element("UpdateSource").Value = "https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Meta.xml";
|
meta.Element("UpdateSource").Value =
|
||||||
|
"https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Meta.xml";
|
||||||
if (meta.Element("Repos") == null)
|
if (meta.Element("Repos") == null)
|
||||||
meta.Add(new XElement("Repos"));
|
meta.Add(new XElement("Repos"));
|
||||||
if (meta.Element("Repos").Elements("Repo").Count() == 0)
|
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://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Repo.xml")));
|
meta.Element("Repos").Add(new XElement("Repo", new XElement("Name", "UpTool2 official Repo"),
|
||||||
|
new XElement("Link",
|
||||||
|
"https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Repo.xml")));
|
||||||
meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link"))
|
meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link"))
|
||||||
.Where(s => new string[] { null, "https://github.com/JFronny/UpTool2/releases/download/Repo/Repo.xml",
|
.Where(s => new[]
|
||||||
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Repo.xml"}.Contains(s.Value))
|
{
|
||||||
.ToList().ForEach(s => s.Value = "https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Repo.xml");
|
null, "https://github.com/JFronny/UpTool2/releases/download/Repo/Repo.xml",
|
||||||
|
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Repo.xml"
|
||||||
|
}.Contains(s.Value))
|
||||||
|
.ToList().ForEach(s =>
|
||||||
|
s.Value =
|
||||||
|
"https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Repo.xml");
|
||||||
if (meta.Element("LocalRepo") == null)
|
if (meta.Element("LocalRepo") == null)
|
||||||
meta.Add(new XElement("LocalRepo"));
|
meta.Add(new XElement("LocalRepo"));
|
||||||
x.Save(PathTool.infoXML);
|
x.Save(PathTool.InfoXml);
|
||||||
}
|
}
|
||||||
catch (XmlException)
|
catch (XmlException)
|
||||||
{
|
{
|
||||||
if (throwOnError)
|
if (throwOnError) throw;
|
||||||
throw;
|
MessageBox.Show("Something went wrong while trying to parse XML. Retrying...");
|
||||||
else
|
File.Delete(PathTool.InfoXml);
|
||||||
{
|
FixXml();
|
||||||
MessageBox.Show("Something went wrong while trying to parse XML. Retrying...");
|
|
||||||
File.Delete(PathTool.infoXML);
|
|
||||||
FixXML();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool UpdateCheck(string metaXML)
|
private static bool UpdateCheck(string metaXml)
|
||||||
{
|
{
|
||||||
XElement meta = XDocument.Load(metaXML).Element("meta");
|
XElement meta = XDocument.Load(metaXml).Element("meta");
|
||||||
if (Assembly.GetExecutingAssembly().GetName().Version < Version.Parse(meta.Element("Version").Value))
|
if (Assembly.GetExecutingAssembly().GetName().Version >= Version.Parse(meta.Element("Version").Value))
|
||||||
{
|
return true;
|
||||||
installUpdate(meta);
|
InstallUpdate(meta);
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void installUpdate(XElement meta)
|
private static void InstallUpdate(XElement meta)
|
||||||
{
|
{
|
||||||
byte[] dl;
|
byte[] dl;
|
||||||
using (DownloadDialog dlg = new DownloadDialog(meta.Element("File").Value))
|
using (DownloadDialog dlg = new DownloadDialog(meta.Element("File").Value))
|
||||||
{
|
{
|
||||||
if (dlg.ShowDialog() != DialogResult.OK)
|
if (dlg.ShowDialog() != DialogResult.OK)
|
||||||
throw new Exception("Failed to update");
|
throw new Exception("Failed to update");
|
||||||
dl = dlg.result;
|
dl = dlg.Result;
|
||||||
}
|
}
|
||||||
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
|
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
|
||||||
{
|
{
|
||||||
string pkghash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
|
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
|
||||||
if (pkghash != meta.Element("Hash").Value.ToUpper())
|
if (pkgHash != meta.Element("Hash").Value.ToUpper())
|
||||||
throw new Exception("The hash is not equal to the one stored in the repo:\r\nPackage: " + pkghash + "\r\nOnline: " + meta.Element("Hash").Value.ToUpper());
|
throw new Exception("The hash is not equal to the one stored in the repo:\r\nPackage: " + pkgHash +
|
||||||
|
"\r\nOnline: " + meta.Element("Hash").Value.ToUpper());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Directory.Exists(PathTool.GetProgPath("Install", "tmp")))
|
if (Directory.Exists(PathTool.GetRelative("Install", "tmp")))
|
||||||
Directory.Delete(PathTool.GetProgPath("Install", "tmp"), true);
|
Directory.Delete(PathTool.GetRelative("Install", "tmp"), true);
|
||||||
Directory.CreateDirectory(PathTool.GetProgPath("Install", "tmp"));
|
Directory.CreateDirectory(PathTool.GetRelative("Install", "tmp"));
|
||||||
using (MemoryStream ms = new MemoryStream(dl))
|
using (MemoryStream ms = new MemoryStream(dl))
|
||||||
using (ZipArchive ar = new ZipArchive(ms))
|
using (ZipArchive ar = new ZipArchive(ms))
|
||||||
{
|
{
|
||||||
ar.Entries.Where(s => !string.IsNullOrEmpty(s.Name)).ToList().ForEach(s =>
|
ar.Entries.Where(s => !string.IsNullOrEmpty(s.Name)).ToList().ForEach(s =>
|
||||||
{
|
{
|
||||||
s.ExtractToFile(PathTool.GetProgPath("Install", "tmp", s.Name), true);
|
s.ExtractToFile(PathTool.GetRelative("Install", "tmp", s.Name), true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
splash.Hide();
|
Splash.Hide();
|
||||||
Process.Start(new ProcessStartInfo { FileName = "cmd.exe", Arguments = @"/C timeout /t 2 & xcopy /s /e /y tmp\* .", CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, WorkingDirectory = PathTool.GetProgPath("Install") });
|
Process.Start(new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "cmd.exe", Arguments = @"/C timeout /t 2 & xcopy /s /e /y tmp\* .", CreateNoWindow = true,
|
||||||
|
WindowStyle = ProcessWindowStyle.Hidden, WorkingDirectory = PathTool.GetRelative("Install")
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Ping(string url)
|
private static bool Ping(string url)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
|
||||||
request.Timeout = 3000;
|
request.Timeout = 3000;
|
||||||
request.AllowAutoRedirect = false;
|
request.AllowAutoRedirect = false;
|
||||||
request.Method = "HEAD";
|
request.Method = "HEAD";
|
||||||
using var response = request.GetResponse();
|
using WebResponse response = request.GetResponse();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
22
UpTool2/SourcesForm.Designer.cs
generated
22
UpTool2/SourcesForm.Designer.cs
generated
|
@ -31,22 +31,21 @@
|
||||||
this.sourceGrid = new System.Windows.Forms.DataGridView();
|
this.sourceGrid = new System.Windows.Forms.DataGridView();
|
||||||
this.sbName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.sbName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.sbLink = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.sbLink = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.sourceGrid)).BeginInit();
|
((System.ComponentModel.ISupportInitialize) (this.sourceGrid)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// sourceGrid
|
// sourceGrid
|
||||||
//
|
//
|
||||||
this.sourceGrid.BackgroundColor = System.Drawing.Color.White;
|
this.sourceGrid.BackgroundColor = System.Drawing.Color.White;
|
||||||
this.sourceGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.sourceGrid.ColumnHeadersHeightSizeMode =
|
||||||
this.sourceGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.sbName,
|
this.sourceGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {this.sbName, this.sbLink});
|
||||||
this.sbLink});
|
|
||||||
this.sourceGrid.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.sourceGrid.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.sourceGrid.GridColor = System.Drawing.Color.White;
|
this.sourceGrid.GridColor = System.Drawing.Color.White;
|
||||||
this.sourceGrid.Location = new System.Drawing.Point(0, 0);
|
this.sourceGrid.Location = new System.Drawing.Point(0, 0);
|
||||||
this.sourceGrid.MultiSelect = false;
|
this.sourceGrid.MultiSelect = false;
|
||||||
this.sourceGrid.Name = "sourceGrid";
|
this.sourceGrid.Name = "sourceGrid";
|
||||||
this.sourceGrid.Size = new System.Drawing.Size(800, 450);
|
this.sourceGrid.Size = new System.Drawing.Size(933, 519);
|
||||||
this.sourceGrid.TabIndex = 0;
|
this.sourceGrid.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// sbName
|
// sbName
|
||||||
|
@ -54,20 +53,20 @@
|
||||||
this.sbName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
|
this.sbName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
this.sbName.HeaderText = "Name";
|
this.sbName.HeaderText = "Name";
|
||||||
this.sbName.Name = "sbName";
|
this.sbName.Name = "sbName";
|
||||||
this.sbName.Width = 60;
|
this.sbName.Width = 64;
|
||||||
//
|
//
|
||||||
// sbLink
|
// sbLink
|
||||||
//
|
//
|
||||||
this.sbLink.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
|
this.sbLink.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
this.sbLink.HeaderText = "Link";
|
this.sbLink.HeaderText = "Link";
|
||||||
this.sbLink.Name = "sbLink";
|
this.sbLink.Name = "sbLink";
|
||||||
this.sbLink.Width = 52;
|
this.sbLink.Width = 54;
|
||||||
//
|
//
|
||||||
// SettingsForms
|
// SettingsForms
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(933, 519);
|
||||||
this.Controls.Add(this.sourceGrid);
|
this.Controls.Add(this.sourceGrid);
|
||||||
this.Name = "SettingsForms";
|
this.Name = "SettingsForms";
|
||||||
this.ShowIcon = false;
|
this.ShowIcon = false;
|
||||||
|
@ -75,9 +74,8 @@
|
||||||
this.Text = "Sources";
|
this.Text = "Sources";
|
||||||
this.TopMost = true;
|
this.TopMost = true;
|
||||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SettingsForms_FormClosing);
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SettingsForms_FormClosing);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.sourceGrid)).EndInit();
|
((System.ComponentModel.ISupportInitialize) (this.sourceGrid)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Linq;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using UpTool2.Tool;
|
using UpTool2.Tool;
|
||||||
|
|
||||||
|
@ -7,34 +6,29 @@ namespace UpTool2
|
||||||
{
|
{
|
||||||
public partial class SettingsForms : Form
|
public partial class SettingsForms : Form
|
||||||
{
|
{
|
||||||
private XDocument doc;
|
private readonly XDocument doc;
|
||||||
private XElement meta;
|
private readonly XElement meta;
|
||||||
private XElement repos;
|
private readonly XElement repos;
|
||||||
|
|
||||||
public SettingsForms()
|
public SettingsForms()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Program.FixXML();
|
Program.FixXml();
|
||||||
doc = XDocument.Load(PathTool.infoXML);
|
doc = XDocument.Load(PathTool.InfoXml);
|
||||||
meta = doc.Element("meta");
|
meta = doc.Element("meta");
|
||||||
repos = meta.Element("Repos");
|
repos = meta.Element("Repos");
|
||||||
foreach (XElement repo in repos.Elements("Repo"))
|
foreach (XElement repo in repos.Elements("Repo"))
|
||||||
{
|
|
||||||
sourceGrid.Rows.Add(repo.Element("Name").Value, repo.Element("Link").Value);
|
sourceGrid.Rows.Add(repo.Element("Name").Value, repo.Element("Link").Value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SettingsForms_FormClosing(object sender, FormClosingEventArgs e)
|
private void SettingsForms_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
repos.RemoveNodes();
|
repos.RemoveNodes();
|
||||||
for (int y = 0; y < sourceGrid.Rows.Count; y++)
|
for (int y = 0; y < sourceGrid.Rows.Count; y++)
|
||||||
{
|
|
||||||
if (y + 1 < sourceGrid.Rows.Count)
|
if (y + 1 < sourceGrid.Rows.Count)
|
||||||
{
|
repos.Add(new XElement("Repo", new XElement("Name", (string) sourceGrid.Rows[y].Cells[0].Value),
|
||||||
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)));
|
new XElement("Link", (string) sourceGrid.Rows[y].Cells[1].Value)));
|
||||||
}
|
doc.Save(PathTool.InfoXml);
|
||||||
}
|
|
||||||
doc.Save(PathTool.infoXML);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ using System.IO.Compression;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using UpTool2.Data;
|
using UpTool2.DataStructures;
|
||||||
|
|
||||||
namespace UpTool2.Tool
|
namespace UpTool2.Tool
|
||||||
{
|
{
|
||||||
|
@ -27,19 +27,20 @@ namespace UpTool2.Tool
|
||||||
if (Directory.Exists(app))
|
if (Directory.Exists(app))
|
||||||
Directory.Delete(app, true);
|
Directory.Delete(app, true);
|
||||||
Directory.CreateDirectory(app);
|
Directory.CreateDirectory(app);
|
||||||
using DownloadDialog dlg = new DownloadDialog(appI.file);
|
using DownloadDialog dlg = new DownloadDialog(appI.File);
|
||||||
if (dlg.ShowDialog() != DialogResult.OK)
|
if (dlg.ShowDialog() != DialogResult.OK)
|
||||||
throw new Exception("Download failed");
|
throw new Exception("Download failed");
|
||||||
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
|
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
|
||||||
{
|
{
|
||||||
string pkghash = BitConverter.ToString(sha256.ComputeHash(dlg.result)).Replace("-", string.Empty).ToUpper();
|
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dlg.Result)).Replace("-", string.Empty)
|
||||||
if (pkghash != appI.hash.ToUpper())
|
.ToUpper();
|
||||||
|
if (pkgHash != appI.Hash.ToUpper())
|
||||||
throw new Exception($@"The hash is not equal to the one stored in the repo:
|
throw new Exception($@"The hash is not equal to the one stored in the repo:
|
||||||
Package: {pkghash}
|
Package: {pkgHash}
|
||||||
Online: {appI.hash.ToUpper()}");
|
Online: {appI.Hash.ToUpper()}");
|
||||||
}
|
}
|
||||||
File.WriteAllBytes(Path.Combine(app, "package.zip"), dlg.result);
|
File.WriteAllBytes(Path.Combine(app, "package.zip"), dlg.Result);
|
||||||
completeInstall(appI);
|
CompleteInstall(appI);
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@ -58,7 +59,7 @@ Online: {appI.hash.ToUpper()}");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void installZip(string zipPath, App meta)
|
public static void InstallZip(string zipPath, App meta)
|
||||||
{
|
{
|
||||||
string app = "";
|
string app = "";
|
||||||
string tmp = "";
|
string tmp = "";
|
||||||
|
@ -70,8 +71,8 @@ Online: {appI.hash.ToUpper()}");
|
||||||
if (Directory.Exists(tmp))
|
if (Directory.Exists(tmp))
|
||||||
Directory.Delete(tmp, true);
|
Directory.Delete(tmp, true);
|
||||||
Directory.CreateDirectory(tmp);
|
Directory.CreateDirectory(tmp);
|
||||||
File.Copy(zipPath, Path.Combine(app + "package.zip"));
|
File.Copy(zipPath, Path.Combine(app, "package.zip"));
|
||||||
completeInstall(meta);
|
CompleteInstall(meta);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -86,24 +87,32 @@ Online: {appI.hash.ToUpper()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void completeInstall(App app) => completeInstall(app.appPath, app.name, app.description, app.version, app.mainFile);
|
private static void CompleteInstall(App app) =>
|
||||||
|
CompleteInstall(app.appPath, app.Name, app.Description, app.Version, app.MainFile);
|
||||||
|
|
||||||
private static void completeInstall(string appPath, string name, string description, Version version, string mainFile)
|
private static void CompleteInstall(string appPath, string name, string description, Version version,
|
||||||
|
string mainFile)
|
||||||
{
|
{
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
string tmp = PathTool.tempPath;
|
string tmp = PathTool.tempPath;
|
||||||
ZipFile.ExtractToDirectory(Path.Combine(appPath + "package.zip"), tmp);
|
ZipFile.ExtractToDirectory(Path.Combine(appPath, "package.zip"), tmp);
|
||||||
Directory.Move(Path.Combine(tmp + "Data"), Path.Combine(appPath + "app"));
|
Directory.Move(Path.Combine(tmp, "Data"), Path.Combine(appPath, "app"));
|
||||||
XElement el = new XElement("app", new XElement("Name", name), new XElement("Description", description), new XElement("Version", version));
|
XElement el = new XElement("app", new XElement("Name", name), new XElement("Description", description),
|
||||||
|
new XElement("Version", version));
|
||||||
if (mainFile != null)
|
if (mainFile != null)
|
||||||
el.Add(new XElement(new XElement("MainFile", mainFile)));
|
el.Add(new XElement(new XElement("MainFile", mainFile)));
|
||||||
el.Save(Path.Combine(appPath, "info.xml"));
|
el.Save(Path.Combine(appPath, "info.xml"));
|
||||||
Process.Start(new ProcessStartInfo { FileName = "cmd.exe", Arguments = $"/C \"{Path.Combine(tmp, "Install.bat")}\"", WorkingDirectory = Path.Combine(appPath, "app"), CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden }).WaitForExit();
|
Process.Start(new ProcessStartInfo
|
||||||
if (GlobalVariables.relE)
|
{
|
||||||
GlobalVariables.reloadElements.Invoke();
|
FileName = "cmd.exe", Arguments = $"/C \"{Path.Combine(tmp, "Install.bat")}\"",
|
||||||
|
WorkingDirectory = Path.Combine(appPath, "app"), CreateNoWindow = true,
|
||||||
|
WindowStyle = ProcessWindowStyle.Hidden
|
||||||
|
}).WaitForExit();
|
||||||
|
if (GlobalVariables.RelE)
|
||||||
|
GlobalVariables.ReloadElements.Invoke();
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch { throw; }
|
catch { throw; }
|
||||||
|
|
3
UpTool2/Tool/DownloadDialog.Designer.cs
generated
3
UpTool2/Tool/DownloadDialog.Designer.cs
generated
|
@ -16,7 +16,7 @@
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
client.Dispose();
|
_client.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,6 @@
|
||||||
this.Text = "Downloading...";
|
this.Text = "Downloading...";
|
||||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DownloadDialog_FormClosing);
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DownloadDialog_FormClosing);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -6,19 +6,19 @@ namespace UpTool2.Tool
|
||||||
{
|
{
|
||||||
public partial class DownloadDialog : Form
|
public partial class DownloadDialog : Form
|
||||||
{
|
{
|
||||||
private bool close;
|
private readonly WebClient _client;
|
||||||
private readonly WebClient client;
|
private bool _close;
|
||||||
public byte[] result;
|
public byte[] Result;
|
||||||
|
|
||||||
public DownloadDialog(string uri)
|
public DownloadDialog(string uri)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client = new WebClient();
|
_client = new WebClient();
|
||||||
client.DownloadProgressChanged += progressChanged;
|
_client.DownloadProgressChanged += ProgressChanged;
|
||||||
client.DownloadDataCompleted += done;
|
_client.DownloadDataCompleted += Done;
|
||||||
client.DownloadDataAsync(new Uri(uri), client);
|
_client.DownloadDataAsync(new Uri(uri), _client);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -27,16 +27,17 @@ namespace UpTool2.Tool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void done(object sender, DownloadDataCompletedEventArgs e)
|
private void Done(object sender, DownloadDataCompletedEventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
close = true;
|
_close = true;
|
||||||
result = e.Result;
|
Result = e.Result;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void progressChanged(object sender, DownloadProgressChangedEventArgs e) => progressBar.Value = e.ProgressPercentage;
|
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e) =>
|
||||||
|
progressBar.Value = e.ProgressPercentage;
|
||||||
|
|
||||||
private void DownloadDialog_FormClosing(object sender, FormClosingEventArgs e) => e.Cancel = !close;
|
private void DownloadDialog_FormClosing(object sender, FormClosingEventArgs e) => e.Cancel = !_close;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,17 +6,20 @@ namespace UpTool2.Tool
|
||||||
{
|
{
|
||||||
internal static class PathTool
|
internal static class PathTool
|
||||||
{
|
{
|
||||||
public static string GetProgPath(params string[] segments) => Path.Combine(new[] { dir }.Concat(segments).ToArray());
|
public static string dir =>
|
||||||
|
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "UpTool2");
|
||||||
|
|
||||||
public static string dir => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "UpTool2");
|
public static string tempPath => GetRelative("tmp");
|
||||||
public static string tempPath => GetProgPath("tmp");
|
public static string appsPath => GetRelative("Apps");
|
||||||
public static string appsPath => GetProgPath("Apps");
|
public static string InfoXml => GetRelative("info.xml");
|
||||||
public static string infoXML => GetProgPath("info.xml");
|
|
||||||
|
|
||||||
public static string getAppPath(Guid app) => Path.Combine(appsPath, app.ToString());
|
public static string GetRelative(params string[] segments) =>
|
||||||
|
Path.Combine(new[] {dir}.Concat(segments).ToArray());
|
||||||
|
|
||||||
public static string getDataPath(Guid app) => Path.Combine(getAppPath(app) + @"app");
|
public static string GetAppPath(Guid app) => Path.Combine(appsPath, app.ToString());
|
||||||
|
|
||||||
public static string getInfoPath(Guid app) => Path.Combine(getAppPath(app), "info.xml");
|
public static string GetDataPath(Guid app) => Path.Combine(GetAppPath(app), "app");
|
||||||
|
|
||||||
|
public static string GetInfoPath(Guid app) => Path.Combine(GetAppPath(app), "info.xml");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,19 +8,20 @@ using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using UpTool2.Data;
|
using UpTool2.DataStructures;
|
||||||
using UpTool2.Properties;
|
using UpTool2.Properties;
|
||||||
|
|
||||||
namespace UpTool2.Tool
|
namespace UpTool2.Tool
|
||||||
{
|
{
|
||||||
internal static class RepoManagement
|
internal static class RepoManagement
|
||||||
{
|
{
|
||||||
public static void fetchRepos()
|
public static void FetchRepos()
|
||||||
{
|
{
|
||||||
Program.FixXML();
|
Program.FixXml();
|
||||||
XElement meta = XDocument.Load(PathTool.infoXML).Element("meta");
|
XElement meta = XDocument.Load(PathTool.InfoXml).Element("meta");
|
||||||
List<XElement> tmp_apps_list = new List<XElement>();
|
List<XElement> tmpAppsList = new List<XElement>();
|
||||||
List<string> repArr = meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link").Value).Distinct().ToList();
|
List<string> repArr = meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link").Value).Distinct()
|
||||||
|
.ToList();
|
||||||
using (WebClient client = new WebClient())
|
using (WebClient client = new WebClient())
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -31,30 +32,32 @@ namespace UpTool2.Tool
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
XDocument repo = XDocument.Load(repArr[i]);
|
XDocument repo = XDocument.Load(repArr[i]);
|
||||||
repArr.AddRange(repo.Element("repo").Elements("repolink").Select(s => s.Value).Where(s => !repArr.Contains(s)));
|
repArr.AddRange(repo.Element("repo").Elements("repolink").Select(s => s.Value)
|
||||||
XElement[] tmp_apparray = repo.Element("repo").Elements("app").Where(app => tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value).Count() == 0 ||
|
.Where(s => !repArr.Contains(s)));
|
||||||
tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value)
|
XElement[] tmp_apparray = repo.Element("repo").Elements("app").Where(app =>
|
||||||
.Where(a => a.Element("Version").getVer() >= app.Element("Version").getVer()).Count() == 0).ToArray()
|
!tmpAppsList.Any(a => a.Element("ID").Value == app.Element("ID").Value) ||
|
||||||
.Concat(repo.Element("repo").Elements("applink").Select(s => XDocument.Load(s.Value).Element("app"))).ToArray();
|
!tmpAppsList
|
||||||
|
.Where(a => a.Element("ID").Value == app.Element("ID").Value).Any(a => GetVer(a.Element("Version")) >= app.Element("Version").GetVer())).ToArray()
|
||||||
|
.Concat(repo.Element("repo").Elements("applink")
|
||||||
|
.Select(s => XDocument.Load(s.Value).Element("app"))).ToArray();
|
||||||
for (int i1 = 0; i1 < tmp_apparray.Length; i1++)
|
for (int i1 = 0; i1 < tmp_apparray.Length; i1++)
|
||||||
{
|
{
|
||||||
XElement app = tmp_apparray[i1];
|
XElement app = tmp_apparray[i1];
|
||||||
//"Sanity check"
|
//"Sanity check"
|
||||||
int.Parse(app.Element("Version").Value);
|
Version.Parse(app.Element("Version").Value);
|
||||||
Guid.Parse(app.Element("ID").Value);
|
Guid.Parse(app.Element("ID").Value);
|
||||||
//Create XElement
|
//Create XElement
|
||||||
tmp_apps_list.Add(new XElement("App",
|
tmpAppsList.Add(new XElement("App",
|
||||||
new XElement("Name", app.Element("Name").Value),
|
new XElement("Name", app.Element("Name").Value),
|
||||||
new XElement("Description", app.Element("Description").Value),
|
new XElement("Description", app.Element("Description").Value),
|
||||||
new XElement("Version", app.Element("Version").Value),
|
new XElement("Version", app.Element("Version").Value),
|
||||||
new XElement("ID", app.Element("ID").Value),
|
new XElement("ID", app.Element("ID").Value),
|
||||||
new XElement("File", app.Element("File").Value),
|
new XElement("File", app.Element("File").Value),
|
||||||
new XElement("Hash", app.Element("Hash").Value)
|
new XElement("Hash", app.Element("Hash").Value)
|
||||||
));
|
));
|
||||||
if (app.Element("MainFile") != null)
|
if (app.Element("MainFile") != null)
|
||||||
tmp_apps_list.Last().Add(new XElement("MainFile", app.Element("MainFile").Value));
|
tmpAppsList.Last().Add(new XElement("MainFile", app.Element("MainFile").Value));
|
||||||
if (app.Element("Icon") != null)
|
if (app.Element("Icon") != null)
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Scale Image and save as Base64
|
//Scale Image and save as Base64
|
||||||
|
@ -68,23 +71,23 @@ namespace UpTool2.Tool
|
||||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||||
g.SmoothingMode = SmoothingMode.HighQuality;
|
g.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||||
using (var wrapMode = new ImageAttributes())
|
using ImageAttributes wrapMode = new ImageAttributes();
|
||||||
{
|
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
|
||||||
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
|
g.DrawImage(src, new Rectangle(0, 0, 70, 70), 0, 0, src.Width, src.Height,
|
||||||
g.DrawImage(src, new Rectangle(0, 0, 70, 70), 0, 0, src.Width, src.Height, GraphicsUnit.Pixel, wrapMode);
|
GraphicsUnit.Pixel, wrapMode);
|
||||||
}
|
|
||||||
}
|
|
||||||
using (var ms = new MemoryStream())
|
|
||||||
{
|
|
||||||
dest.Save(ms, ImageFormat.Png);
|
|
||||||
tmp_apps_list.Last().Add(new XElement("Icon", Convert.ToBase64String(ms.ToArray())));
|
|
||||||
}
|
}
|
||||||
|
using MemoryStream ms = new MemoryStream();
|
||||||
|
dest.Save(ms, ImageFormat.Png);
|
||||||
|
tmpAppsList.Last()
|
||||||
|
.Add(new XElement("Icon", Convert.ToBase64String(ms.ToArray())));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
}
|
}
|
||||||
catch { }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value).Count() > 1)
|
if (tmpAppsList.Count(a => a.Element("ID").Value == app.Element("ID").Value) > 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));
|
tmpAppsList.Where(a => a.Element("ID").Value == app.Element("ID").Value).Reverse().Skip(1)
|
||||||
|
.ToList().ForEach(a => tmpAppsList.Remove(a));
|
||||||
}
|
}
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
|
@ -96,64 +99,76 @@ namespace UpTool2.Tool
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmp_apps_list.Sort((x, y) => x.Element("Name").Value.CompareTo(y.Element("Name").Value));
|
tmpAppsList.Sort((x, y) => string.Compare(x.Element("Name").Value, y.Element("Name").Value, StringComparison.Ordinal));
|
||||||
if (meta.Element("LocalRepo") == null)
|
if (meta.Element("LocalRepo") == null)
|
||||||
meta.Add(new XElement("LocalRepo"));
|
meta.Add(new XElement("LocalRepo"));
|
||||||
XElement repos = meta.Element("LocalRepo");
|
XElement repos = meta.Element("LocalRepo");
|
||||||
repos.RemoveNodes();
|
repos.RemoveNodes();
|
||||||
tmp_apps_list.ForEach(app => repos.Add(app));
|
tmpAppsList.ForEach(app => repos.Add(app));
|
||||||
meta.Save(PathTool.infoXML);
|
meta.Save(PathTool.InfoXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Version getVer(this XElement el) => int.TryParse(el.Value, out int i) ? new Version(0, 0, 0, i) : Version.Parse(el.Value);
|
private static Version GetVer(this XElement el) =>
|
||||||
|
int.TryParse(el.Value, out int i) ? new Version(0, 0, 0, i) : Version.Parse(el.Value);
|
||||||
|
|
||||||
public static void getReposFromDisk()
|
public static void GetReposFromDisk()
|
||||||
{
|
{
|
||||||
GlobalVariables.apps.Clear();
|
GlobalVariables.Apps.Clear();
|
||||||
string xml = PathTool.infoXML;
|
string xml = PathTool.InfoXml;
|
||||||
XDocument.Load(xml).Element("meta").Element("LocalRepo").Elements().ToList().ForEach(app =>
|
XDocument.Load(xml).Element("meta").Element("LocalRepo").Elements().ToList().ForEach(app =>
|
||||||
{
|
{
|
||||||
Guid id = Guid.Parse(app.Element("ID").Value);
|
Guid id = Guid.Parse(app.Element("ID").Value);
|
||||||
string locInPath = PathTool.getInfoPath(id);
|
string locInPath = PathTool.GetInfoPath(id);
|
||||||
XElement locIn = File.Exists(locInPath) ? XDocument.Load(locInPath).Element("app") : app;
|
XElement locIn = File.Exists(locInPath) ? XDocument.Load(locInPath).Element("app") : app;
|
||||||
if (int.TryParse(app.Element("Version").Value, out _))
|
if (int.TryParse(app.Element("Version").Value, out _))
|
||||||
app.Element("Version").Value = GlobalVariables.minimumVer.ToString();
|
app.Element("Version").Value = GlobalVariables.minimumVer.ToString();
|
||||||
GlobalVariables.apps.Add(id, new App(
|
GlobalVariables.Apps.Add(id, new App(
|
||||||
name: locIn.Element("Name").Value,
|
locIn.Element("Name").Value,
|
||||||
description: locIn.Element("Description").Value,
|
locIn.Element("Description").Value,
|
||||||
version: Version.Parse(app.Element("Version").Value),
|
Version.Parse(app.Element("Version").Value),
|
||||||
file: app.Element("File").Value,
|
app.Element("File").Value,
|
||||||
local: false,
|
false,
|
||||||
hash: app.Element("Hash").Value,
|
app.Element("Hash").Value,
|
||||||
iD: id,
|
id,
|
||||||
color: Color.White,
|
Color.White,
|
||||||
icon: app.Element("Icon") == null ? Resources.C_64.ToBitmap() : (Bitmap)new ImageConverter().ConvertFrom(Convert.FromBase64String(app.Element("Icon").Value)),
|
app.Element("Icon") == null
|
||||||
runnable: locIn.Element("MainFile") != null || app.Element("MainFile") != null,
|
? Resources.C_64.ToBitmap()
|
||||||
mainFile: locIn.Element("MainFile") == null ? app.Element("MainFile") == null ? "" : app.Element("MainFile").Value : locIn.Element("MainFile").Value
|
: (Bitmap) new ImageConverter().ConvertFrom(
|
||||||
));
|
Convert.FromBase64String(app.Element("Icon").Value)),
|
||||||
|
locIn.Element("MainFile") != null || app.Element("MainFile") != null,
|
||||||
|
locIn.Element("MainFile") == null
|
||||||
|
? app.Element("MainFile") == null ? "" : app.Element("MainFile").Value
|
||||||
|
: locIn.Element("MainFile").Value
|
||||||
|
));
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Console.WriteLine(locIn.Element("MainFile") == null ? "NULL" : locIn.Element("MainFile").Value);
|
Console.WriteLine(locIn.Element("MainFile") == null ? "NULL" : locIn.Element("MainFile").Value);
|
||||||
Console.WriteLine(GlobalVariables.apps[id].mainFile);
|
Console.WriteLine(GlobalVariables.Apps[id].MainFile);
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
Directory.GetDirectories(PathTool.appsPath).Where(s => !GlobalVariables.apps.ContainsKey(Guid.Parse(Path.GetFileName(s)))).ToList().ForEach(s =>
|
Directory.GetDirectories(PathTool.appsPath)
|
||||||
{
|
.Where(s => Guid.TryParse(Path.GetFileName(s), out Guid guid) && !GlobalVariables.Apps.ContainsKey(guid)).ToList().ForEach(s =>
|
||||||
Guid tmp = Guid.Parse(Path.GetFileName(s));
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
XElement data = XDocument.Load(PathTool.getInfoPath(tmp)).Element("app");
|
Guid tmp = Guid.Parse(Path.GetFileName(s));
|
||||||
GlobalVariables.apps.Add(tmp, new App("(local) " + data.Element("Name").Value, data.Element("Description").Value, GlobalVariables.minimumVer, "", true, "", tmp, Color.Red, Resources.C_64.ToBitmap(), data.Element("MainFile") != null, data.Element("MainFile") == null ? "" : data.Element("MainFile").Value));
|
try
|
||||||
}
|
{
|
||||||
catch (Exception e)
|
XElement data = XDocument.Load(PathTool.GetInfoPath(tmp)).Element("app");
|
||||||
{
|
GlobalVariables.Apps.Add(tmp,
|
||||||
if (MessageBox.Show($@"An error occured while loading this local repo:
|
new App("(local) " + data.Element("Name").Value, data.Element("Description").Value,
|
||||||
|
GlobalVariables.minimumVer, "", true, "", tmp, Color.Red, Resources.C_64.ToBitmap(),
|
||||||
|
data.Element("MainFile") != null,
|
||||||
|
data.Element("MainFile") == null ? "" : data.Element("MainFile").Value));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show($@"An error occured while loading this local repo:
|
||||||
{e.Message}
|
{e.Message}
|
||||||
Do you want to exit? Otherwise the folder will be deleted, possibly causeing problems later.", "", MessageBoxButtons.YesNo) == DialogResult.No)
|
Do you want to exit? Otherwise the folder will be deleted, possibly causeing problems later.", "",
|
||||||
Directory.Delete(PathTool.getAppPath(tmp), true);
|
MessageBoxButtons.YesNo) == DialogResult.No)
|
||||||
else
|
Directory.Delete(PathTool.GetAppPath(tmp), true);
|
||||||
Environment.Exit(0);
|
else
|
||||||
}
|
Environment.Exit(0);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,48 +6,116 @@ namespace UpTool2.Tool
|
||||||
{
|
{
|
||||||
internal static class Shortcut
|
internal static class Shortcut
|
||||||
{
|
{
|
||||||
private static Type m_type = Type.GetTypeFromProgID("WScript.Shell");
|
private static readonly Type MType = Type.GetTypeFromProgID("WScript.Shell");
|
||||||
private static object m_shell = Activator.CreateInstance(m_type);
|
private static readonly object MShell = Activator.CreateInstance(MType);
|
||||||
|
|
||||||
public static void Make(string target, string fileName)
|
public static void Make(string target, string fileName)
|
||||||
{
|
{
|
||||||
IWshShortcut shortcut = (IWshShortcut)m_type.InvokeMember("CreateShortcut", BindingFlags.InvokeMethod, null, m_shell, new object[] { fileName });
|
IWshShortcut shortcut = (IWshShortcut) MType.InvokeMember("CreateShortcut", BindingFlags.InvokeMethod,
|
||||||
|
null, MShell, new object[] {fileName});
|
||||||
shortcut.TargetPath = target;
|
shortcut.TargetPath = target;
|
||||||
shortcut.Save();
|
shortcut.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
[ComImport, TypeLibType(0x1040), Guid("F935DC23-1CF0-11D0-ADB9-00C04FD58A0B")]
|
[ComImport]
|
||||||
|
[TypeLibType(0x1040)]
|
||||||
|
[Guid("F935DC23-1CF0-11D0-ADB9-00C04FD58A0B")]
|
||||||
private interface IWshShortcut
|
private interface IWshShortcut
|
||||||
{
|
{
|
||||||
[DispId(0)]
|
[DispId(0)]
|
||||||
string FullName { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0)] get; }
|
string FullName
|
||||||
|
{
|
||||||
|
[return: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0)]
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
[DispId(0x3e8)]
|
[DispId(0x3e8)]
|
||||||
string Arguments { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3e8)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3e8)] set; }
|
string Arguments
|
||||||
|
{
|
||||||
|
[return: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3e8)]
|
||||||
|
get;
|
||||||
|
[param: In]
|
||||||
|
[param: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3e8)]
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
[DispId(0x3e9)]
|
[DispId(0x3e9)]
|
||||||
string Description { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3e9)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3e9)] set; }
|
string Description
|
||||||
|
{
|
||||||
|
[return: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3e9)]
|
||||||
|
get;
|
||||||
|
[param: In]
|
||||||
|
[param: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3e9)]
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
[DispId(0x3ea)]
|
[DispId(0x3ea)]
|
||||||
string Hotkey { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3ea)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ea)] set; }
|
string Hotkey
|
||||||
|
{
|
||||||
|
[return: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3ea)]
|
||||||
|
get;
|
||||||
|
[param: In]
|
||||||
|
[param: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3ea)]
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
[DispId(0x3eb)]
|
[DispId(0x3eb)]
|
||||||
string IconLocation { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3eb)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3eb)] set; }
|
string IconLocation
|
||||||
|
{
|
||||||
|
[return: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3eb)]
|
||||||
|
get;
|
||||||
|
[param: In]
|
||||||
|
[param: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3eb)]
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
[DispId(0x3ec)]
|
[DispId(0x3ec)]
|
||||||
string RelativePath { [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ec)] set; }
|
string RelativePath
|
||||||
|
{
|
||||||
|
[param: In]
|
||||||
|
[param: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3ec)]
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
[DispId(0x3ed)]
|
[DispId(0x3ed)]
|
||||||
string TargetPath { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3ed)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ed)] set; }
|
string TargetPath
|
||||||
|
{
|
||||||
|
[return: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3ed)]
|
||||||
|
get;
|
||||||
|
[param: In]
|
||||||
|
[param: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3ed)]
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
[DispId(0x3ee)]
|
[DispId(0x3ee)] int WindowStyle { [DispId(0x3ee)] get; [param: In] [DispId(0x3ee)] set; }
|
||||||
int WindowStyle { [DispId(0x3ee)] get; [param: In] [DispId(0x3ee)] set; }
|
|
||||||
|
|
||||||
[DispId(0x3ef)]
|
[DispId(0x3ef)]
|
||||||
string WorkingDirectory { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3ef)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ef)] set; }
|
string WorkingDirectory
|
||||||
|
{
|
||||||
|
[return: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3ef)]
|
||||||
|
get;
|
||||||
|
[param: In]
|
||||||
|
[param: MarshalAs(UnmanagedType.BStr)]
|
||||||
|
[DispId(0x3ef)]
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
[TypeLibFunc(0x40), DispId(0x7d0)]
|
[TypeLibFunc(0x40)]
|
||||||
void Load([In, MarshalAs(UnmanagedType.BStr)] string PathLink);
|
[DispId(0x7d0)]
|
||||||
|
void Load([In] [MarshalAs(UnmanagedType.BStr)] string pathLink);
|
||||||
|
|
||||||
[DispId(0x7d1)]
|
[DispId(0x7d1)]
|
||||||
void Save();
|
void Save();
|
||||||
|
|
|
@ -9,11 +9,12 @@
|
||||||
<RootNamespace>UpTool2</RootNamespace>
|
<RootNamespace>UpTool2</RootNamespace>
|
||||||
<AssemblyName>UpTool2</AssemblyName>
|
<AssemblyName>UpTool2</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
<LangVersion>preview</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<Deterministic>false</Deterministic>
|
<Deterministic>false</Deterministic>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
|
Reference in New Issue
Block a user