main: Cleaned up UI and fixed a few bugs

This commit is contained in:
Nathan Woodburn 2023-07-07 16:47:58 +10:00
parent a09a10dd10
commit 2d6eb3c34a
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
6 changed files with 123 additions and 56 deletions

View File

@ -36,16 +36,16 @@
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(448, 260);
FormBorderStyle = FormBorderStyle.Fixed3D;
ControlBox = false;
Enabled = false;
FormBorderStyle = FormBorderStyle.SizableToolWindow;
Icon = (Icon)resources.GetObject("$this.Icon");
MaximizeBox = false;
MinimizeBox = false;
Name = "Loader";
Text = "Loader";
Visible = false;
Opacity = 0;
FormBorderStyle = FormBorderStyle.SizableToolWindow;
Opacity = 0D;
ShowInTaskbar = false;
Text = "Loader";
ResumeLayout(false);
}

View File

@ -9,7 +9,7 @@ namespace FireWalletLite
{
#region Constants
MainForm mainForm = new MainForm();
bool hideScreen = false;
bool hideScreen = true;
Process HSDProcess;
#endregion
@ -20,19 +20,11 @@ namespace FireWalletLite
SplashScreen splashScreen = new SplashScreen(false);
splashScreen.Show();
Application.DoEvents();
DateTime start = DateTime.Now;
while ((DateTime.Now - start).TotalSeconds < 5)
{
Thread.Sleep(10);
Application.DoEvents();
}
// Install and load node
string dir = mainForm.dir;
HSDProcess = new Process();
if (!Directory.Exists(dir)) Environment.Exit(1);
string hsdPath = dir + "hsd\\bin\\hsd.exe";
if (!Directory.Exists(dir + "hsd"))
{
@ -58,7 +50,11 @@ namespace FireWalletLite
HSDProcess.StartInfo.RedirectStandardError = false;
}
HSDProcess.Start();
while ((DateTime.Now - start).TotalSeconds < 5)
{
Thread.Sleep(10);
Application.DoEvents();
}
splashScreen.CloseSplash();
while (!splashScreen.IsClosed)
{
@ -238,5 +234,6 @@ namespace FireWalletLite
}
}
#endregion
}
}

View File

