mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-11-10 17:28:17 +11:00
main: Added transactions panel
This commit is contained in:
parent
a4c1f0c895
commit
2da17c2d7d
14
FireWallet/MainForm.Designer.cs
generated
14
FireWallet/MainForm.Designer.cs
generated
@ -58,6 +58,7 @@
|
|||||||
labelBalanceTotal = new Label();
|
labelBalanceTotal = new Label();
|
||||||
labelLocked = new Label();
|
labelLocked = new Label();
|
||||||
labelBalance = new Label();
|
labelBalance = new Label();
|
||||||
|
panelSend = new Panel();
|
||||||
statusStripmain.SuspendLayout();
|
statusStripmain.SuspendLayout();
|
||||||
panelaccount.SuspendLayout();
|
panelaccount.SuspendLayout();
|
||||||
groupBoxaccount.SuspendLayout();
|
groupBoxaccount.SuspendLayout();
|
||||||
@ -245,6 +246,7 @@
|
|||||||
buttonSend.TabIndex = 1;
|
buttonSend.TabIndex = 1;
|
||||||
buttonSend.Text = "Send";
|
buttonSend.Text = "Send";
|
||||||
buttonSend.UseVisualStyleBackColor = true;
|
buttonSend.UseVisualStyleBackColor = true;
|
||||||
|
buttonSend.Click += buttonSend_Click;
|
||||||
//
|
//
|
||||||
// buttonPortfolio
|
// buttonPortfolio
|
||||||
//
|
//
|
||||||
@ -263,7 +265,7 @@
|
|||||||
panelPortfolio.Controls.Add(groupBoxTransactions);
|
panelPortfolio.Controls.Add(groupBoxTransactions);
|
||||||
panelPortfolio.Controls.Add(groupBoxinfo);
|
panelPortfolio.Controls.Add(groupBoxinfo);
|
||||||
panelPortfolio.Controls.Add(groupBoxbalance);
|
panelPortfolio.Controls.Add(groupBoxbalance);
|
||||||
panelPortfolio.Location = new Point(120, 25);
|
panelPortfolio.Location = new Point(448, 170);
|
||||||
panelPortfolio.Name = "panelPortfolio";
|
panelPortfolio.Name = "panelPortfolio";
|
||||||
panelPortfolio.Size = new Size(956, 538);
|
panelPortfolio.Size = new Size(956, 538);
|
||||||
panelPortfolio.TabIndex = 7;
|
panelPortfolio.TabIndex = 7;
|
||||||
@ -363,11 +365,20 @@
|
|||||||
labelBalance.TabIndex = 0;
|
labelBalance.TabIndex = 0;
|
||||||
labelBalance.Text = "labelBalance";
|
labelBalance.Text = "labelBalance";
|
||||||
//
|
//
|
||||||
|
// panelSend
|
||||||
|
//
|
||||||
|
panelSend.Location = new Point(120, 25);
|
||||||
|
panelSend.Name = "panelSend";
|
||||||
|
panelSend.Size = new Size(200, 100);
|
||||||
|
panelSend.TabIndex = 2;
|
||||||
|
panelSend.Visible = false;
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(1152, 575);
|
ClientSize = new Size(1152, 575);
|
||||||
|
Controls.Add(panelSend);
|
||||||
Controls.Add(panelPortfolio);
|
Controls.Add(panelPortfolio);
|
||||||
Controls.Add(panelNav);
|
Controls.Add(panelNav);
|
||||||
Controls.Add(panelaccount);
|
Controls.Add(panelaccount);
|
||||||
@ -423,5 +434,6 @@
|
|||||||
private Label labelPendingCount;
|
private Label labelPendingCount;
|
||||||
private Label labelSyncPercent;
|
private Label labelSyncPercent;
|
||||||
private GroupBox groupBoxTransactions;
|
private GroupBox groupBoxTransactions;
|
||||||
|
private Panel panelSend;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.Policy;
|
using System.Security.Policy;
|
||||||
@ -10,6 +11,7 @@ namespace FireWallet
|
|||||||
#region Variables
|
#region Variables
|
||||||
string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FireWallet\\";
|
string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FireWallet\\";
|
||||||
Dictionary<string, string> nodeSettings;
|
Dictionary<string, string> nodeSettings;
|
||||||
|
Dictionary<string, string> userSettings;
|
||||||
Dictionary<string, string> theme;
|
Dictionary<string, string> theme;
|
||||||
int Network;
|
int Network;
|
||||||
string account;
|
string account;
|
||||||
@ -31,6 +33,7 @@ namespace FireWallet
|
|||||||
{
|
{
|
||||||
UpdateTheme();
|
UpdateTheme();
|
||||||
LoadNode();
|
LoadNode();
|
||||||
|
LoadSettings();
|
||||||
|
|
||||||
// Edit the theme of the navigation panel
|
// Edit the theme of the navigation panel
|
||||||
panelNav.BackColor = ColorTranslator.FromHtml(theme["background-alt"]);
|
panelNav.BackColor = ColorTranslator.FromHtml(theme["background-alt"]);
|
||||||
@ -48,6 +51,8 @@ namespace FireWallet
|
|||||||
|
|
||||||
// Prompt for login
|
// Prompt for login
|
||||||
GetAccounts();
|
GetAccounts();
|
||||||
|
|
||||||
|
AddLog("Loaded");
|
||||||
}
|
}
|
||||||
private void MainForm_Closing(object sender, FormClosingEventArgs e)
|
private void MainForm_Closing(object sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
@ -81,6 +86,7 @@ namespace FireWallet
|
|||||||
string line = sr.ReadLine();
|
string line = sr.ReadLine();
|
||||||
string[] split = line.Split(':');
|
string[] split = line.Split(':');
|
||||||
nodeSettings.Add(split[0].Trim(), split[1].Trim());
|
nodeSettings.Add(split[0].Trim(), split[1].Trim());
|
||||||
|
|
||||||
}
|
}
|
||||||
sr.Dispose();
|
sr.Dispose();
|
||||||
|
|
||||||
@ -107,6 +113,28 @@ namespace FireWallet
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private void LoadSettings()
|
||||||
|
{
|
||||||
|
if (!File.Exists(dir + "settings.txt"))
|
||||||
|
{
|
||||||
|
AddLog("Creating settings file");
|
||||||
|
StreamWriter sw = new StreamWriter(dir + "settings.txt");
|
||||||
|
sw.WriteLine("explorer-tx: https://niami.io/tx/");
|
||||||
|
sw.WriteLine("explorer-addr: https://niami.io/address/");
|
||||||
|
sw.WriteLine("explorer-block: https://niami.io/block/");
|
||||||
|
sw.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
StreamReader sr = new StreamReader(dir + "settings.txt");
|
||||||
|
userSettings = new Dictionary<string, string>();
|
||||||
|
while (!sr.EndOfStream)
|
||||||
|
{
|
||||||
|
string line = sr.ReadLine();
|
||||||
|
userSettings.Add(line.Substring(0, line.IndexOf(":")).Trim(), line.Substring(line.IndexOf(":") + 1).Trim());
|
||||||
|
}
|
||||||
|
sr.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -258,6 +286,8 @@ namespace FireWallet
|
|||||||
sw.WriteLine("transparent-mode: off");
|
sw.WriteLine("transparent-mode: off");
|
||||||
sw.WriteLine("transparency-key: main");
|
sw.WriteLine("transparency-key: main");
|
||||||
sw.WriteLine("transparency-percent: 90");
|
sw.WriteLine("transparency-percent: 90");
|
||||||
|
sw.WriteLine("selected-bg: #000000");
|
||||||
|
sw.WriteLine("selected-fg: #ffffff");
|
||||||
|
|
||||||
sw.Dispose();
|
sw.Dispose();
|
||||||
AddLog("Created theme file");
|
AddLog("Created theme file");
|
||||||
@ -539,8 +569,84 @@ namespace FireWallet
|
|||||||
AddLog("GetInfo Error");
|
AddLog("GetInfo Error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
JArray pendingTxs = JArray.Parse(APIresponse);
|
||||||
|
labelPendingCount.Text = "Unconfirmed TX: " + pendingTxs.Count.ToString();
|
||||||
|
|
||||||
|
|
||||||
|
// Get TX's
|
||||||
|
APIresponse = await APIGet("wallet/" + account + "/tx/history", true);
|
||||||
|
if (APIresponse == "Error")
|
||||||
|
{
|
||||||
|
AddLog("GetInfo Error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
JArray txs = JArray.Parse(APIresponse);
|
JArray txs = JArray.Parse(APIresponse);
|
||||||
labelPendingCount.Text = "Unconfirmed TX: " + resp.Count.ToString();
|
int txCount = txs.Count;
|
||||||
|
if (txCount > groupBoxTransactions.Height / 55) txCount = (int)Math.Floor(groupBoxTransactions.Height / 55.0);
|
||||||
|
Control[] tmpControls = new Control[txCount];
|
||||||
|
for (int i = 0; i < txCount; i++)
|
||||||
|
{
|
||||||
|
// Get last tx
|
||||||
|
JObject tx = JObject.Parse(txs[txs.Count - 1 - i].ToString());
|
||||||
|
string hash = tx["hash"].ToString();
|
||||||
|
string date = tx["mdate"].ToString();
|
||||||
|
|
||||||
|
Panel tmpPanel = new Panel();
|
||||||
|
tmpPanel.Width = groupBoxTransactions.Width - 20;
|
||||||
|
tmpPanel.Height = 50;
|
||||||
|
tmpPanel.Location = new Point(10, 20 + (i * 55));
|
||||||
|
tmpPanel.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
tmpPanel.BackColor = ColorTranslator.FromHtml(theme["background-alt"]);
|
||||||
|
tmpPanel.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]);
|
||||||
|
tmpPanel.Controls.Add(
|
||||||
|
new Label()
|
||||||
|
{
|
||||||
|
Text = "Date: " + date,
|
||||||
|
Location = new Point(10, 5)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Label labelHash = new Label()
|
||||||
|
{
|
||||||
|
Text = "Hash: " + hash.Substring(0, 10) + "..." + hash.Substring(hash.Length - 10),
|
||||||
|
AutoSize = true,
|
||||||
|
Location = new Point(10, 25),
|
||||||
|
Font = new Font(this.Font, FontStyle.Underline)
|
||||||
|
};
|
||||||
|
labelHash.Click += (sender, e) =>
|
||||||
|
{
|
||||||
|
string url = userSettings["explorer-tx"] + hash;
|
||||||
|
ProcessStartInfo psi = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = url,
|
||||||
|
UseShellExecute = true
|
||||||
|
};
|
||||||
|
Process.Start(psi);
|
||||||
|
|
||||||
|
};
|
||||||
|
tmpPanel.Controls.Add(labelHash);
|
||||||
|
|
||||||
|
// Count inputs and outputs
|
||||||
|
JArray inputs = JArray.Parse(tx["inputs"].ToString());
|
||||||
|
JArray outputs = JArray.Parse(tx["outputs"].ToString());
|
||||||
|
int inputCount = inputs.Count;
|
||||||
|
int outputCount = outputs.Count;
|
||||||
|
|
||||||
|
Label labelInputOutput = new Label()
|
||||||
|
{
|
||||||
|
Text = "Inputs: " + inputCount + " Outputs: " + outputCount,
|
||||||
|
AutoSize = true,
|
||||||
|
Location = new Point(300, 20)
|
||||||
|
};
|
||||||
|
tmpPanel.Controls.Add(labelInputOutput);
|
||||||
|
|
||||||
|
|
||||||
|
tmpControls[i] = tmpPanel;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
groupBoxTransactions.Controls.Clear();
|
||||||
|
groupBoxTransactions.Controls.AddRange(tmpControls);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -561,13 +667,34 @@ namespace FireWallet
|
|||||||
#region Nav
|
#region Nav
|
||||||
private async void buttonPortfolio_Click(object sender, EventArgs e)
|
private async void buttonPortfolio_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
buttonSend.BackColor = ColorTranslator.FromHtml(theme["background"]);
|
||||||
|
buttonSend.ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
|
||||||
|
panelSend.Hide();
|
||||||
panelPortfolio.Show();
|
panelPortfolio.Show();
|
||||||
await UpdateBalance();
|
await UpdateBalance();
|
||||||
GetInfo();
|
GetInfo();
|
||||||
labelBalance.Text = "Available: " + balance.ToString() + " HNS";
|
labelBalance.Text = "Available: " + balance.ToString() + " HNS";
|
||||||
labelLocked.Text = "Locked: " + balanceLocked.ToString() + " HNS";
|
labelLocked.Text = "Locked: " + balanceLocked.ToString() + " HNS";
|
||||||
labelBalanceTotal.Text = "Total: " + (balance + balanceLocked).ToString() + " HNS";
|
labelBalanceTotal.Text = "Total: " + (balance + balanceLocked).ToString() + " HNS";
|
||||||
|
if (theme.ContainsKey("selected-bg") && theme.ContainsKey("selected-fg"))
|
||||||
|
{
|
||||||
|
buttonPortfolio.BackColor = ColorTranslator.FromHtml(theme["selected-bg"]);
|
||||||
|
buttonPortfolio.ForeColor = ColorTranslator.FromHtml(theme["selected-fg"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private void buttonSend_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
panelPortfolio.Hide();
|
||||||
|
panelSend.Show();
|
||||||
|
buttonPortfolio.BackColor = ColorTranslator.FromHtml(theme["background"]);
|
||||||
|
buttonPortfolio.ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
|
||||||
|
if (theme.ContainsKey("selected-bg") && theme.ContainsKey("selected-fg"))
|
||||||
|
{
|
||||||
|
buttonSend.BackColor = ColorTranslator.FromHtml(theme["selected-bg"]);
|
||||||
|
buttonSend.ForeColor = ColorTranslator.FromHtml(theme["selected-fg"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user