Maybe fix everything

This commit is contained in:
CreepyCrafter24 2020-02-28 14:26:16 +01:00
parent 46a9bf099b
commit fea9f80001
22 changed files with 612 additions and 445 deletions

0
.idea/.gitignore vendored Normal file
View File

2
.idea/.idea.UpTool2/.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# Default ignored files
/workspace.xml

View 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>

View 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>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ContentModelUserStore">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View 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>

View 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>

View File

@ -1,77 +1,73 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using UpTool2.Tool;
using static System.Environment;
using Version = System.Version;
namespace UpTool2.Data
namespace UpTool2.DataStructures
{
public struct App : IEquatable<App>
{
public string name;
public string description;
public Version version;
public string file;
public bool local;
public string hash;
public Guid ID;
public Color color;
public Image icon;
public bool runnable;
public string mainFile;
public readonly string Name;
public readonly string Description;
public readonly Version Version;
public readonly string File;
public readonly bool Local;
public readonly string Hash;
private Guid _id;
public Color Color;
public readonly Image Icon;
public readonly bool Runnable;
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));
this.description = description ?? throw new ArgumentNullException(nameof(description));
this.version = version;
this.file = file ?? throw new ArgumentNullException(nameof(file));
this.local = local;
this.hash = hash ?? throw new ArgumentNullException(nameof(hash));
ID = iD;
this.color = color;
this.icon = icon ?? throw new ArgumentNullException(nameof(icon));
this.runnable = runnable;
this.mainFile = mainFile ?? throw new ArgumentNullException(nameof(mainFile));
Name = name ?? throw new ArgumentNullException(nameof(name));
Description = description ?? throw new ArgumentNullException(nameof(description));
Version = version;
File = file ?? throw new ArgumentNullException(nameof(file));
Local = local;
Hash = hash ?? throw new ArgumentNullException(nameof(hash));
_id = iD;
Color = color;
Icon = icon ?? throw new ArgumentNullException(nameof(icon));
Runnable = runnable;
MainFile = mainFile ?? throw new ArgumentNullException(nameof(mainFile));
}
public Status status
{
get {
string xml = PathTool.getInfoPath(ID);
if (File.Exists(xml))
{
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
get
{
if (!System.IO.File.Exists(infoPath))
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 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:
{string.Join(NewLine, description.Split('\n').Select(s => { if (s.EndsWith("\r")) s.Remove(s.Length - 1, 1); return "> " + s; }))}
Version: {version}
File: {file}
Local: {local.ToString()}
Hash: {hash}
ID: {ID.ToString()}
Color: {color.ToKnownColor().ToString()}
Runnable: {runnable}
MainFile: {mainFile}
{string.Join(NewLine, Description.Split('\n').Select(s => { if (s.EndsWith("\r")) s.Remove(s.Length - 1, 1); return "> " + s; }))}
Version: {Version}
File: {File}
Local: {Local.ToString()}
Hash: {Hash}
ID: {_id.ToString()}
Color: {Color.ToKnownColor().ToString()}
Runnable: {Runnable}
MainFile: {MainFile}
Status: {status.ToString()}
Object Hash Code: {GetHashCode()}";
@ -79,8 +75,8 @@ Object Hash Code: {GetHashCode()}";
public static bool operator !=(App left, App right) => !(left == right);
public string appPath => PathTool.getAppPath(this.ID);
public string dataPath => PathTool.getDataPath(this.ID);
public string infoPath => PathTool.getInfoPath(this.ID);
public string appPath => PathTool.GetAppPath(_id);
public string dataPath => PathTool.GetDataPath(_id);
public string infoPath => PathTool.GetInfoPath(_id);
}
}

View File

@ -1,5 +1,8 @@
namespace UpTool2.Data
using System;
namespace UpTool2.DataStructures
{
[Flags]
public enum Status
{
Not_Installed = 1,

View File

@ -1,14 +1,14 @@
using System;
using System.Collections.Generic;
using UpTool2.Data;
using UpTool2.DataStructures;
namespace UpTool2
{
static partial class GlobalVariables
internal static class GlobalVariables
{
public static Dictionary<Guid, App> apps = new Dictionary<Guid, App>();
public static bool relE = true;
public static Action reloadElements;
public static readonly Dictionary<Guid, App> Apps = new Dictionary<Guid, App>();
public static bool RelE = true;
public static Action ReloadElements;
public static Version minimumVer => Version.Parse("0.0.0.0");
}
}

View File

@ -47,7 +47,7 @@
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.searchPackageDialog = new System.Windows.Forms.OpenFileDialog();
this.infoPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
((System.ComponentModel.ISupportInitialize) (this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
this.splitContainer.SuspendLayout();
@ -59,9 +59,9 @@
this.sidebarPanel.AutoScroll = true;
this.sidebarPanel.BackColor = System.Drawing.SystemColors.ControlLight;
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.Size = new System.Drawing.Size(268, 391);
this.sidebarPanel.Size = new System.Drawing.Size(312, 451);
this.sidebarPanel.TabIndex = 0;
//
// infoPanel
@ -75,15 +75,17 @@
this.infoPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.infoPanel.Location = new System.Drawing.Point(0, 0);
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;
//
// action_run
//
this.action_run.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.action_run.Location = new System.Drawing.Point(421, 5);
this.action_run.Anchor =
((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.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.Text = "↗";
this.action_run.UseVisualStyleBackColor = true;
@ -91,11 +93,13 @@
//
// 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.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.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.Text = "🗑";
this.action_remove.UseVisualStyleBackColor = true;
@ -103,11 +107,13 @@
//
// 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.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.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.Text = "⭱";
this.action_update.UseVisualStyleBackColor = true;
@ -115,11 +121,13 @@
//
// 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.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.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.Text = "⭳";
this.action_install.UseVisualStyleBackColor = true;
@ -127,15 +135,16 @@
//
// 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.Size = new System.Drawing.Size(524, 397);
this.infoPanel_Description.Size = new System.Drawing.Size(611, 458);
this.infoPanel_Description.TabIndex = 1;
//
// infoPanel_Title
//
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.Name = "infoPanel_Title";
this.infoPanel_Title.Size = new System.Drawing.Size(0, 31);
@ -157,8 +166,9 @@
//
this.splitContainer.Panel2.Controls.Add(this.infoPanel);
this.splitContainer.Panel2MinSize = 160;
this.splitContainer.Size = new System.Drawing.Size(800, 450);
this.splitContainer.SplitterDistance = 268;
this.splitContainer.Size = new System.Drawing.Size(933, 519);
this.splitContainer.SplitterDistance = 312;
this.splitContainer.SplitterWidth = 5;
this.splitContainer.TabIndex = 0;
this.splitContainer.TabStop = false;
//
@ -172,15 +182,17 @@
this.optionsPanel.Dock = System.Windows.Forms.DockStyle.Top;
this.optionsPanel.Location = new System.Drawing.Point(0, 0);
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;
//
// controls_upload
//
this.controls_upload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.controls_upload.Location = new System.Drawing.Point(242, 5);
this.controls_upload.Anchor =
((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.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.Text = "↑";
this.controls_upload.UseVisualStyleBackColor = true;
@ -188,31 +200,35 @@
//
// filterBox
//
this.filterBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.filterBox.Anchor =
((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.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.Size = new System.Drawing.Size(178, 21);
this.filterBox.Size = new System.Drawing.Size(207, 23);
this.filterBox.TabIndex = 3;
this.filterBox.SelectedIndexChanged += new System.EventHandler(this.updateSidebarV);
this.filterBox.SelectedIndexChanged += new System.EventHandler(this.UpdateSidebarV);
//
// searchBox
//
this.searchBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.searchBox.Location = new System.Drawing.Point(3, 33);
this.searchBox.Anchor =
((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Bottom |
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.Size = new System.Drawing.Size(262, 20);
this.searchBox.Size = new System.Drawing.Size(305, 23);
this.searchBox.TabIndex = 2;
this.searchBox.TextChanged += new System.EventHandler(this.updateSidebarV);
this.searchBox.TextChanged += new System.EventHandler(this.UpdateSidebarV);
//
// 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.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.Text = "⚙";
this.controls_settings.UseVisualStyleBackColor = true;
@ -220,9 +236,9 @@
//
// 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.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.Text = "↻";
this.controls_reload.UseVisualStyleBackColor = true;
@ -241,12 +257,12 @@
//
// 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.ClientSize = new System.Drawing.Size(800, 450);
this.ClientSize = new System.Drawing.Size(933, 519);
this.Controls.Add(this.splitContainer);
this.HelpButton = true;
this.MinimumSize = new System.Drawing.Size(543, 238);
this.MinimumSize = new System.Drawing.Size(631, 269);
this.Name = "MainForm";
this.ShowIcon = false;
this.Text = "UpTool 2";
@ -256,12 +272,11 @@
this.infoPanel.PerformLayout();
this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
((System.ComponentModel.ISupportInitialize) (this.splitContainer)).EndInit();
this.splitContainer.ResumeLayout(false);
this.optionsPanel.ResumeLayout(false);
this.optionsPanel.PerformLayout();
this.ResumeLayout(false);
}
#endregion

View File

@ -1,34 +1,52 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using UpTool2.Properties;
using System.IO;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using Microsoft.VisualBasic;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Microsoft.VisualBasic;
using UpTool2.DataStructures;
using UpTool2.Properties;
using UpTool2.Tool;
using UpTool2.Data;
#if DEBUG
using System.Threading;
using System.Linq;
#endif
namespace UpTool2
{
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)
{
#if !DEBUG
try
{
#endif
AppInstall.Install((App)action_install.Tag);
AppInstall.Install((App) action_install.Tag);
#if !DEBUG
}
catch (Exception e1)
@ -44,21 +62,25 @@ namespace UpTool2
{
try
{
string app = ((App)action_remove.Tag).appPath;
string app = ((App) action_remove.Tag).appPath;
string tmp = PathTool.tempPath;
if (Directory.Exists(tmp))
Directory.Delete(tmp, true);
Directory.CreateDirectory(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(app, true);
if (GlobalVariables.relE)
reloadElements();
if (GlobalVariables.RelE)
ReloadElements();
}
catch (Exception e1)
{
if (!GlobalVariables.relE)
if (!GlobalVariables.RelE)
throw;
MessageBox.Show(e1.ToString(), "Removal failed");
}
@ -70,14 +92,14 @@ namespace UpTool2
try
{
#endif
if (searchPackageDialog.ShowDialog() == DialogResult.OK)
{
Guid ID = Guid.NewGuid();
while (GlobalVariables.apps.ContainsKey(ID) || Directory.Exists(PathTool.getAppPath(ID)))
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, "");
AppInstall.installZip(searchPackageDialog.FileName, appI);
}
if (searchPackageDialog.ShowDialog() != DialogResult.OK)
return;
Guid id = Guid.NewGuid();
while (GlobalVariables.Apps.ContainsKey(id) || Directory.Exists(PathTool.GetAppPath(id)))
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, "");
AppInstall.InstallZip(searchPackageDialog.FileName, appI);
#if !DEBUG
}
catch (Exception e1)
@ -89,19 +111,16 @@ namespace UpTool2
#endif
}
private void reloadElements()
private void ReloadElements()
{
//remove
toolTip.RemoveAll();
clearSelection();
ClearSelection();
infoPanel_Title.Invalidate();
infoPanel_Description.Invalidate();
int F = sidebarPanel.Controls.Count;
for (int i = 0; i < F; i++)
{
sidebarPanel.Controls[0].Dispose();
}
GlobalVariables.apps.Clear();
for (int i = 0; i < F; i++) sidebarPanel.Controls[0].Dispose();
GlobalVariables.Apps.Clear();
//add
toolTip.SetToolTip(controls_settings, "Settings");
toolTip.SetToolTip(controls_reload, "Refresh repositories");
@ -111,60 +130,73 @@ namespace UpTool2
toolTip.SetToolTip(action_remove, "Remove");
toolTip.SetToolTip(action_update, "Update");
toolTip.SetToolTip(action_run, "Run");
RepoManagement.getReposFromDisk();
RepoManagement.GetReposFromDisk();
int availableUpdates = 0;
foreach (App app in GlobalVariables.apps.Values)
foreach (App app in GlobalVariables.Apps.Values)
{
Panel sidebarIcon = new Panel();
sidebarIcon.Tag = app;
sidebarIcon.BackColor = app.color;
sidebarIcon.BackColor = app.Color;
sidebarIcon.Size = new Size(70, 70);
sidebarIcon.BackgroundImage = app.icon;
sidebarIcon.BackgroundImage = app.Icon;
sidebarIcon.BackgroundImageLayout = ImageLayout.Stretch;
bool updatable = (!app.local) && ((app.status & Status.Updatable) == Status.Updatable);
sidebarIcon.Click += (object sender, EventArgs e) =>
bool updatable = !app.Local && (app.status & Status.Updatable) == Status.Updatable;
sidebarIcon.Click += (sender, e) =>
{
infoPanel_Title.Text = app.name;
infoPanel_Title.ForeColor = app.local ? Color.Red : Color.Black;
infoPanel_Description.Text = app.description;
infoPanel_Title.Text = app.Name;
infoPanel_Title.ForeColor = app.Local ? Color.Red : Color.Black;
infoPanel_Description.Text = app.Description;
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.Enabled = Directory.Exists(app.appPath);
action_update.Tag = app;
action_update.Enabled = updatable;
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)
availableUpdates++;
toolTip.SetToolTip(sidebarIcon, app.name);
toolTip.SetToolTip(sidebarIcon, app.Name);
sidebarPanel.Controls.Add(sidebarIcon);
}
updateSidebarV(null, null);
Text = $"UpTool2 {((availableUpdates == 0) ? "(All up-to-date)" : $"({availableUpdates.ToString()} Updates)")}";
UpdateSidebarV(null, null);
Text =
$"UpTool2 {(availableUpdates == 0 ? "(All up-to-date)" : $"({availableUpdates.ToString()} Updates)")}";
}
private void Action_run_Click(object sender, EventArgs e)
{
Console.WriteLine(new string('-', 10));
Console.WriteLine(((App)action_run.Tag).dataPath);
Console.WriteLine(((App) action_run.Tag).dataPath);
Console.WriteLine("\\");
Console.WriteLine(((App)action_run.Tag).mainFile);
Console.WriteLine(((App)action_run.Tag).dataPath);
_ = Process.Start(
new ProcessStartInfo
{
FileName = Path.Combine(((App)action_run.Tag).dataPath, ((App)action_run.Tag).mainFile),
WorkingDirectory = ((App)action_run.Tag).dataPath
});
Console.WriteLine(((App) action_run.Tag).MainFile);
Console.WriteLine(((App) action_run.Tag).dataPath);
string path = Path.Combine(((App) action_run.Tag).dataPath, ((App) action_run.Tag).MainFile);
try
{
Process.Start(
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)
{
try
{
GlobalVariables.relE = false;
GlobalVariables.RelE = false;
Action_remove_Click(sender, e);
Action_install_Click(sender, e);
}
@ -172,19 +204,19 @@ namespace UpTool2
{
MessageBox.Show(e1.ToString(), "Install failed");
}
reloadElements();
GlobalVariables.relE = true;
ReloadElements();
GlobalVariables.RelE = true;
}
private void Controls_reload_Click(object sender, EventArgs e)
{
RepoManagement.fetchRepos();
reloadElements();
RepoManagement.FetchRepos();
ReloadElements();
}
private void Controls_settings_Click(object sender, EventArgs e) => new SettingsForms().ShowDialog();
private void clearSelection()
private void ClearSelection()
{
action_install.Enabled = false;
action_remove.Enabled = false;
@ -194,18 +226,21 @@ namespace UpTool2
infoPanel_Description.Text = "";
}
private void updateSidebarV(object sender, EventArgs e)
private void UpdateSidebarV(object sender, EventArgs e)
{
#if DEBUG
if (searchBox.Text == "!DEBUG:PRINT!")
{
searchBox.Text = "!DEBUG:PRINT";
string _tmp_file = 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()));
string tmpFile = Path.GetTempFileName();
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(() =>
{
Process.Start("notepad", _tmp_file).WaitForExit();
File.Delete(_tmp_file);
Process.Start("notepad", tmpFile).WaitForExit();
File.Delete(tmpFile);
}).Start();
}
else
@ -214,59 +249,30 @@ namespace UpTool2
Enum.TryParse(filterBox.SelectedValue.ToString(), out Status status);
for (int i = 0; i < sidebarPanel.Controls.Count; i++)
{
Panel sidebarIcon = (Panel)sidebarPanel.Controls[i];
App app = (App)sidebarIcon.Tag;
sidebarIcon.Visible = app.name.Contains(searchBox.Text) && ((int)app.status & (int)(Program.online ? status : Status.Installed)) != 0;
Panel sidebarIcon = (Panel) sidebarPanel.Controls[i];
App app = (App) sidebarIcon.Tag;
sidebarIcon.Visible = app.Name.Contains(searchBox.Text) &&
((int) app.status & (int) (Program.Online ? status : Status.Installed)) != 0;
}
clearSelection();
ClearSelection();
#if DEBUG
}
#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)
{
Program.splash.Hide();
Program.Splash.Hide();
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)
{
var path = assembly.GetName().CodeBase;
string path = assembly.GetName().CodeBase;
if (File.Exists(path))
{
var buffer = new byte[Math.Max(Marshal.SizeOf(typeof(_IMAGE_FILE_HEADER)), 4)];
using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
byte[] buffer = new byte[Math.Max(Marshal.SizeOf(typeof(_IMAGE_FILE_HEADER)), 4)];
using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
fileStream.Position = 0x3C;
fileStream.Read(buffer, 0, 4);
@ -274,12 +280,15 @@ namespace UpTool2
fileStream.Read(buffer, 0, 4); // "PE\0\0"
fileStream.Read(buffer, 0, buffer.Length);
}
var pinnedBuffer = GCHandle.Alloc(buffer, GCHandleType.Pinned);
GCHandle pinnedBuffer = GCHandle.Alloc(buffer, GCHandleType.Pinned);
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
{
@ -293,9 +302,20 @@ namespace UpTool2
{
DateTime buildTime = GetBuildDateTime(Assembly.GetExecutingAssembly());
_ = MessageBox.Show($@"UpTool2 by CC24
Version: {Assembly.GetExecutingAssembly().GetName().Version.ToString()}
Build Date: {buildTime.ToString("dd.MM.yyyy")}", "UpTool2");
Version: {Assembly.GetExecutingAssembly().GetName().Version}
Build Date: {buildTime:dd.MM.yyyy}", "UpTool2");
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;
}
}
}

View File

@ -15,14 +15,13 @@ using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using UpTool2.Tool;
using Shortcut = UpTool2.Tool.Shortcut;
namespace UpTool2
{
internal static class Program
{
public static Form splash;
public static bool online;
public static Form Splash;
public static bool Online;
[STAThread]
private static void Main()
@ -30,36 +29,38 @@ namespace UpTool2
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
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);
var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);
var securitySettings = new MutexSecurity();
MutexAccessRule allowEveryoneRule = new MutexAccessRule(
new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl,
AccessControlType.Allow);
MutexSecurity securitySettings = new MutexSecurity();
securitySettings.AddAccessRule(allowEveryoneRule);
using (var mutex = new Mutex(false, mutexId, out bool createdNew, securitySettings))
{
var hasHandle = false;
using Mutex mutex = new Mutex(false, mutexId, out bool createdNew, securitySettings);
bool hasHandle = false;
#if !DEBUG
try
{
#endif
try
{
hasHandle = mutex.WaitOne(5000, false);
if (hasHandle == false)
throw new TimeoutException("Timeout waiting for exclusive access");
}
catch (AbandonedMutexException)
{
try
{
hasHandle = mutex.WaitOne(5000, false);
if (hasHandle == false)
throw new TimeoutException("Timeout waiting for exclusive access");
}
catch (AbandonedMutexException)
{
#if DEBUG
Console.WriteLine("Mutex abandoned");
Console.WriteLine("Mutex abandoned");
#endif
hasHandle = true;
}
if (!Directory.Exists(PathTool.dir))
Directory.CreateDirectory(PathTool.dir);
FixXML();
string metaXML = XDocument.Load(PathTool.infoXML).Element("meta").Element("UpdateSource").Value;
online = Ping(metaXML);
hasHandle = true;
}
if (!Directory.Exists(PathTool.dir))
Directory.CreateDirectory(PathTool.dir);
FixXml();
string metaXml = XDocument.Load(PathTool.InfoXml).Element("meta").Element("UpdateSource").Value;
Online = Ping(metaXml);
#if !DEBUG
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")))
Shortcut.Make(PathTool.GetProgPath("Install", "UpTool2.exe"), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk"));
#endif
if (!Directory.Exists(PathTool.GetProgPath("Apps")))
Directory.CreateDirectory(PathTool.GetProgPath("Apps"));
if (!online || UpdateCheck(metaXML))
Application.Run(new MainForm());
if (!Directory.Exists(PathTool.GetRelative("Apps")))
Directory.CreateDirectory(PathTool.GetRelative("Apps"));
if (!Online || UpdateCheck(metaXml))
Application.Run(new MainForm());
#if !DEBUG
}
catch (Exception e1)
@ -96,12 +97,11 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
mutex.ReleaseMutex();
}
#endif
}
}
private static void ShowSplash()
{
splash = new Form
Splash = new Form
{
StartPosition = FormStartPosition.CenterScreen,
FormBorderStyle = FormBorderStyle.None,
@ -114,8 +114,8 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
ForeColor = Color.Green,
TopMost = true
};
splash.MaximumSize = splash.Size;
splash.MinimumSize = splash.Size;
Splash.MaximumSize = Splash.Size;
Splash.MinimumSize = Splash.Size;
Label splashL = new Label
{
AutoSize = false,
@ -124,101 +124,111 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
Text = "Loading",
Font = new Font(FontFamily.GenericSansSerif, 40)
};
splash.Controls.Add(splashL);
splash.Show();
splash.BringToFront();
Splash.Controls.Add(splashL);
Splash.Show();
Splash.BringToFront();
}
public static void FixXML(bool throwOnError = false)
public static void FixXml(bool throwOnError = false)
{
try
{
if ((!File.Exists(PathTool.infoXML)) || XDocument.Load(PathTool.infoXML).Element("meta") == null)
new XElement("meta").Save(PathTool.infoXML);
XDocument x = XDocument.Load(PathTool.infoXML);
if (!File.Exists(PathTool.InfoXml) || XDocument.Load(PathTool.InfoXml).Element("meta") == null)
new XElement("meta").Save(PathTool.InfoXml);
XDocument x = XDocument.Load(PathTool.InfoXml);
XElement meta = x.Element("meta");
if (meta.Element("UpdateSource") == null)
meta.Add(new XElement("UpdateSource"));
if (new string[] { "", "https://raw.githubusercontent.com/CreepyCrafter24/UpTool2/master/Meta.xml",
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Meta.xml" }
if (new[]
{
"", "https://raw.githubusercontent.com/CreepyCrafter24/UpTool2/master/Meta.xml",
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Meta.xml"
}
.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)
meta.Add(new XElement("Repos"));
if (meta.Element("Repos").Elements("Repo").Count() == 0)
meta.Element("Repos").Add(new XElement("Repo", new XElement("Name", "UpTool2 official Repo"), new XElement("Link", "https://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"))
.Where(s => new string[] { 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");
.Where(s => new[]
{
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)
meta.Add(new XElement("LocalRepo"));
x.Save(PathTool.infoXML);
x.Save(PathTool.InfoXml);
}
catch (XmlException)
{
if (throwOnError)
throw;
else
{
MessageBox.Show("Something went wrong while trying to parse XML. Retrying...");
File.Delete(PathTool.infoXML);
FixXML();
}
if (throwOnError) throw;
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");
if (Assembly.GetExecutingAssembly().GetName().Version < Version.Parse(meta.Element("Version").Value))
{
installUpdate(meta);
return false;
}
return true;
XElement meta = XDocument.Load(metaXml).Element("meta");
if (Assembly.GetExecutingAssembly().GetName().Version >= Version.Parse(meta.Element("Version").Value))
return true;
InstallUpdate(meta);
return false;
}
private static void installUpdate(XElement meta)
private static void InstallUpdate(XElement meta)
{
byte[] dl;
using (DownloadDialog dlg = new DownloadDialog(meta.Element("File").Value))
{
if (dlg.ShowDialog() != DialogResult.OK)
throw new Exception("Failed to update");
dl = dlg.result;
dl = dlg.Result;
}
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
{
string pkghash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).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());
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).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());
}
if (Directory.Exists(PathTool.GetProgPath("Install", "tmp")))
Directory.Delete(PathTool.GetProgPath("Install", "tmp"), true);
Directory.CreateDirectory(PathTool.GetProgPath("Install", "tmp"));
if (Directory.Exists(PathTool.GetRelative("Install", "tmp")))
Directory.Delete(PathTool.GetRelative("Install", "tmp"), true);
Directory.CreateDirectory(PathTool.GetRelative("Install", "tmp"));
using (MemoryStream ms = new MemoryStream(dl))
using (ZipArchive ar = new ZipArchive(ms))
{
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();
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") });
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.GetRelative("Install")
});
}
public static bool Ping(string url)
private static bool Ping(string url)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.Timeout = 3000;
request.AllowAutoRedirect = false;
request.Method = "HEAD";
using var response = request.GetResponse();
using WebResponse response = request.GetResponse();
return true;
}
catch

View File

@ -31,22 +31,21 @@
this.sourceGrid = new System.Windows.Forms.DataGridView();
this.sbName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.sbLink = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.sourceGrid)).BeginInit();
((System.ComponentModel.ISupportInitialize) (this.sourceGrid)).BeginInit();
this.SuspendLayout();
//
// sourceGrid
//
this.sourceGrid.BackgroundColor = System.Drawing.Color.White;
this.sourceGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.sourceGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.sbName,
this.sbLink});
this.sourceGrid.ColumnHeadersHeightSizeMode =
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.sourceGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {this.sbName, this.sbLink});
this.sourceGrid.Dock = System.Windows.Forms.DockStyle.Fill;
this.sourceGrid.GridColor = System.Drawing.Color.White;
this.sourceGrid.Location = new System.Drawing.Point(0, 0);
this.sourceGrid.MultiSelect = false;
this.sourceGrid.Name = "sourceGrid";
this.sourceGrid.Size = new System.Drawing.Size(800, 450);
this.sourceGrid.Size = new System.Drawing.Size(933, 519);
this.sourceGrid.TabIndex = 0;
//
// sbName
@ -54,20 +53,20 @@
this.sbName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
this.sbName.HeaderText = "Name";
this.sbName.Name = "sbName";
this.sbName.Width = 60;
this.sbName.Width = 64;
//
// sbLink
//
this.sbLink.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
this.sbLink.HeaderText = "Link";
this.sbLink.Name = "sbLink";
this.sbLink.Width = 52;
this.sbLink.Width = 54;
//
// 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.ClientSize = new System.Drawing.Size(800, 450);
this.ClientSize = new System.Drawing.Size(933, 519);
this.Controls.Add(this.sourceGrid);
this.Name = "SettingsForms";
this.ShowIcon = false;
@ -75,9 +74,8 @@
this.Text = "Sources";
this.TopMost = true;
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);
}
#endregion

View File

@ -1,5 +1,4 @@
using System.Linq;
using System.Windows.Forms;
using System.Windows.Forms;
using System.Xml.Linq;
using UpTool2.Tool;
@ -7,34 +6,29 @@ namespace UpTool2
{
public partial class SettingsForms : Form
{
private XDocument doc;
private XElement meta;
private XElement repos;
private readonly XDocument doc;
private readonly XElement meta;
private readonly XElement repos;
public SettingsForms()
{
InitializeComponent();
Program.FixXML();
doc = XDocument.Load(PathTool.infoXML);
Program.FixXml();
doc = XDocument.Load(PathTool.InfoXml);
meta = doc.Element("meta");
repos = meta.Element("Repos");
foreach (XElement repo in repos.Elements("Repo"))
{
sourceGrid.Rows.Add(repo.Element("Name").Value, repo.Element("Link").Value);
}
}
private void SettingsForms_FormClosing(object sender, FormClosingEventArgs e)
{
repos.RemoveNodes();
for (int y = 0; y < sourceGrid.Rows.Count; y++)
{
if (y + 1 < sourceGrid.Rows.Count)
{
repos.Add(new XElement("Repo", new XElement("Name", (string)sourceGrid.Rows[y].Cells[0].Value), new XElement("Link", (string)sourceGrid.Rows[y].Cells[1].Value)));
}
}
doc.Save(PathTool.infoXML);
repos.Add(new XElement("Repo", new XElement("Name", (string) sourceGrid.Rows[y].Cells[0].Value),
new XElement("Link", (string) sourceGrid.Rows[y].Cells[1].Value)));
doc.Save(PathTool.InfoXml);
}
}
}

View File

@ -5,7 +5,7 @@ using System.IO.Compression;
using System.Security.Cryptography;
using System.Windows.Forms;
using System.Xml.Linq;
using UpTool2.Data;
using UpTool2.DataStructures;
namespace UpTool2.Tool
{
@ -27,19 +27,20 @@ namespace UpTool2.Tool
if (Directory.Exists(app))
Directory.Delete(app, true);
Directory.CreateDirectory(app);
using DownloadDialog dlg = new DownloadDialog(appI.file);
using DownloadDialog dlg = new DownloadDialog(appI.File);
if (dlg.ShowDialog() != DialogResult.OK)
throw new Exception("Download failed");
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
{
string pkghash = BitConverter.ToString(sha256.ComputeHash(dlg.result)).Replace("-", string.Empty).ToUpper();
if (pkghash != appI.hash.ToUpper())
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dlg.Result)).Replace("-", string.Empty)
.ToUpper();
if (pkgHash != appI.Hash.ToUpper())
throw new Exception($@"The hash is not equal to the one stored in the repo:
Package: {pkghash}
Online: {appI.hash.ToUpper()}");
Package: {pkgHash}
Online: {appI.Hash.ToUpper()}");
}
File.WriteAllBytes(Path.Combine(app, "package.zip"), dlg.result);
completeInstall(appI);
File.WriteAllBytes(Path.Combine(app, "package.zip"), dlg.Result);
CompleteInstall(appI);
#if !DEBUG
}
catch
@ -58,7 +59,7 @@ Online: {appI.hash.ToUpper()}");
#endif
}
public static void installZip(string zipPath, App meta)
public static void InstallZip(string zipPath, App meta)
{
string app = "";
string tmp = "";
@ -70,8 +71,8 @@ Online: {appI.hash.ToUpper()}");
if (Directory.Exists(tmp))
Directory.Delete(tmp, true);
Directory.CreateDirectory(tmp);
File.Copy(zipPath, Path.Combine(app + "package.zip"));
completeInstall(meta);
File.Copy(zipPath, Path.Combine(app, "package.zip"));
CompleteInstall(meta);
}
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
try
{
#endif
string tmp = PathTool.tempPath;
ZipFile.ExtractToDirectory(Path.Combine(appPath + "package.zip"), tmp);
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));
ZipFile.ExtractToDirectory(Path.Combine(appPath, "package.zip"), tmp);
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));
if (mainFile != null)
el.Add(new XElement(new XElement("MainFile", mainFile)));
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();
if (GlobalVariables.relE)
GlobalVariables.reloadElements.Invoke();
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();
if (GlobalVariables.RelE)
GlobalVariables.ReloadElements.Invoke();
#if !DEBUG
}
catch { throw; }

View File

@ -16,7 +16,7 @@
if (disposing && (components != null))
{
components.Dispose();
client.Dispose();
_client.Dispose();
}
base.Dispose(disposing);
}
@ -57,7 +57,6 @@
this.Text = "Downloading...";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DownloadDialog_FormClosing);
this.ResumeLayout(false);
}
#endregion

