Fancier splash
This commit is contained in:
parent
8fff6b1500
commit
217a088f1e
|
@ -23,12 +23,13 @@
|
|||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InstallerForm));
|
||||
System.ComponentModel.ComponentResourceManager resources =
|
||||
new System.ComponentModel.ComponentResourceManager(typeof(InstallerForm));
|
||||
this.install = new System.Windows.Forms.Button();
|
||||
this.installLabel = new System.Windows.Forms.Label();
|
||||
this.progress = new System.Windows.Forms.ProgressBar();
|
||||
|
@ -38,8 +39,10 @@
|
|||
//
|
||||
// install
|
||||
//
|
||||
this.install.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.install.Anchor =
|
||||
((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Bottom |
|
||||
System.Windows.Forms.AnchorStyles.Left) |
|
||||
System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.install.Location = new System.Drawing.Point(12, 92);
|
||||
this.install.Name = "install";
|
||||
this.install.Size = new System.Drawing.Size(539, 27);
|
||||
|
@ -59,8 +62,10 @@
|
|||
//
|
||||
// progress
|
||||
//
|
||||
this.progress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.progress.Anchor =
|
||||
((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Bottom |
|
||||
System.Windows.Forms.AnchorStyles.Left) |
|
||||
System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.progress.Location = new System.Drawing.Point(12, 92);
|
||||
this.progress.Maximum = 6;
|
||||
this.progress.Name = "progress";
|
||||
|
@ -79,8 +84,10 @@
|
|||
//
|
||||
// log
|
||||
//
|
||||
this.log.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.log.Location = new System.Drawing.Point(524, 4);
|
||||
this.log.Anchor =
|
||||
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
||||
System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.log.Location = new System.Drawing.Point(524, 3);
|
||||
this.log.Name = "log";
|
||||
this.log.Size = new System.Drawing.Size(36, 23);
|
||||
this.log.TabIndex = 4;
|
||||
|
@ -93,7 +100,7 @@
|
|||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(563, 131);
|
||||
this.ClientSize = new System.Drawing.Size(563, 132);
|
||||
this.Controls.Add(this.log);
|
||||
this.Controls.Add(this.processLabel);
|
||||
this.Controls.Add(this.progress);
|
||||
|
@ -105,7 +112,6 @@
|
|||
this.Text = "UpTool2 Installer";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1,5 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace UpTool2
|
|||
filterBox.Enabled = false;
|
||||
filterBox.SelectedIndex = 2;
|
||||
}
|
||||
Program.SetSplash(8, "Reloading data");
|
||||
ReloadElements();
|
||||
if (!Directory.Exists(PathTool.appsPath))
|
||||
Directory.CreateDirectory(PathTool.appsPath);
|
||||
|
@ -258,8 +259,15 @@ namespace UpTool2
|
|||
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
Program.Splash.Hide();
|
||||
BringToFront();
|
||||
if (Program.Splash.IsDisposed)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.Splash.Invoke((Action)Program.Splash.Hide);
|
||||
BringToFront();
|
||||
}
|
||||
}
|
||||
|
||||
private static DateTime GetBuildDateTime(Assembly assembly)
|
||||
|
@ -297,7 +305,7 @@ namespace UpTool2
|
|||
try
|
||||
{
|
||||
DateTime buildTime = GetBuildDateTime(Assembly.GetExecutingAssembly());
|
||||
MessageBox.Show($@"UpTool2 by CC24
|
||||
MessageBox.Show($@"UpTool2 by JFronny
|
||||
Version: {Assembly.GetExecutingAssembly().GetName().Version}
|
||||
Build Date: {buildTime:dd.MM.yyyy}", "UpTool2");
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ namespace UpTool2
|
|||
internal static class Program
|
||||
{
|
||||
public static Form Splash;
|
||||
private static int SplashProgress;
|
||||
private static string SplashMessage;
|
||||
public static bool Online;
|
||||
|
||||
[STAThread]
|
||||
|
@ -26,7 +28,8 @@ namespace UpTool2
|
|||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
ShowSplash();
|
||||
BuildSplash();
|
||||
new Thread(() => { Splash.ShowDialog(); }).Start();
|
||||
using Mutex mutex = new Mutex(false,
|
||||
$"Global\\{{{((GuidAttribute) Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value}}}",
|
||||
out bool _);
|
||||
|
@ -54,9 +57,11 @@ namespace UpTool2
|
|||
#endif
|
||||
hasHandle = true;
|
||||
}
|
||||
SetSplash(1, "Initializing paths");
|
||||
if (!Directory.Exists(PathTool.dir))
|
||||
Directory.CreateDirectory(PathTool.dir);
|
||||
FixXml();
|
||||
SetSplash(2, "Performing checks");
|
||||
string metaXml = XDocument.Load(PathTool.InfoXml).Element("meta").Element("UpdateSource").Value;
|
||||
Online = Ping(metaXml);
|
||||
if (Application.ExecutablePath != PathTool.GetRelative("Install", "UpTool2.dll"))
|
||||
|
@ -64,12 +69,22 @@ namespace UpTool2
|
|||
$"WARNING!{Environment.NewLine}Running from outside the install directory is not recommended!");
|
||||
if (!Directory.Exists(PathTool.GetRelative("Apps")))
|
||||
Directory.CreateDirectory(PathTool.GetRelative("Apps"));
|
||||
if (!Online)
|
||||
SetSplash(7, "Opening");
|
||||
if (!Online || UpdateCheck(metaXml))
|
||||
Application.Run(new MainForm());
|
||||
#if !DEBUG
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
try
|
||||
{
|
||||
Splash.Hide();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Failed to hide splash");
|
||||
}
|
||||
MessageBox.Show(e1.ToString());
|
||||
}
|
||||
finally
|
||||
|
@ -80,7 +95,7 @@ namespace UpTool2
|
|||
#endif
|
||||
}
|
||||
|
||||
private static void ShowSplash()
|
||||
private static void BuildSplash()
|
||||
{
|
||||
Splash = new Form
|
||||
{
|
||||
|
@ -92,24 +107,73 @@ namespace UpTool2
|
|||
ShowIcon = false,
|
||||
ShowInTaskbar = false,
|
||||
Size = new Size(700, 400),
|
||||
ForeColor = Color.Green,
|
||||
TopMost = true
|
||||
BackColor = Color.Black
|
||||
};
|
||||
Splash.MaximumSize = Splash.Size;
|
||||
Splash.MinimumSize = Splash.Size;
|
||||
Label splashL = new Label
|
||||
Splash.Paint += (sender, e) =>
|
||||
{
|
||||
AutoSize = false,
|
||||
Dock = DockStyle.Fill,
|
||||
TextAlign = ContentAlignment.MiddleCenter,
|
||||
Text = "Loading",
|
||||
Font = new Font(FontFamily.GenericSansSerif, 40)
|
||||
Graphics g = e.Graphics;
|
||||
//Draw background
|
||||
Brush[] brushes = {Brushes.Purple, Brushes.MediumPurple, Brushes.Indigo, Brushes.Fuchsia, Brushes.OrangeRed};
|
||||
const int barWidth = 50;
|
||||
const int topOffset = 100;
|
||||
for (int i = 0; i < Splash.Width + topOffset; i += barWidth)
|
||||
{
|
||||
g.FillPolygon(brushes[(i / barWidth) % brushes.Length], new []
|
||||
{
|
||||
new PointF(i, 0),
|
||||
new PointF(i + barWidth, 0),
|
||||
new PointF(i, Splash.Height),
|
||||
new PointF(i - topOffset, Splash.Height)
|
||||
});
|
||||
}
|
||||
//Draw Text: UpTool2 (by JFronny)^
|
||||
Font font = new Font(FontFamily.GenericSansSerif, 40, FontStyle.Bold);
|
||||
const string text = "UpTool2";
|
||||
SizeF size = g.MeasureString(text, font);
|
||||
RectangleF rect = new RectangleF((Splash.Width / 2f) - (size.Width / 2), (Splash.Height / 2f) - (size.Height / 2), size.Width, size.Height);
|
||||
g.DrawString(text, font, Brushes.White, rect);
|
||||
Font smallFont = new Font(FontFamily.GenericSansSerif, 10);
|
||||
const string subtitle = "by JFronny";
|
||||
SizeF size2 = g.MeasureString(subtitle, smallFont);
|
||||
g.DrawString(subtitle, smallFont, Brushes.White, new RectangleF(rect.Right - size2.Width, rect.Bottom - size2.Height, size2.Width, size2.Height));
|
||||
//Draw progress bar
|
||||
Rectangle bar = new Rectangle((3 * Splash.Width) / 8, ((Splash.Height * 3) / 4) - 10, Splash.Width / 4, 20);
|
||||
g.FillRectangle(Brushes.Gray, bar);
|
||||
g.FillRectangle(Brushes.Black, new Rectangle(bar.X, bar.Y, (bar.Width * SplashProgress) / 10, bar.Height));
|
||||
g.DrawRectangle(Pens.DimGray, bar);
|
||||
//g.DrawString(SplashMessage, smallFont, Brushes.White, new PointF(bar.Left, bar.Bottom));
|
||||
g.DrawString(SplashMessage, smallFont, Brushes.White, bar, new StringFormat {Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center});
|
||||
};
|
||||
Splash.Controls.Add(splashL);
|
||||
Splash.Show();
|
||||
Splash.BringToFront();
|
||||
int xOff = 0;
|
||||
int yOff = 0;
|
||||
bool moving = false;
|
||||
Splash.MouseDown += (sender, e) =>
|
||||
{
|
||||
moving = true;
|
||||
xOff = e.X;
|
||||
yOff = e.Y;
|
||||
};
|
||||
Splash.MouseUp += (sender, e) => moving = false;
|
||||
Splash.MouseMove += (sender, e) =>
|
||||
{
|
||||
if (!moving) return;
|
||||
Splash.Left = Cursor.Position.X - xOff;
|
||||
Splash.Top = Cursor.Position.Y - yOff;
|
||||
};
|
||||
Splash.Load += (sender, e) => Splash.BringToFront();
|
||||
Splash.FormClosed += (sender, e) => Splash.Dispose();
|
||||
}
|
||||
|
||||
public static void SetSplash(int progress, string status) => Splash.Invoke(new Action(() =>
|
||||
{
|
||||
SplashProgress = progress;
|
||||
Console.WriteLine(status);
|
||||
SplashMessage = status;
|
||||
Splash.Invoke((Action) Splash.Invalidate);
|
||||
}));
|
||||
|
||||
public static void FixXml(bool throwOnError = false)
|
||||
{
|
||||
try
|
||||
|
@ -160,16 +224,19 @@ namespace UpTool2
|
|||
|
||||
private static bool UpdateCheck(string metaXml)
|
||||
{
|
||||
SetSplash(3, "Comparing online version");
|
||||
XElement meta = XDocument.Load(metaXml).Element("meta");
|
||||
if (Assembly.GetExecutingAssembly().GetName().Version >= Version.Parse(meta.Element("Version").Value))
|
||||
return true;
|
||||
byte[] dl;
|
||||
SetSplash(4, "Downloading latest");
|
||||
using (DownloadDialog dlg = new DownloadDialog(meta.Element("File").Value))
|
||||
{
|
||||
if (dlg.ShowDialog() != DialogResult.OK)
|
||||
throw new Exception("Failed to update");
|
||||
dl = dlg.Result;
|
||||
}
|
||||
SetSplash(8, "Verifying");
|
||||
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
|
||||
{
|
||||
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
|
||||
|
@ -177,6 +244,7 @@ namespace UpTool2
|
|||
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());
|
||||
}
|
||||
SetSplash(9, "Installing");
|
||||
if (Directory.Exists(PathTool.GetRelative("Install", "tmp")))
|
||||
Directory.Delete(PathTool.GetRelative("Install", "tmp"), true);
|
||||
Directory.CreateDirectory(PathTool.GetRelative("Install", "tmp"));
|
||||
|
|
Reference in New Issue