main: Cleaned up code and set splash to close after node connected

- Splash will not close anymore until Node is started and connected if internal HSD running.
- Splash will not close until after 4 seconds if external HSD running
This commit is contained in:
Nathan Woodburn 2023-06-17 15:24:13 +10:00
parent 90cc614ebf
commit 0a5412478c
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
10 changed files with 305 additions and 274 deletions

View File

@ -465,7 +465,7 @@ namespace FireWallet
HttpClient httpClient = new HttpClient();
private async void buttonSend_Click(object sender, EventArgs e)
{
if (!mainForm.watchOnly)
if (!mainForm.WatchOnly)
{
string batchTX = "[" + string.Join(", ", batches.Select(batch => batch.ToString())) + "]";
string content = "{\"method\": \"sendbatch\",\"params\":[ " + batchTX + "]}";
@ -508,7 +508,7 @@ namespace FireWallet
JObject result = JObject.Parse(jObject["result"].ToString());
string hash = result["hash"].ToString();
AddLog("Batch sent with hash: " + hash);
NotifyForm notifyForm2 = new NotifyForm("Batch sent\nThis might take a while to mine.", "Explorer", mainForm.userSettings["explorer-tx"] + hash);
NotifyForm notifyForm2 = new NotifyForm("Batch sent\nThis might take a while to mine.", "Explorer", mainForm.UserSettings["explorer-tx"] + hash);
notifyForm2.ShowDialog();
notifyForm2.Dispose();
this.Close();
@ -552,7 +552,7 @@ namespace FireWallet
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.FileName = "node.exe";
proc.StartInfo.WorkingDirectory = dir + "hsd-ledger/bin/";
string args = "hsd-ledger/bin/hsd-ledger sendraw \"\"" + response.Replace("\"","\\\"") + "\"\" [" + domainslist + "] --api-key " + mainForm.nodeSettings["Key"] + " -w " + mainForm.account;
string args = "hsd-ledger/bin/hsd-ledger sendraw \"\"" + response.Replace("\"","\\\"") + "\"\" [" + domainslist + "] --api-key " + mainForm.NodeSettings["Key"] + " -w " + mainForm.Account;
proc.StartInfo.Arguments = dir + args;
var outputBuilder = new StringBuilder();
@ -578,7 +578,7 @@ namespace FireWallet
if (output.Contains("Submitted TXID"))
{
string hash = output.Substring(output.IndexOf("Submitted TXID") + 16, 64);
string link = mainForm.userSettings["explorer-tx"] + hash;
string link = mainForm.UserSettings["explorer-tx"] + hash;
NotifyForm notifySuccess = new NotifyForm("Transaction Sent\nThis transaction could take up to 20 minutes to mine",
"Explorer", link);
notifySuccess.ShowDialog();
@ -739,10 +739,10 @@ namespace FireWallet
/// <returns></returns>
private async Task<string> APIPost(string path, bool wallet, string content)
{
string key = mainForm.nodeSettings["Key"];
string ip = mainForm.nodeSettings["IP"];
string key = mainForm.NodeSettings["Key"];
string ip = mainForm.NodeSettings["IP"];
string port = "1203";
if (mainForm.network == 1)
if (mainForm.HSDNetwork == 1)
{
port = "1303";
}

View File

@ -27,7 +27,7 @@ namespace FireWallet
InitializeComponent();
this.domain = domain;
this.mainForm = mainForm;
nodeSettings = mainForm.nodeSettings;
nodeSettings = mainForm.NodeSettings;
cancel = true;
this.Text = domain + "/ DNS | FireWallet";
@ -439,7 +439,7 @@ namespace FireWallet
string key = nodeSettings["Key"];
string ip = nodeSettings["IP"];
string port = "1203";
if (mainForm.network == 1)
if (mainForm.HSDNetwork == 1)
{
port = "1303";
}
@ -478,7 +478,7 @@ namespace FireWallet
string ip = nodeSettings["IP"];
string port = "1203";
if (mainForm.network == 1)
if (mainForm.HSDNetwork == 1)
{
port = "1303";
}

View File

@ -32,7 +32,7 @@ namespace FireWallet
this.explorerTX = explorerTX;
this.explorerName = explorerName;
this.mainForm = mainForm;
this.theme = mainForm.theme;
this.theme = mainForm.Theme;
// Apply theme
this.BackColor = ColorTranslator.FromHtml(theme["background"]);
@ -47,7 +47,7 @@ namespace FireWallet
mainForm.ThemeControl(c);
}
applyTransparency(mainForm.theme);
applyTransparency(mainForm.Theme);
}
#region Theme
private void applyTransparency(Dictionary<string, string> theme)
@ -157,7 +157,7 @@ namespace FireWallet
network = Convert.ToInt32(nodeSettings["Network"]);
GetName();
if (mainForm.watchOnly)
if (mainForm.WatchOnly)
{
buttonActionMain.Enabled = false; // Only allow sending in batches for ledger
}

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,7 @@ namespace FireWallet
private void NewAccountForm_Load(object sender, EventArgs e)
{
page = 0;
Dictionary<string, string> theme = mainForm.theme;
Dictionary<string, string> theme = mainForm.Theme;
this.BackColor = ColorTranslator.FromHtml(theme["background"]);
this.ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
foreach (Control c in Controls)
@ -208,7 +208,7 @@ namespace FireWallet
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.FileName = "node.exe";
proc.StartInfo.Arguments = mainForm.dir + "hsd-ledger/bin/hsd-ledger createwallet " + textBoxNewPass1.Text + " --api-key " + mainForm.nodeSettings["Key"];
proc.StartInfo.Arguments = mainForm.dir + "hsd-ledger/bin/hsd-ledger createwallet " + textBoxNewPass1.Text + " --api-key " + mainForm.NodeSettings["Key"];
var outputBuilder = new StringBuilder();
// Event handler for capturing output data
@ -243,10 +243,10 @@ namespace FireWallet
HttpClient httpClient = new HttpClient();
private async Task<string> APIPut(string path, bool wallet, string content)
{
string key = mainForm.nodeSettings["Key"];
string ip = mainForm.nodeSettings["IP"];
string key = mainForm.NodeSettings["Key"];
string ip = mainForm.NodeSettings["IP"];
string port = "1203";
if (mainForm.network == 1)
if (mainForm.HSDNetwork == 1)
{
port = "1303";
}

View File

@ -28,21 +28,13 @@
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SplashScreen));
timerSplashDelay = new System.Windows.Forms.Timer(components);
label1 = new Label();
pictureBox1 = new PictureBox();
label2 = new Label();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout();
//
// timerSplashDelay
//
timerSplashDelay.Enabled = true;
timerSplashDelay.Interval = 3000;
timerSplashDelay.Tick += timerSplashDelay_Tick;
//
// label1
//
label1.AutoSize = true;
@ -99,8 +91,6 @@
}
#endregion
private System.Windows.Forms.Timer timerSplashDelay;
private Label label1;
private PictureBox pictureBox1;
private Label label2;

View File

@ -13,23 +13,25 @@ namespace FireWallet
{
public partial class SplashScreen : Form
{
public SplashScreen()
public SplashScreen(bool timer)
{
InitializeComponent();
close = false;
}
bool close;
private void timerSplashDelay_Tick(object sender, EventArgs e)
private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e)
{
if (!close)
{
e.Cancel = true;
}
}
public void CloseSplash()
{
close = true;
this.Close();
}
private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
ProcessStartInfo psi = new ProcessStartInfo

View File

@ -117,9 +117,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timerSplashDelay.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>

View File

@ -22,8 +22,8 @@ namespace FireWallet
{
InitializeComponent();
// Theme
this.BackColor = ColorTranslator.FromHtml(mainForm.theme["background"]);
this.ForeColor = ColorTranslator.FromHtml(mainForm.theme["foreground"]);
this.BackColor = ColorTranslator.FromHtml(mainForm.Theme["background"]);
this.ForeColor = ColorTranslator.FromHtml(mainForm.Theme["foreground"]);
foreach (Control c in Controls)
{
mainForm.ThemeControl(c);
@ -35,7 +35,7 @@ namespace FireWallet
private async void TXForm_Load(object sender, EventArgs e)
{
tx = JObject.Parse(await mainForm.APIGet("wallet/"+mainForm.account+"/tx/" + txid,true));
tx = JObject.Parse(await mainForm.APIGet("wallet/"+mainForm.Account+"/tx/" + txid,true));
this.Text = "TX: " + tx["hash"].ToString();
labelHash.Text = "Hash: " + tx["hash"].ToString();
@ -142,7 +142,7 @@ namespace FireWallet
private void Explorer_Click(object sender, EventArgs e)
{
// Open the transaction in a browser
string url = mainForm.userSettings["explorer-tx"] + tx["hash"].ToString();
string url = mainForm.UserSettings["explorer-tx"] + tx["hash"].ToString();
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = url,

View File

@ -25,18 +25,18 @@ namespace FireWallet
Domain = domain;
this.Text = "Transfer " + Domain + " | FireWallet";
label1.Text = "Transfer " + Domain;
if (MainForm.theme.ContainsKey("error"))
if (MainForm.Theme.ContainsKey("error"))
{
labelError.ForeColor = ColorTranslator.FromHtml(MainForm.theme["error"]);
labelError.ForeColor = ColorTranslator.FromHtml(MainForm.Theme["error"]);
}
if (MainForm.watchOnly)
if (MainForm.WatchOnly)
{
buttonTransfer.Enabled = false; // watch only wallet only batch
}
// Theme
this.BackColor = ColorTranslator.FromHtml(MainForm.theme["background"]);
this.ForeColor = ColorTranslator.FromHtml(MainForm.theme["foreground"]);
this.BackColor = ColorTranslator.FromHtml(MainForm.Theme["background"]);
this.ForeColor = ColorTranslator.FromHtml(MainForm.Theme["foreground"]);
foreach (Control c in Controls)
{
MainForm.ThemeControl(c);
@ -73,7 +73,7 @@ namespace FireWallet
}
JObject result = JObject.Parse(APIresp["result"].ToString());
string hash = result["hash"].ToString();
string link = MainForm.userSettings["explorer-tx"] + hash;
string link = MainForm.UserSettings["explorer-tx"] + hash;
NotifyForm notifySuccess = new NotifyForm("Transaction Sent\nThis transaction could take up to 20 minutes to mine",
"Explorer", link);
notifySuccess.ShowDialog();