main: Updated prerequisite install

This commit is contained in:
2023-07-19 15:06:25 +10:00
parent 7909f111cb
commit fffafcd89e
3 changed files with 62 additions and 141 deletions

View File

@@ -6,6 +6,13 @@ namespace FireWalletLite;
public partial class Loader : Form
{
#region Constants
private readonly MainForm mainForm = new();
private readonly bool hideScreen = true; // Hide screen or not (for debug)
private readonly Process HSDProcess;
#endregion
public Loader()
{
InitializeComponent();
@@ -62,14 +69,6 @@ public partial class Loader : Form
mainForm.Show();
}
#region Constants
private readonly MainForm mainForm = new();
private readonly bool hideScreen = true;
private readonly Process HSDProcess;
#endregion
#region Git
public void CloneRepository(string repositoryUrl, string destinationPath)
@@ -184,30 +183,36 @@ public partial class Loader : Form
mainForm.AddLog(ex.Message);
if (ex.Message.Contains("to start process 'git'"))
{
var notifyForm = new NotifyForm("Git needs to be installed\nCheck logs for more details");
var notifyForm = new NotifyForm("Git is not installed\nPlease install it to install HSD dependencies",
"Install", "https://git-scm.com/download/win");
notifyForm.ShowDialog();
notifyForm.Dispose();
Environment.Exit(21);
}
else if (ex.Message.Contains("to start process 'node'"))
{
var notifyForm = new NotifyForm("Node needs to be installed\nCheck logs for more details");
var notifyForm = new NotifyForm("Node is not installed\nPlease install it to install HSD dependencies",
"Install", "https://nodejs.org/en/download");
notifyForm.ShowDialog();
notifyForm.Dispose();
Environment.Exit(22);
}
else if (ex.Message.Contains("to start process 'npm'"))
{
var notifyForm = new NotifyForm("NPM needs to be installed\nCheck logs for more details");
var notifyForm = new NotifyForm("NPM is not installed\nPlease install it to install HSD dependencies",
"Install", "https://docs.npmjs.com/downloading-and-installing-node-js-and-npm");
notifyForm.ShowDialog();
notifyForm.Dispose();
Environment.Exit(23);
}
else
{
var notifyForm = new NotifyForm("Git/NPM Install FAILED\nCheck logs for more details");
notifyForm.ShowDialog();
notifyForm.Dispose();
Environment.Exit(24);
}
Environment.Exit(24);
}
}

View File

@@ -8,11 +8,14 @@ public partial class NotifyForm : Form
private bool allowClose = true;
private readonly string altLink;
private readonly string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
"\\FireWallet\\";
private readonly bool Linkcopy;
private Dictionary<string, string> theme;
public Dictionary<string, string> Theme { get; set; } = new()
{
{ "background", "#000000" },
{ "foreground", "#8e05c2"},
{ "background-alt", "#3e065f"},
{ "foreground-alt", "#ffffff"}
};
public NotifyForm(string Message)
{
@@ -100,150 +103,34 @@ public partial class NotifyForm : Form
private void UpdateTheme()
{
// Check if file exists
if (!Directory.Exists(dir)) CreateConfig(dir);
if (!File.Exists(dir + "theme.txt")) CreateConfig(dir);
if (!Theme.ContainsKey("background") || !Theme.ContainsKey("background-alt") ||
!Theme.ContainsKey("foreground") || !Theme.ContainsKey("foreground-alt")) return;
// Read file
var sr = new StreamReader(dir + "theme.txt");
theme = new Dictionary<string, string>();
while (!sr.EndOfStream)
{
var line = sr.ReadLine();
var split = line.Split(':');
theme.Add(split[0].Trim(), split[1].Trim());
}
sr.Dispose();
if (!theme.ContainsKey("background") || !theme.ContainsKey("background-alt") ||
!theme.ContainsKey("foreground") || !theme.ContainsKey("foreground-alt")) return;
// Apply theme
BackColor = ColorTranslator.FromHtml(theme["background"]);
// Apply Theme
BackColor = ColorTranslator.FromHtml(Theme["background"]);
// Foreground
ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
ForeColor = ColorTranslator.FromHtml(Theme["foreground"]);
// Need to specify this for each groupbox to override the black text
foreach (Control c in Controls) ThemeControl(c);
// Transparancy
applyTransparency(theme);
}
private void ThemeControl(Control c)
{
if (c.GetType() == typeof(GroupBox) || c.GetType() == typeof(Panel))
{
c.ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
c.ForeColor = ColorTranslator.FromHtml(Theme["foreground"]);
foreach (Control sub in c.Controls) ThemeControl(sub);
}
if (c.GetType() == typeof(TextBox) || c.GetType() == typeof(Button)
|| c.GetType() == typeof(ComboBox) || c.GetType() == typeof(StatusStrip))
{
c.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]);
c.BackColor = ColorTranslator.FromHtml(theme["background-alt"]);
c.ForeColor = ColorTranslator.FromHtml(Theme["foreground-alt"]);
c.BackColor = ColorTranslator.FromHtml(Theme["background-alt"]);
}
}
private void applyTransparency(Dictionary<string, string> theme)
{
if (theme.ContainsKey("transparent-mode"))
switch (theme["transparent-mode"])
{
case "mica":
var accent = new AccentPolicy { AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND };
var accentStructSize = Marshal.SizeOf(accent);
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
Marshal.StructureToPtr(accent, accentPtr, false);
var data = new WindowCompositionAttributeData
{
Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
SizeOfData = accentStructSize,
Data = accentPtr
};
User32.SetWindowCompositionAttribute(Handle, ref data);
Marshal.FreeHGlobal(accentPtr);
break;
case "key":
if (theme.ContainsKey("transparency-key"))
switch (theme["transparency-key"])
{
case "alt":
TransparencyKey = ColorTranslator.FromHtml(theme["background-alt"]);
break;
case "main":
TransparencyKey = ColorTranslator.FromHtml(theme["background"]);
break;
default:
TransparencyKey = ColorTranslator.FromHtml(theme["transparency-key"]);
break;
}
break;
case "percent":
if (theme.ContainsKey("transparency-percent"))
Opacity = Convert.ToDouble(theme["transparency-percent"]) / 100;
break;
}
}
private void CreateConfig(string dir)
{
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
var sw = new StreamWriter(dir + "theme.txt");
sw.WriteLine("background: #000000");
sw.WriteLine("foreground: #8e05c2");
sw.WriteLine("background-alt: #3e065f");
sw.WriteLine("foreground-alt: #ffffff");
sw.WriteLine("transparent-mode: off");
sw.WriteLine("transparency-key: main");
sw.WriteLine("transparency-percent: 90");
sw.Dispose();
}
// Required for mica effect
internal enum AccentState
{
ACCENT_DISABLED = 0,
ACCENT_ENABLE_GRADIENT = 1,
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
ACCENT_ENABLE_BLURBEHIND = 3,
ACCENT_INVALID_STATE = 4
}
internal enum WindowCompositionAttribute
{
WCA_ACCENT_POLICY = 19
}
[StructLayout(LayoutKind.Sequential)]
internal struct AccentPolicy
{
public AccentState AccentState;
public int AccentFlags;
public int GradientColor;
public int AnimationId;
}
[StructLayout(LayoutKind.Sequential)]
internal struct WindowCompositionAttributeData
{
public WindowCompositionAttribute Attribute;
public IntPtr Data;
public int SizeOfData;
}
internal static class User32
{
[DllImport("user32.dll")]
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
}
#endregion
}