View File

@ -6,19 +6,19 @@ namespace UpTool2.Tool
{
public partial class DownloadDialog : Form
{
private bool close;
private readonly WebClient client;
public byte[] result;
private readonly WebClient _client;
private bool _close;
public byte[] Result;
public DownloadDialog(string uri)
{
InitializeComponent();
try
{
client = new WebClient();
client.DownloadProgressChanged += progressChanged;
client.DownloadDataCompleted += done;
client.DownloadDataAsync(new Uri(uri), client);
_client = new WebClient();
_client.DownloadProgressChanged += ProgressChanged;
_client.DownloadDataCompleted += Done;
_client.DownloadDataAsync(new Uri(uri), _client);
}
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;
close = true;
result = e.Result;
_close = true;
Result = e.Result;
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;
}
}

View File

@ -6,17 +6,20 @@ namespace UpTool2.Tool
{
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 => GetProgPath("tmp");
public static string appsPath => GetProgPath("Apps");
public static string infoXML => GetProgPath("info.xml");
public static string tempPath => GetRelative("tmp");
public static string appsPath => GetRelative("Apps");
public static string InfoXml => GetRelative("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");
}
}

View File

@ -8,19 +8,20 @@ using System.Linq;
using System.Net;
using System.Windows.Forms;
using System.Xml.Linq;
using UpTool2.Data;
using UpTool2.DataStructures;
using UpTool2.Properties;
namespace UpTool2.Tool
{
internal static class RepoManagement
{
public static void fetchRepos()
public static void FetchRepos()
{
Program.FixXML();
XElement meta = XDocument.Load(PathTool.infoXML).Element("meta");
List<XElement> tmp_apps_list = new List<XElement>();
List<string> repArr = meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link").Value).Distinct().ToList();
Program.FixXml();
XElement meta = XDocument.Load(PathTool.InfoXml).Element("meta");
List<XElement> tmpAppsList = new List<XElement>();
List<string> repArr = meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link").Value).Distinct()
.ToList();
using (WebClient client = new WebClient())
{
int i = 0;
@ -31,30 +32,32 @@ namespace UpTool2.Tool
{
#endif
XDocument repo = XDocument.Load(repArr[i]);
repArr.AddRange(repo.Element("repo").Elements("repolink").Select(s => s.Value).Where(s => !repArr.Contains(s)));
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 ||
tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value)
.Where(a => a.Element("Version").getVer() >= app.Element("Version").getVer()).Count() == 0).ToArray()
.Concat(repo.Element("repo").Elements("applink").Select(s => XDocument.Load(s.Value).Element("app"))).ToArray();
repArr.AddRange(repo.Element("repo").Elements("repolink").Select(s => s.Value)
.Where(s => !repArr.Contains(s)));
XElement[] tmp_apparray = repo.Element("repo").Elements("app").Where(app =>
!tmpAppsList.Any(a => a.Element("ID").Value == app.Element("ID").Value) ||
!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++)
{
XElement app = tmp_apparray[i1];
//"Sanity check"
int.Parse(app.Element("Version").Value);
Version.Parse(app.Element("Version").Value);
Guid.Parse(app.Element("ID").Value);
//Create XElement
tmp_apps_list.Add(new XElement("App",
new XElement("Name", app.Element("Name").Value),
new XElement("Description", app.Element("Description").Value),
new XElement("Version", app.Element("Version").Value),
new XElement("ID", app.Element("ID").Value),
new XElement("File", app.Element("File").Value),
new XElement("Hash", app.Element("Hash").Value)
));
tmpAppsList.Add(new XElement("App",
new XElement("Name", app.Element("Name").Value),
new XElement("Description", app.Element("Description").Value),
new XElement("Version", app.Element("Version").Value),
new XElement("ID", app.Element("ID").Value),
new XElement("File", app.Element("File").Value),
new XElement("Hash", app.Element("Hash").Value)
));
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)
{
try
{
//Scale Image and save as Base64
@ -68,23 +71,23 @@ namespace UpTool2.Tool
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.SmoothingMode = SmoothingMode.HighQuality;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
using (var wrapMode = new ImageAttributes())
{
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
g.DrawImage(src, new Rectangle(0, 0, 70, 70), 0, 0, src.Width, src.Height, 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 ImageAttributes wrapMode = new ImageAttributes();
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
g.DrawImage(src, new Rectangle(0, 0, 70, 70), 0, 0, src.Width, src.Height,
GraphicsUnit.Pixel, wrapMode);
}
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)
tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value).Reverse().Skip(1).ToList().ForEach(a => tmp_apps_list.Remove(a));
if (tmpAppsList.Count(a => a.Element("ID").Value == app.Element("ID").Value) > 1)
tmpAppsList.Where(a => a.Element("ID").Value == app.Element("ID").Value).Reverse().Skip(1)
.ToList().ForEach(a => tmpAppsList.Remove(a));
}
#if !DEBUG
}
@ -96,64 +99,76 @@ namespace UpTool2.Tool
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)
meta.Add(new XElement("LocalRepo"));
XElement repos = meta.Element("LocalRepo");
repos.RemoveNodes();
tmp_apps_list.ForEach(app => repos.Add(app));
meta.Save(PathTool.infoXML);
tmpAppsList.ForEach(app => repos.Add(app));
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();
string xml = PathTool.infoXML;
GlobalVariables.Apps.Clear();
string xml = PathTool.InfoXml;
XDocument.Load(xml).Element("meta").Element("LocalRepo").Elements().ToList().ForEach(app =>
{
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;
if (int.TryParse(app.Element("Version").Value, out _))
app.Element("Version").Value = GlobalVariables.minimumVer.ToString();
GlobalVariables.apps.Add(id, new App(
name: locIn.Element("Name").Value,
description: locIn.Element("Description").Value,
version: Version.Parse(app.Element("Version").Value),
file: app.Element("File").Value,
local: false,
hash: app.Element("Hash").Value,
iD: id,
color: Color.White,
icon: app.Element("Icon") == null ? Resources.C_64.ToBitmap() : (Bitmap)new ImageConverter().ConvertFrom(Convert.FromBase64String(app.Element("Icon").Value)),
runnable: locIn.Element("MainFile") != null || app.Element("MainFile") != null,
mainFile: locIn.Element("MainFile") == null ? app.Element("MainFile") == null ? "" : app.Element("MainFile").Value : locIn.Element("MainFile").Value
));
GlobalVariables.Apps.Add(id, new App(
locIn.Element("Name").Value,
locIn.Element("Description").Value,
Version.Parse(app.Element("Version").Value),
app.Element("File").Value,
false,
app.Element("Hash").Value,
id,
Color.White,
app.Element("Icon") == null
? Resources.C_64.ToBitmap()
: (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
Console.WriteLine(locIn.Element("MainFile") == null ? "NULL" : locIn.Element("MainFile").Value);
Console.WriteLine(GlobalVariables.apps[id].mainFile);
Console.WriteLine(GlobalVariables.Apps[id].MainFile);
#endif
});
Directory.GetDirectories(PathTool.appsPath).Where(s => !GlobalVariables.apps.ContainsKey(Guid.Parse(Path.GetFileName(s)))).ToList().ForEach(s =>
{
Guid tmp = Guid.Parse(Path.GetFileName(s));
try
Directory.GetDirectories(PathTool.appsPath)
.Where(s => Guid.TryParse(Path.GetFileName(s), out Guid guid) && !GlobalVariables.Apps.ContainsKey(guid)).ToList().ForEach(s =>
{
XElement data = XDocument.Load(PathTool.getInfoPath(tmp)).Element("app");
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));
}
catch (Exception e)
{
if (MessageBox.Show($@"An error occured while loading this local repo:
Guid tmp = Guid.Parse(Path.GetFileName(s));
try
{
XElement data = XDocument.Load(PathTool.GetInfoPath(tmp)).Element("app");
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));
}
catch (Exception e)
{
if (MessageBox.Show($@"An error occured while loading this local repo:
{e.Message}
Do you want to exit? Otherwise the folder will be deleted, possibly causeing problems later.", "", MessageBoxButtons.YesNo) == DialogResult.No)
Directory.Delete(PathTool.getAppPath(tmp), true);
else
Environment.Exit(0);
}
});
Do you want to exit? Otherwise the folder will be deleted, possibly causeing problems later.", "",
MessageBoxButtons.YesNo) == DialogResult.No)
Directory.Delete(PathTool.GetAppPath(tmp), true);
else
Environment.Exit(0);
}
});
}
}
}