@ -32,6 +32,8 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
statusStripMain = new StatusStrip();
SyncLabel = new ToolStripStatusLabel();
LabelSyncWarning = new ToolStripStatusLabel();
DropDownHelp = new ToolStripDropDownButton();
timerUpdate = new System.Windows.Forms.Timer(components);
panelLogin = new Panel();
pictureBoxLogo = new PictureBox();
@ -50,7 +52,6 @@
groupBoxAccount = new GroupBox();
labelDomains = new Label();
labelBalance = new Label();
LabelSyncWarning = new ToolStripStatusLabel();
statusStripMain.SuspendLayout();
panelLogin.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxLogo).BeginInit();
@ -64,7 +65,7 @@
// statusStripMain
//
statusStripMain.Dock = DockStyle.Top;
statusStripMain.Items.AddRange(new ToolStripItem[] { SyncLabel, LabelSyncWarning });
statusStripMain.Items.AddRange(new ToolStripItem[] { SyncLabel, LabelSyncWarning, DropDownHelp });
statusStripMain.Location = new Point(0, 0);
statusStripMain.Name = "statusStripMain";
statusStripMain.Size = new Size(1099, 22);
@ -78,6 +79,23 @@
SyncLabel.Size = new Size(158, 17);
SyncLabel.Text = "Status: Node Not Connected";
//
// LabelSyncWarning
//
LabelSyncWarning.Name = "LabelSyncWarning";
LabelSyncWarning.Size = new Size(443, 17);
LabelSyncWarning.Text = "Please wait for node to sync. Account info could be incorrect while node is behind.";
LabelSyncWarning.Visible = false;
//
// DropDownHelp
//
DropDownHelp.DisplayStyle = ToolStripItemDisplayStyle.Text;
DropDownHelp.Image = (Image)resources.GetObject("DropDownHelp.Image");
DropDownHelp.ImageTransparentColor = Color.Magenta;
DropDownHelp.Name = "DropDownHelp";
DropDownHelp.Size = new Size(62, 20);
DropDownHelp.Text = "Support";
DropDownHelp.ToolTipText = "Get Support";
//
// timerUpdate
//
timerUpdate.Enabled = true;
@ -88,7 +106,7 @@
//
panelLogin.Controls.Add(pictureBoxLogo);
panelLogin.Controls.Add(groupBoxLogin);
panelLogin.Location = new Point(12, 40);
panelLogin.Location = new Point(1025, 185);
panelLogin.Name = "panelLogin";
panelLogin.Size = new Size(1099, 558);
panelLogin.TabIndex = 1;
@ -123,16 +141,16 @@
labelWelcome.Font = new Font("Segoe UI", 14F, FontStyle.Regular, GraphicsUnit.Point);
labelWelcome.Location = new Point(119, 25);
labelWelcome.Name = "labelWelcome";
labelWelcome.Size = new Size(212, 25);
labelWelcome.Size = new Size(238, 25);
labelWelcome.TabIndex = 3;
labelWelcome.Text = "Login to access account";
labelWelcome.Text = "Login to access your wallet";
//
// textBoxPassword
//
textBoxPassword.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
textBoxPassword.Location = new Point(209, 70);
textBoxPassword.Location = new Point(174, 71);
textBoxPassword.Name = "textBoxPassword";
textBoxPassword.Size = new Size(137, 29);
textBoxPassword.Size = new Size(235, 29);
textBoxPassword.TabIndex = 2;
textBoxPassword.UseSystemPasswordChar = true;
textBoxPassword.KeyDown += textBoxPassword_KeyDown;
@ -141,7 +159,7 @@
//
labelPassword.AutoSize = true;
labelPassword.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
labelPassword.Location = new Point(114, 73);
labelPassword.Location = new Point(79, 74);
labelPassword.Name = "labelPassword";
labelPassword.Size = new Size(79, 21);
labelPassword.TabIndex = 1;
@ -165,7 +183,7 @@
panelPortfolio.Controls.Add(groupBoxDomains);
panelPortfolio.Controls.Add(panelNav);
panelPortfolio.Controls.Add(groupBoxAccount);
panelPortfolio.Location = new Point(1041, 468);
panelPortfolio.Location = new Point(0, 25);
panelPortfolio.Name = "panelPortfolio";
panelPortfolio.Size = new Size(1052, 529);
panelPortfolio.TabIndex = 2;
@ -176,7 +194,7 @@
buttonRenew.Enabled = false;
buttonRenew.FlatStyle = FlatStyle.Flat;
buttonRenew.Font = new Font("Segoe UI", 14F, FontStyle.Regular, GraphicsUnit.Point);
buttonRenew.Location = new Point(102, 117);
buttonRenew.Location = new Point(102, 171);
buttonRenew.Name = "buttonRenew";
buttonRenew.Size = new Size(299, 49);
buttonRenew.TabIndex = 3;
@ -188,9 +206,9 @@
//
groupBoxDomains.Controls.Add(panelDomainList);
groupBoxDomains.Font = new Font("Segoe UI", 14F, FontStyle.Regular, GraphicsUnit.Point);
groupBoxDomains.Location = new Point(407, 3);
groupBoxDomains.Location = new Point(407, 57);
groupBoxDomains.Name = "groupBoxDomains";
groupBoxDomains.Size = new Size(642, 523);
groupBoxDomains.Size = new Size(642, 469);
groupBoxDomains.TabIndex = 2;
groupBoxDomains.TabStop = false;
groupBoxDomains.Text = "Domains";
@ -202,7 +220,7 @@
panelDomainList.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
panelDomainList.Location = new Point(3, 28);
panelDomainList.Name = "panelDomainList";
panelDomainList.Size = new Size(636, 492);
panelDomainList.Size = new Size(636, 438);
panelDomainList.TabIndex = 0;
//
// panelNav
@ -219,7 +237,7 @@
//
buttonSend.FlatStyle = FlatStyle.Flat;
buttonSend.Font = new Font("Segoe UI", 14F, FontStyle.Regular, GraphicsUnit.Point);
buttonSend.Location = new Point(3, 45);
buttonSend.Location = new Point(3, 99);
buttonSend.Name = "buttonSend";
buttonSend.Size = new Size(90, 36);
buttonSend.TabIndex = 1;
@ -231,7 +249,7 @@
//
buttonReceive.FlatStyle = FlatStyle.Flat;
buttonReceive.Font = new Font("Segoe UI", 14F, FontStyle.Regular, GraphicsUnit.Point);
buttonReceive.Location = new Point(3, 3);
buttonReceive.Location = new Point(3, 57);
buttonReceive.Name = "buttonReceive";
buttonReceive.Size = new Size(90, 36);
buttonReceive.TabIndex = 0;
@ -244,7 +262,7 @@
groupBoxAccount.Controls.Add(labelDomains);
groupBoxAccount.Controls.Add(labelBalance);
groupBoxAccount.Font = new Font("Segoe UI", 14F, FontStyle.Regular, GraphicsUnit.Point);
groupBoxAccount.Location = new Point(102, 3);
groupBoxAccount.Location = new Point(102, 57);
groupBoxAccount.Name = "groupBoxAccount";
groupBoxAccount.Size = new Size(299, 108);
groupBoxAccount.TabIndex = 0;
@ -269,13 +287,6 @@
labelBalance.TabIndex = 0;
labelBalance.Text = "labelBal";
//
// LabelSyncWarning
//
LabelSyncWarning.Name = "LabelSyncWarning";
LabelSyncWarning.Size = new Size(443, 17);
LabelSyncWarning.Text = "Please wait for node to sync. Account info could be incorrect while node is behind.";
LabelSyncWarning.Visible = false;
//
// MainForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
@ -329,5 +340,6 @@
private Button buttonSend;
private PictureBox pictureBoxLogo;
private ToolStripStatusLabel LabelSyncWarning;
private ToolStripDropDownButton DropDownHelp;
}
}

