Added download/install log coloring
This commit is contained in:
parent
37d7efc36e
commit
a50eafb689
5 changed files with 64 additions and 39 deletions
|
@ -6,7 +6,7 @@
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ApplicationIcon>ini.ico</ApplicationIcon>
|
<ApplicationIcon>ini.ico</ApplicationIcon>
|
||||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||||
<Version>1.0.2</Version>
|
<Version>1.0.3</Version>
|
||||||
<PackageIcon>ini.ico</PackageIcon>
|
<PackageIcon>ini.ico</PackageIcon>
|
||||||
<PackageIconUrl />
|
<PackageIconUrl />
|
||||||
<Description>Automatically downloads and installs CreamAPI files for programs/games.</Description>
|
<Description>Automatically downloads and installs CreamAPI files for programs/games.</Description>
|
||||||
|
|
39
CreamInstaller/InstallForm.Designer.cs
generated
39
CreamInstaller/InstallForm.Designer.cs
generated
|
@ -32,10 +32,10 @@ namespace CreamInstaller
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InstallForm));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InstallForm));
|
||||||
this.userProgressBar = new System.Windows.Forms.ProgressBar();
|
this.userProgressBar = new System.Windows.Forms.ProgressBar();
|
||||||
this.userInfoLabel = new System.Windows.Forms.Label();
|
this.userInfoLabel = new System.Windows.Forms.Label();
|
||||||
this.logTextBox = new System.Windows.Forms.TextBox();
|
|
||||||
this.acceptButton = new System.Windows.Forms.Button();
|
this.acceptButton = new System.Windows.Forms.Button();
|
||||||
this.retryButton = new System.Windows.Forms.Button();
|
this.retryButton = new System.Windows.Forms.Button();
|
||||||
this.cancelButton = new System.Windows.Forms.Button();
|
this.cancelButton = new System.Windows.Forms.Button();
|
||||||
|
this.logTextBox = new System.Windows.Forms.RichTextBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// userProgressBar
|
// userProgressBar
|
||||||
|
@ -57,22 +57,6 @@ namespace CreamInstaller
|
||||||
this.userInfoLabel.TabIndex = 2;
|
this.userInfoLabel.TabIndex = 2;
|
||||||
this.userInfoLabel.Text = "Loading . . . ";
|
this.userInfoLabel.Text = "Loading . . . ";
|
||||||
//
|
//
|
||||||
// logTextBox
|
|
||||||
//
|
|
||||||
this.logTextBox.AcceptsReturn = true;
|
|
||||||
this.logTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.logTextBox.Location = new System.Drawing.Point(12, 56);
|
|
||||||
this.logTextBox.Multiline = true;
|
|
||||||
this.logTextBox.Name = "logTextBox";
|
|
||||||
this.logTextBox.ReadOnly = true;
|
|
||||||
this.logTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
|
||||||
this.logTextBox.Size = new System.Drawing.Size(460, 164);
|
|
||||||
this.logTextBox.TabIndex = 3;
|
|
||||||
this.logTextBox.TabStop = false;
|
|
||||||
this.logTextBox.WordWrap = false;
|
|
||||||
//
|
|
||||||
// acceptButton
|
// acceptButton
|
||||||
//
|
//
|
||||||
this.acceptButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.acceptButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
@ -108,14 +92,30 @@ namespace CreamInstaller
|
||||||
this.cancelButton.UseVisualStyleBackColor = true;
|
this.cancelButton.UseVisualStyleBackColor = true;
|
||||||
this.cancelButton.Click += new System.EventHandler(this.OnCancel);
|
this.cancelButton.Click += new System.EventHandler(this.OnCancel);
|
||||||
//
|
//
|
||||||
|
// logTextBox
|
||||||
|
//
|
||||||
|
this.logTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.logTextBox.HideSelection = false;
|
||||||
|
this.logTextBox.Location = new System.Drawing.Point(12, 56);
|
||||||
|
this.logTextBox.Name = "logTextBox";
|
||||||
|
this.logTextBox.ReadOnly = true;
|
||||||
|
this.logTextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedBoth;
|
||||||
|
this.logTextBox.Size = new System.Drawing.Size(460, 164);
|
||||||
|
this.logTextBox.TabIndex = 4;
|
||||||
|
this.logTextBox.TabStop = false;
|
||||||
|
this.logTextBox.Text = "";
|
||||||
|
this.logTextBox.WordWrap = false;
|
||||||
|
//
|
||||||
// InstallForm
|
// InstallForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
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(484, 261);
|
this.ClientSize = new System.Drawing.Size(484, 261);
|
||||||
|
this.Controls.Add(this.logTextBox);
|
||||||
this.Controls.Add(this.cancelButton);
|
this.Controls.Add(this.cancelButton);
|
||||||
this.Controls.Add(this.retryButton);
|
this.Controls.Add(this.retryButton);
|
||||||
this.Controls.Add(this.logTextBox);
|
|
||||||
this.Controls.Add(this.acceptButton);
|
this.Controls.Add(this.acceptButton);
|
||||||
this.Controls.Add(this.userProgressBar);
|
this.Controls.Add(this.userProgressBar);
|
||||||
this.Controls.Add(this.userInfoLabel);
|
this.Controls.Add(this.userInfoLabel);
|
||||||
|
@ -131,17 +131,16 @@ namespace CreamInstaller
|
||||||
this.TopMost = true;
|
this.TopMost = true;
|
||||||
this.Load += new System.EventHandler(this.OnLoad);
|
this.Load += new System.EventHandler(this.OnLoad);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
private System.Windows.Forms.ProgressBar userProgressBar;
|
private System.Windows.Forms.ProgressBar userProgressBar;
|
||||||
private System.Windows.Forms.Label userInfoLabel;
|
private System.Windows.Forms.Label userInfoLabel;
|
||||||
private System.Windows.Forms.TextBox logTextBox;
|
|
||||||
private System.Windows.Forms.Button acceptButton;
|
private System.Windows.Forms.Button acceptButton;
|
||||||
private System.Windows.Forms.Button retryButton;
|
private System.Windows.Forms.Button retryButton;
|
||||||
private System.Windows.Forms.Button cancelButton;
|
private System.Windows.Forms.Button cancelButton;
|
||||||
|
private System.Windows.Forms.RichTextBox logTextBox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Threading;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace CreamInstaller
|
namespace CreamInstaller
|
||||||
{
|
{
|
||||||
|
@ -17,6 +18,7 @@ namespace CreamInstaller
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Program.InstallForm = this;
|
Program.InstallForm = this;
|
||||||
Text = Program.ApplicationName;
|
Text = Program.ApplicationName;
|
||||||
|
logTextBox.BackColor = LogColor.Background;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateProgress(int progress)
|
public void UpdateProgress(int progress)
|
||||||
|
@ -24,16 +26,14 @@ namespace CreamInstaller
|
||||||
Program.UpdateProgressInstantly(userProgressBar, progress);
|
Program.UpdateProgressInstantly(userProgressBar, progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateUser(string text, bool log = true)
|
public void UpdateUser(string text, Color color, bool log = true)
|
||||||
{
|
{
|
||||||
userInfoLabel.Text = text;
|
userInfoLabel.Text = text;
|
||||||
if (log && !logTextBox.IsDisposed)
|
if (log && !logTextBox.IsDisposed)
|
||||||
{
|
{
|
||||||
if (logTextBox.Text.Length > 0)
|
if (logTextBox.Text.Length > 0)
|
||||||
{
|
logTextBox.AppendText(Environment.NewLine, color);
|
||||||
logTextBox.AppendText(Environment.NewLine);
|
logTextBox.AppendText(userInfoLabel.Text, color);
|
||||||
}
|
|
||||||
logTextBox.AppendText(userInfoLabel.Text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ namespace CreamInstaller
|
||||||
Program.Cleanup(cancel: false, logout: false);
|
Program.Cleanup(cancel: false, logout: false);
|
||||||
|
|
||||||
UpdateProgress(0);
|
UpdateProgress(0);
|
||||||
UpdateUser("Downloading CreamAPI files for " + selection.ProgramName + " . . . ");
|
UpdateUser("Downloading CreamAPI files for " + selection.ProgramName + " . . . ", LogColor.Operation);
|
||||||
Program.OutputFile = selection.ProgramDirectory + "\\" + selection.DownloadNode.Name;
|
Program.OutputFile = selection.ProgramDirectory + "\\" + selection.DownloadNode.Name;
|
||||||
if (File.Exists(Program.OutputFile))
|
if (File.Exists(Program.OutputFile))
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,7 @@ namespace CreamInstaller
|
||||||
{
|
{
|
||||||
if (!Program.Canceled)
|
if (!Program.Canceled)
|
||||||
{
|
{
|
||||||
UpdateUser($"Downloading CreamAPI files for {selection.ProgramName} . . . {(int)progress}%", log: false);
|
UpdateUser($"Downloading CreamAPI files for {selection.ProgramName} . . . {(int)progress}%", LogColor.Operation, log: false);
|
||||||
UpdateProgress((int)progress);
|
UpdateProgress((int)progress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -74,7 +74,7 @@ namespace CreamInstaller
|
||||||
UpdateProgress(100);
|
UpdateProgress(100);
|
||||||
|
|
||||||
UpdateProgress(0);
|
UpdateProgress(0);
|
||||||
UpdateUser("Searching for CreamAPI files in downloaded archive . . . ");
|
UpdateUser("Searching for CreamAPI files in downloaded archive . . . ", LogColor.Operation);
|
||||||
string resourcePath = null;
|
string resourcePath = null;
|
||||||
List<ZipArchiveEntry> resources = new List<ZipArchiveEntry>();
|
List<ZipArchiveEntry> resources = new List<ZipArchiveEntry>();
|
||||||
Program.OutputArchive = ZipFile.OpenRead(Program.OutputFile);
|
Program.OutputArchive = ZipFile.OpenRead(Program.OutputFile);
|
||||||
|
@ -85,7 +85,7 @@ namespace CreamInstaller
|
||||||
if (entry.Name == "steam_api64.dll")
|
if (entry.Name == "steam_api64.dll")
|
||||||
{
|
{
|
||||||
resourcePath = Path.GetDirectoryName(entry.FullName);
|
resourcePath = Path.GetDirectoryName(entry.FullName);
|
||||||
UpdateUser("Got CreamAPI file path: " + resourcePath);
|
UpdateUser("Got CreamAPI file path: " + resourcePath, LogColor.Resource);
|
||||||
}
|
}
|
||||||
UpdateProgress((currentEntryCount / (Program.OutputArchive.Entries.Count * 2)) * 100);
|
UpdateProgress((currentEntryCount / (Program.OutputArchive.Entries.Count * 2)) * 100);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ namespace CreamInstaller
|
||||||
if (!string.IsNullOrEmpty(entry.Name) && Path.GetDirectoryName(entry.FullName) == resourcePath)
|
if (!string.IsNullOrEmpty(entry.Name) && Path.GetDirectoryName(entry.FullName) == resourcePath)
|
||||||
{
|
{
|
||||||
resources.Add(entry);
|
resources.Add(entry);
|
||||||
UpdateUser("Found CreamAPI file: " + entry.Name);
|
UpdateUser("Found CreamAPI file: " + entry.Name, LogColor.Resource);
|
||||||
}
|
}
|
||||||
UpdateProgress((currentEntryCount / (Program.OutputArchive.Entries.Count * 2)) * 100);
|
UpdateProgress((currentEntryCount / (Program.OutputArchive.Entries.Count * 2)) * 100);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ namespace CreamInstaller
|
||||||
UpdateProgress(100);
|
UpdateProgress(100);
|
||||||
|
|
||||||
UpdateProgress(0);
|
UpdateProgress(0);
|
||||||
UpdateUser("Installing CreamAPI files for " + selection.ProgramName + " . . . ");
|
UpdateUser("Installing CreamAPI files for " + selection.ProgramName + " . . . ", LogColor.Operation);
|
||||||
int currentFileCount = 0;
|
int currentFileCount = 0;
|
||||||
foreach (string directory in selection.SteamApiDllDirectories)
|
foreach (string directory in selection.SteamApiDllDirectories)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +114,7 @@ namespace CreamInstaller
|
||||||
{
|
{
|
||||||
currentFileCount++;
|
currentFileCount++;
|
||||||
string file = directory + "\\" + entry.Name;
|
string file = directory + "\\" + entry.Name;
|
||||||
UpdateUser(file);
|
UpdateUser(file, LogColor.Resource);
|
||||||
if (File.Exists(file))
|
if (File.Exists(file))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -132,7 +132,7 @@ namespace CreamInstaller
|
||||||
}
|
}
|
||||||
UpdateProgress(100);
|
UpdateProgress(100);
|
||||||
|
|
||||||
UpdateUser("CreamAPI successfully downloaded and installed for " + selection.ProgramName);
|
UpdateUser("CreamAPI successfully downloaded and installed for " + selection.ProgramName, LogColor.Success);
|
||||||
Program.ProgramSelections.Remove(selection);
|
Program.ProgramSelections.Remove(selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,12 +149,12 @@ namespace CreamInstaller
|
||||||
{
|
{
|
||||||
await Install();
|
await Install();
|
||||||
Program.Cleanup();
|
Program.Cleanup();
|
||||||
UpdateUser("CreamAPI successfully downloaded and installed for " + ProgramCount + " program(s)");
|
UpdateUser("CreamAPI successfully downloaded and installed for " + ProgramCount + " program(s)", LogColor.Success);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
Program.Cleanup(logout: false);
|
Program.Cleanup(logout: false);
|
||||||
UpdateUser("Operation failed: " + exception.Message);
|
UpdateUser("Operation failed: " + exception.Message, LogColor.Error);
|
||||||
retryButton.Enabled = true;
|
retryButton.Enabled = true;
|
||||||
}
|
}
|
||||||
acceptButton.Enabled = true;
|
acceptButton.Enabled = true;
|
||||||
|
|
25
CreamInstaller/LogColor.cs
Normal file
25
CreamInstaller/LogColor.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace CreamInstaller
|
||||||
|
{
|
||||||
|
public static class LogColor
|
||||||
|
{
|
||||||
|
public static Color Background => Color.DarkSlateGray;
|
||||||
|
public static Color Operation => Color.LightGray;
|
||||||
|
public static Color Resource => Color.LightBlue;
|
||||||
|
public static Color Success => Color.LightGreen;
|
||||||
|
public static Color Cleanup => Color.YellowGreen;
|
||||||
|
public static Color Warning => Color.Yellow;
|
||||||
|
public static Color Error => Color.DarkOrange;
|
||||||
|
|
||||||
|
public static void AppendText(this RichTextBox logTextBox, string text, Color color)
|
||||||
|
{
|
||||||
|
logTextBox.SelectionStart = logTextBox.TextLength;
|
||||||
|
logTextBox.SelectionLength = 0;
|
||||||
|
logTextBox.SelectionColor = color;
|
||||||
|
logTextBox.AppendText(text);
|
||||||
|
logTextBox.SelectionColor = logTextBox.ForeColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -75,7 +75,7 @@ namespace CreamInstaller
|
||||||
if (OutputArchive != null || CancellationTokenSource != null || OutputTask != null || OutputFile != null)
|
if (OutputArchive != null || CancellationTokenSource != null || OutputTask != null || OutputFile != null)
|
||||||
{
|
{
|
||||||
InstallForm?.UpdateProgress(0);
|
InstallForm?.UpdateProgress(0);
|
||||||
InstallForm?.UpdateUser("Cleaning up . . . ");
|
InstallForm?.UpdateUser("Cleaning up . . . ", LogColor.Cleanup);
|
||||||
}
|
}
|
||||||
if (OutputArchive != null)
|
if (OutputArchive != null)
|
||||||
{
|
{
|
||||||
|
@ -113,15 +113,16 @@ namespace CreamInstaller
|
||||||
}
|
}
|
||||||
catch (UnauthorizedAccessException)
|
catch (UnauthorizedAccessException)
|
||||||
{
|
{
|
||||||
InstallForm?.UpdateUser($"WARNING: Couldn't clean up downloaded archive ({OutputFile})");
|
InstallForm?.UpdateUser($"WARNING: Couldn't clean up downloaded archive ({OutputFile})", LogColor.Warning);
|
||||||
}
|
}
|
||||||
|
InstallForm?.UpdateUser($"WARNING: Couldn't clean up downloaded archive ({OutputFile})", LogColor.Warning);
|
||||||
OutputFile = null;
|
OutputFile = null;
|
||||||
}
|
}
|
||||||
InstallForm?.UpdateProgress(100);
|
InstallForm?.UpdateProgress(100);
|
||||||
if (logout && MegaApiClient != null && MegaApiClient.IsLoggedIn)
|
if (logout && MegaApiClient != null && MegaApiClient.IsLoggedIn)
|
||||||
{
|
{
|
||||||
InstallForm?.UpdateProgress(0);
|
InstallForm?.UpdateProgress(0);
|
||||||
InstallForm?.UpdateUser("Logging out of MEGA . . . ");
|
InstallForm?.UpdateUser("Logging out of MEGA . . . ", LogColor.Cleanup);
|
||||||
MegaApiClient.Logout();
|
MegaApiClient.Logout();
|
||||||
InstallForm?.UpdateProgress(100);
|
InstallForm?.UpdateProgress(100);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue