This commit is contained in:
Thomas G 2022-08-05 10:31:34 +10:00
parent 97448ac5fb
commit 5f2e2abdc6
5 changed files with 83 additions and 19 deletions

24
Form2.Designer.cs generated
View File

@ -75,47 +75,49 @@
this.pictureBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.pictureBox2.Image = global::ARCHBLOXBootstrapper.Properties.Resources.archblox;
this.pictureBox2.InitialImage = global::ARCHBLOXBootstrapper.Properties.Resources.archblox;
this.pictureBox2.Location = new System.Drawing.Point(3, 6);
this.pictureBox2.Location = new System.Drawing.Point(18, 17);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(46, 46);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox2.Size = new System.Drawing.Size(35, 42);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox2.TabIndex = 0;
this.pictureBox2.TabStop = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(55, 6);
this.label2.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label2.ImageAlign = System.Drawing.ContentAlignment.BottomLeft;
this.label2.Location = new System.Drawing.Point(58, 18);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(132, 14);
this.label2.Size = new System.Drawing.Size(237, 21);
this.label2.TabIndex = 1;
this.label2.Text = "Checking for updates...";
this.label2.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// progressBar2
//
this.progressBar2.Location = new System.Drawing.Point(55, 29);
this.progressBar2.Location = new System.Drawing.Point(58, 51);
this.progressBar2.MarqueeAnimationSpeed = 10;
this.progressBar2.Name = "progressBar2";
this.progressBar2.Size = new System.Drawing.Size(217, 23);
this.progressBar2.Size = new System.Drawing.Size(287, 26);
this.progressBar2.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
this.progressBar2.TabIndex = 2;
//
// ARCHBLOX
//
this.ClientSize = new System.Drawing.Size(286, 59);
this.ClientSize = new System.Drawing.Size(352, 136);
this.Controls.Add(this.progressBar2);
this.Controls.Add(this.label2);
this.Controls.Add(this.pictureBox2);
this.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ARCHBLOX";
this.Text = "ARCHBLOX Installer";
this.Text = "ARCHBLOX Studio";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}

View File

@ -14,6 +14,7 @@ namespace ARCHBLOXBootstrapper
{
// set up variables
public bool IsCompleted = false;
public bool exitafterarg = false;
public bool DontEvenBother = false;
private static WebClient wc = new WebClient();
private static ManualResetEvent handle = new ManualResetEvent(true);
@ -33,14 +34,27 @@ namespace ARCHBLOXBootstrapper
public ARCHBLOX()
{
InitializeComponent();
// check for an internet connection first
try
{
wc.DownloadData("http://archblox.com/studio/version.txt");
}
catch
{
MessageBox.Show("An error occoured while starting ARCHBLOX Studio\n\nDetails: HttpOpenRequest failed for GET http://archblox.com/studio/version.txt, Error ID: 6", "ARCHBLOX", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(0);
}
// setup paths
byte[] raw = wc.DownloadData("https://archblox.com/studio/version.txt");
byte[] raw = wc.DownloadData("http://archblox.com/studio/version.txt");
string webData = Encoding.UTF8.GetString(raw);
string version_string = webData;
string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Archblx\", @"Studio\", @"Versions\");
string clientPath = Path.Combine(folderPath, version_string + @"\");
string filePath = Path.Combine(clientPath, Path.GetFileName(@"https://archblox.com/client/" + version_string + ".zip"));
string filePath = Path.Combine(clientPath, Path.GetFileName(@"http://archblox.com/client/" + version_string + ".zip"));
string studioPath = Path.Combine(clientPath, "ArchbloxStudio.exe");
ARCHBLOXProtocol.ARCHBLOXURIProtocol.Register();
CreateShortcut();
// TODO: Make studio place launching URI.
if (Directory.Exists(clientPath) & System.IO.File.Exists(studioPath))
{
// studio exists, create shortcut and launch studio
@ -69,14 +83,12 @@ namespace ARCHBLOXBootstrapper
wc.DownloadProgressChanged += Client_DownloadProgressChanged;
wc.DownloadFileCompleted += Client_DownloadFileCompleted;
progressBar2.Style = ProgressBarStyle.Marquee;
wc.DownloadProgressChanged += Client_DownloadProgressChanged;
wc.DownloadFileCompleted += Client_DownloadFileCompleted;
if (DontEvenBother == false)
{
// install studio
label2.Text = "Configuring ARCHBLOX...";
Directory.CreateDirectory(clientPath);
wc.DownloadFileAsync(new Uri(@"https://archblox.com/studio/" + version_string + ".zip"), filePath);
wc.DownloadFileAsync(new Uri(@"http://archblox.com/studio/" + version_string + ".zip"), filePath);
progressBar2.Style = ProgressBarStyle.Blocks;
handle.WaitOne();
} else
@ -97,12 +109,12 @@ namespace ARCHBLOXBootstrapper
{
// the download has completed, extract.zip, create shortcut and launch!
IsCompleted = true;
byte[] raw = wc.DownloadData("https://archblox.com/studio/version.txt");
byte[] raw = wc.DownloadData("http://archblox.com/studio/version.txt");
string webData = Encoding.UTF8.GetString(raw);
string version_string = webData;
string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Archblx\", @"Studio\", @"Versions\");
string clientPath = Path.Combine(folderPath, version_string + @"\");
string filePath = Path.Combine(clientPath, Path.GetFileName(@"https://archblox.com/studio/" + version_string + ".zip"));
string filePath = Path.Combine(clientPath, Path.GetFileName(@"http://archblox.com/studio/" + version_string + ".zip"));
string studioPath = Path.Combine(clientPath, "ArchbloxStudio.exe");
ZipFile.ExtractToDirectory(filePath, clientPath);
System.IO.File.Delete(filePath);

View File

@ -12,11 +12,18 @@ namespace ARCHBLOXBootstrapper
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
static void Main(string[] args)
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args.Length > 0)
{
foreach (string s in args)
{
ARCHBLOXProtocol.SharedVariables.Arguments = s;
}
}
Application.Run(new ARCHBLOX());
}
}

BIN
Resources/Thumbs.db Normal file

Binary file not shown.

43
URI_Maker.cs Normal file
View File

@ -0,0 +1,43 @@
using System;
using System.Windows.Forms;
using System.Security.Permissions;
using Microsoft.Win32;
using System.Text;
using System.Net;
using System.IO;
namespace ARCHBLOXProtocol
{
class SharedVariables
{
public static string Arguments = "";
};
internal static class ARCHBLOXURIProtocol
{
private static RegistryKey softwareClasses = Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Classes", true);
internal static void Register()
{
// credit to p0s0 for helping me with this
if (softwareClasses.OpenSubKey("archbloxstudio") == null) {} else { softwareClasses.DeleteSubKeyTree("archbloxstudio"); }
RegistryKey key = softwareClasses.CreateSubKey("archbloxstudio", true);
key.SetValue("", "URL: archbloxstudio Protocol");
key.SetValue("URL Protocol", "");
RegistryKey key1 = key.CreateSubKey("DefaultIcon", true);
key1.SetValue("", ARCHBLOXBootstrapper.Extensions.GetExecutablePath());
RegistryKey key2 = key.CreateSubKey("shell", true);
RegistryKey key3 = key2.CreateSubKey("open", true);
RegistryKey key4 = key3.CreateSubKey("command", true);
key4.SetValue("", "\"" + ARCHBLOXBootstrapper.Extensions.GetExecutablePath() + "\" %1");
key.Close();
key1.Close();
key2.Close();
key3.Close();
key4.Close();
}
}
}