main: Cleaned login panel

This commit is contained in:
Nathan Woodburn 2023-07-05 18:21:11 +10:00
parent 9e2a1c17d8
commit a19833d025
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
4 changed files with 17 additions and 22 deletions

View File

@ -42,7 +42,10 @@
MinimizeBox = false; MinimizeBox = false;
Name = "Loader"; Name = "Loader";
Text = "Loader"; Text = "Loader";
Load += Loader_Load; Visible = false;
Opacity = 0;
FormBorderStyle = FormBorderStyle.SizableToolWindow;
ShowInTaskbar = false;
ResumeLayout(false); ResumeLayout(false);
} }

View File

@ -39,11 +39,7 @@ namespace FireWalletLite
string repositoryUrl = "https://github.com/handshake-org/hsd.git"; string repositoryUrl = "https://github.com/handshake-org/hsd.git";
string destinationPath = dir + "hsd"; string destinationPath = dir + "hsd";
CloneRepository(repositoryUrl, destinationPath); CloneRepository(repositoryUrl, destinationPath);
} }
// Start HSD // Start HSD
HSDProcess.StartInfo.RedirectStandardInput = true; HSDProcess.StartInfo.RedirectStandardInput = true;
HSDProcess.StartInfo.RedirectStandardOutput = false; HSDProcess.StartInfo.RedirectStandardOutput = false;
@ -70,15 +66,8 @@ namespace FireWalletLite
Application.DoEvents(); Application.DoEvents();
} }
splashScreen.Dispose(); splashScreen.Dispose();
mainForm.Show();
} }
private void Loader_Load(object sender, EventArgs e)
{
this.ShowInTaskbar = false;
this.Opacity = 0;
}
#region Git #region Git
public void CloneRepository(string repositoryUrl, string destinationPath) public void CloneRepository(string repositoryUrl, string destinationPath)
{ {

View File

@ -71,8 +71,7 @@
panelLogin.Controls.Add(textBoxPassword); panelLogin.Controls.Add(textBoxPassword);
panelLogin.Controls.Add(labelPassword); panelLogin.Controls.Add(labelPassword);
panelLogin.Controls.Add(LoginButton); panelLogin.Controls.Add(LoginButton);
panelLogin.Dock = DockStyle.Fill; panelLogin.Location = new Point(776, 443);
panelLogin.Location = new Point(0, 22);
panelLogin.Name = "panelLogin"; panelLogin.Name = "panelLogin";
panelLogin.Size = new Size(784, 428); panelLogin.Size = new Size(784, 428);
panelLogin.TabIndex = 1; panelLogin.TabIndex = 1;
@ -95,6 +94,7 @@
textBoxPassword.Size = new Size(137, 29); textBoxPassword.Size = new Size(137, 29);
textBoxPassword.TabIndex = 2; textBoxPassword.TabIndex = 2;
textBoxPassword.UseSystemPasswordChar = true; textBoxPassword.UseSystemPasswordChar = true;
textBoxPassword.KeyDown += textBoxPassword_KeyDown;
// //
// labelPassword // labelPassword
// //

View File

@ -206,8 +206,6 @@ namespace FireWalletLite
//req.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + key))); //req.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + key)));
req.Content = new StringContent(content); req.Content = new StringContent(content);
// Send request // Send request
try try
{ {
HttpResponseMessage resp = await httpClient.SendAsync(req); HttpResponseMessage resp = await httpClient.SendAsync(req);
@ -237,7 +235,6 @@ namespace FireWalletLite
string port = "1203"; string port = "1203";
if (wallet) port = port + "9"; if (wallet) port = port + "9";
else port = port + "7"; else port = port + "7";
try try
{ {
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://" + ip + ":" + port + "/" + path); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://" + ip + ":" + port + "/" + path);
@ -266,7 +263,6 @@ namespace FireWalletLite
} }
} }
#endregion #endregion
private void MainForm_Load(object sender, EventArgs e) private void MainForm_Load(object sender, EventArgs e)
{ {
LoginButton.Left = (this.ClientSize.Width - LoginButton.Width) / 2; LoginButton.Left = (this.ClientSize.Width - LoginButton.Width) / 2;
@ -292,7 +288,6 @@ namespace FireWalletLite
firstLoginForm.Dispose(); firstLoginForm.Dispose();
} }
} }
private async void Login_Click(object sender, EventArgs e) private async void Login_Click(object sender, EventArgs e)
{ {
LoginButton.Enabled = false; // To prevent double clicking LoginButton.Enabled = false; // To prevent double clicking
@ -302,17 +297,17 @@ namespace FireWalletLite
string content = "{\"passphrase\": \"" + Password + "\",\"timeout\": 60}"; string content = "{\"passphrase\": \"" + Password + "\",\"timeout\": 60}";
string response = await APIPost(path, true, content); string response = await APIPost(path, true, content);
if (response.Contains("Could not decrypt")) if (response == "Error")
{ {
Password = ""; Password = "";
NotifyForm notifyForm = new NotifyForm("Incorrect Password"); NotifyForm notifyForm = new NotifyForm("Incorrect Password");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
LoginButton.Enabled = true; LoginButton.Enabled = true;
return;
} }
panelLogin.Hide(); panelLogin.Hide();
} }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{ {
// Run taskkill /im "node.exe" /f /t // Run taskkill /im "node.exe" /f /t
@ -322,7 +317,15 @@ namespace FireWalletLite
startInfo.CreateNoWindow = true; startInfo.CreateNoWindow = true;
Process.Start(startInfo); Process.Start(startInfo);
Environment.Exit(0); Environment.Exit(0);
}
private void textBoxPassword_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 13)
{
Login_Click(sender, e);
e.SuppressKeyPress = true;
}
} }
} }
} }