View File

@ -6,48 +6,116 @@ namespace UpTool2.Tool
{
internal static class Shortcut
{
private static Type m_type = Type.GetTypeFromProgID("WScript.Shell");
private static object m_shell = Activator.CreateInstance(m_type);
private static readonly Type MType = Type.GetTypeFromProgID("WScript.Shell");
private static readonly object MShell = Activator.CreateInstance(MType);
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.Save();
}
[ComImport, TypeLibType(0x1040), Guid("F935DC23-1CF0-11D0-ADB9-00C04FD58A0B")]
[ComImport]
[TypeLibType(0x1040)]
[Guid("F935DC23-1CF0-11D0-ADB9-00C04FD58A0B")]
private interface IWshShortcut
{
[DispId(0)]
string FullName { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0)] get; }
string FullName
{
[return: MarshalAs(UnmanagedType.BStr)]
[DispId(0)]
get;
}
[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)]
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)]
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)]
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)]
string RelativePath { [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ec)] set; }
string RelativePath
{
[param: In]
[param: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3ec)]
set;
}
[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)]
int WindowStyle { [DispId(0x3ee)] get; [param: In] [DispId(0x3ee)] set; }
[DispId(0x3ee)] int WindowStyle { [DispId(0x3ee)] get; [param: In] [DispId(0x3ee)] set; }
[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)]
void Load([In, MarshalAs(UnmanagedType.BStr)] string PathLink);
[TypeLibFunc(0x40)]
[DispId(0x7d0)]
void Load([In] [MarshalAs(UnmanagedType.BStr)] string pathLink);
[DispId(0x7d1)]
void Save();

View File

@ -9,11 +9,12 @@
<RootNamespace>UpTool2</RootNamespace>
<AssemblyName>UpTool2</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<LangVersion>preview</LangVersion>
<LangVersion>latest</LangVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>false</Deterministic>
<TargetFrameworkProfile />
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>