View File

@ -1,17 +1,37 @@
using System.Data;
using System.Diagnostics;
using System.DirectoryServices.ActiveDirectory;
using System.Runtime.InteropServices;
using FireWallet;
using Newtonsoft.Json.Linq;
using static QRCoder.PayloadGenerator;
namespace FireWalletLite
{
public partial class MainForm : Form
{
#region Constants and Config
// Directory to store files including logs, theme and hsd node
public string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\"
+ Application.ProductName.Trim().Replace(" ", "") + "\\";
// How many days to check for domain exiries. If domain will expire in less than this, prompt user to renew.
public int daysToExpire = 90;
// Explorer URLs for transactions and domains
public string TXExplorer = "https://niami.io/tx/";
public string DomainExplorer = "https://niami.io/domain/";
// Links to show in help dropdown menu
public Dictionary<string, string> HelpLinks = new Dictionary<string, string>()
{
{ "Discord", "https://l.woodburn.au/discord" },
{ "Separator" ,""},
{ "Github", "https://github.com/nathanwoodburn/FireWalletLite" }
};
#endregion
#region Variables
public string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FireWalletLite\\";
public int daysToExpire = 90; // How many days to check for domain exiries. If domain will expire in less than this, prompt user to renew.
public string TXExplorer = "https://niami.io/tx/"; // Transaction explorer URL
public string DomainExplorer = "https://niami.io/domain/"; // Domain explorer URL
public Dictionary<string, string> Theme { get; set; }
HttpClient httpClient = new HttpClient();
Decimal Balance { get; set; }
@ -23,6 +43,26 @@ namespace FireWalletLite
InitializeComponent();
UpdateTheme();
this.Text = Application.ProductName;
foreach (KeyValuePair<string, string> link in HelpLinks)
{
if (link.Key == "Separator")
{
DropDownHelp.DropDownItems.Add(new ToolStripSeparator());
continue;
}
ToolStripMenuItem tsmi = new ToolStripMenuItem(link.Key);
tsmi.Click += (s, e) =>
{
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = link.Value,
UseShellExecute = true
};
Process.Start(psi);
};
DropDownHelp.DropDownItems.Add(tsmi);
}
DropDownHelp.Margin = new Padding(statusStripMain.Width - DropDownHelp.Width - SyncLabel.Width - 20, 0, 0, 0);
}
#region Theming
private void UpdateTheme()
@ -99,8 +139,6 @@ namespace FireWalletLite
sw.WriteLine("foreground: #8e05c2");
sw.WriteLine("background-alt: #3e065f");
sw.WriteLine("foreground-alt: #ffffff");
sw.WriteLine("selected-bg: #000000");
sw.WriteLine("selected-fg: #ffffff");
sw.WriteLine("error: #ff0000");
sw.Dispose();
AddLog("Created theme file");
@ -146,7 +184,6 @@ namespace FireWalletLite
#region API
private async void NodeStatus()
{
if (await APIGet("", false) == "Error")
{
SyncLabel.Text = "Status: Node Not Connected";
@ -160,17 +197,22 @@ namespace FireWalletLite
JObject chain = JObject.Parse(resp["chain"].ToString());
decimal progress = Convert.ToDecimal(chain["progress"].ToString());
SyncLabel.Text = "Sync: " + decimal.Round(progress * 100, 2) + "%";
if (progress < 1) LabelSyncWarning.Visible = true;
else LabelSyncWarning.Visible = false;
if (progress < 1)
{
LabelSyncWarning.Visible = true;
DropDownHelp.Margin = new Padding(statusStripMain.Width - DropDownHelp.Width - SyncLabel.Width - LabelSyncWarning.Width - 20, 0, 0, 0);
}
else
{
LabelSyncWarning.Visible = false;
DropDownHelp.Margin = new Padding(statusStripMain.Width - DropDownHelp.Width - SyncLabel.Width - 20, 0, 0, 0);
}
}
// Try to keep wallet unlocked
string path = "wallet/" + Account + "/unlock";
string content = "{\"passphrase\": \"" + Password + "\",\"timeout\": 60}";
await APIPost(path, true, content);
path = "";
content = "{\"method\": \"selectwallet\",\"params\":[ \"" + Account + "\"]}";
@ -388,14 +430,13 @@ namespace FireWalletLite
{
groupBoxLogin.Left = (this.ClientSize.Width - groupBoxLogin.Width) / 2;
groupBoxLogin.Top = (this.ClientSize.Height - groupBoxLogin.Height) / 2;
pictureBoxLogo.Height = groupBoxLogin.Top - 20;
pictureBoxLogo.Width = pictureBoxLogo.Height;
pictureBoxLogo.Top = 10;
pictureBoxLogo.Left = (this.ClientSize.Width - pictureBoxLogo.Width) / 2;
this.TopMost = true;
textBoxPassword.Focus();
this.TopMost = false;
}
private async void TestForLogin()
{
@ -437,6 +478,14 @@ namespace FireWalletLite
panelNav.Dock = DockStyle.Left;
panelPortfolio.Show();
// Some UI stuff
groupBoxAccount.Top = statusStripMain.Height + 10;
groupBoxDomains.Top = statusStripMain.Height + 10;
groupBoxDomains.Height = this.Height - groupBoxDomains.Top - 20;
buttonReceive.Top = statusStripMain.Height + 10;
buttonSend.Top = buttonReceive.Top + buttonReceive.Height + 10;
buttonRenew.Top = groupBoxAccount.Top + groupBoxAccount.Height + 10;
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{

View File

@ -120,10 +120,19 @@
<metadata name="statusStripMain.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="DropDownHelp.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb
J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj
CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN
AAAAAElFTkSuQmCC
</value>
</data>
<metadata name="timerUpdate.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>164, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="pictureBoxLogo.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAfwAAAGuCAYAAAB1FLTvAAABgmlDQ1BJQ0MgcHJvZmlsZQAAKM+VkUso
@ -133,7 +142,7 @@
2rGEB4Q7EpYt+cG5IicUryu2sqvmzz3VCxuW7dkZpctsZ5wJpphGw2CVDFny9Mhqi+ISlf1IBX+b758W
lyGuDKY4RlnBQvf9qD/43a2b7O8rJjVEoPrJ8946oXYLvgqe93noeV9HUPUIF3bJv3IAQ++iF0paxz40
bcDZZUkztuF8E1ofcrqj+1KVzGAyCa8n8k1xaL6G+oVibz/7HN9BTLqavILdPehKSfZihXfXlff25xm/
PyLflwVytc4cImAAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAHdElNRQfnBhYEEA/g09tlAAD3M0lEQVR4
PyLflwVytc4cImAAAAAJcEhZcwAADrwAAA68AZW8ckkAAAAHdElNRQfnBhYEEA/g09tlAAD3M0lEQVR4
Xuz9d7sd1Znu/+5/z3X2r22CMiJnITKInDHYmAxCAeW8lHPWUiQLAQKRs+12Y8B2u22DUztgY7vZ+3de
id/COOOums+cTz3zHlWjatZcQarnur6X1pqid2iFj0bVqFH/q5lmmmmmmWaaaaaZZppppplmmmmmmWaa
aaaZZpoZdXPSSf921+OPP+Qef+wBd87Zk13r42aaaaaZZpppZhTMt04Z7y6+apq75pbb3MnjJoQdHzv2

View File

@ -907,7 +907,7 @@
dCzhPuFw0rIlP5jIc1LxmmIrs2L+3FO9sG7BnoopXWYbo4wxwSQaBisskSFHt6y2KC5R2Y+U8Lf6/klx
GeJawhTHMMtY6L4f9Qe/u3VTvT35pLoIVDx53lsHVG3B16bnfR563tcRlD3ChV3wLx/AwLvomwUtvA8N
63B2WdCMbTjfgJaHrO7ovlQmM5hKweuJfNM0NF5D7Wy+t599ju8gLl2NX8HuHnSmJXuuxLuri3v784zf
H5FvlztytdwJPAYAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAHdElNRQfnBhUJHwzkL6qtAAD+IUlEQVR4
H5FvlztytdwJPAYAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAHdElNRQfnBhUJHwzkL6qtAAD+IUlEQVR4
Xuz995tcxbnvf59fn+s5322TlCVyFCKDRM7GNiaDUEA5j9JIo5xmlEAIBVAiR4ftjQHb28aAc8Bge3PO
9/lL/C/UU5+1+u6+u/pTa9VavXq6R6r7ut6XZlrskybodaqqa/2vOHHixIkTJ06cOHHixIkTJ06cOHHi
xIkTJ06cOHHixIkTJ06cOHHixIkTJ06cOHHixIkTJ06cOHHixIkTJ06cOHHixIkTJ06cOHHixIkTJ06c