main: Added owned domains list

This commit is contained in:
Nathan Woodburn 2023-06-08 12:03:51 +10:00
parent d073b7621f
commit 9629f96183
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
6 changed files with 110 additions and 20 deletions

View File

@ -71,7 +71,7 @@
comboBoxMode.FlatStyle = FlatStyle.Flat;
comboBoxMode.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
comboBoxMode.FormattingEnabled = true;
comboBoxMode.Items.AddRange(new object[] { "OPEN", "BID", "REVEAL", "REDEEM", "RENEW", "TRANSFER", "FINALIZE" });
comboBoxMode.Items.AddRange(new object[] { "OPEN", "BID", "REVEAL", "REDEEM", "RENEW", "TRANSFER", "FINALIZE", "CANCEL" });
comboBoxMode.Location = new System.Drawing.Point(346, 42);
comboBoxMode.Name = "comboBoxMode";
comboBoxMode.Size = new System.Drawing.Size(226, 29);

View File

@ -248,7 +248,7 @@ namespace FireWallet
this.Close();
}
else if (comboBoxMode.Text == "OPEN" || comboBoxMode.Text == "REVEAL" || comboBoxMode.Text == "REDEEM"
|| comboBoxMode.Text == "RENEW" || comboBoxMode.Text == "FINALIZE")
|| comboBoxMode.Text == "RENEW" || comboBoxMode.Text == "FINALIZE" || comboBoxMode.Text == "CANCEL")
{
batches = new Batch[0];
foreach (string domain in listBoxDomains.Items)

View File

@ -290,7 +290,7 @@
textBoxBlind.Size = new System.Drawing.Size(180, 29);
textBoxBlind.TabIndex = 5;
textBoxBlind.Visible = false;
textBoxBlind.TextChanged += textBoxBlind_TextChanged;
textBoxBlind.TextChanged += BidBlind_TextChanged;
//
// textBoxBid
//
@ -299,7 +299,7 @@
textBoxBid.Size = new System.Drawing.Size(180, 29);
textBoxBid.TabIndex = 4;
textBoxBid.Visible = false;
textBoxBid.TextChanged += textBoxBlind_TextChanged;
textBoxBid.TextChanged += BidBlind_TextChanged;
//
// labelBlind
//

View File

@ -620,18 +620,21 @@ namespace FireWallet
sw.Dispose();
}
#endregion
private async Task<bool> DomainOwned()
private bool DomainOwned()
{
string ownedDomains = await APIGet("wallet/hot/name?own=true", true);
JArray ownedList = JArray.Parse(ownedDomains);
foreach (JObject d in ownedList) if (d["name"].ToString() == domain) return true;
foreach (string d in mainForm.Domains)
{
if (d==domain)
{
return true;
}
}
return false;
}
private async void ActionSetupAsync(string state)
private void ActionSetupAsync(string state)
{
own = await DomainOwned();
own = DomainOwned();
this.state = state;
switch (state)
{
@ -689,7 +692,7 @@ namespace FireWallet
break;
}
}
private void textBoxBlind_TextChanged(object sender, EventArgs e)
private void BidBlind_TextChanged(object sender, EventArgs e)
{
string cleanedText = Regex.Replace(textBoxBid.Text, "[^0-9.]", "");
textBoxBid.Text = cleanedText;

View File

@ -83,6 +83,8 @@ namespace FireWallet
textBoxReceiveAddress = new TextBox();
labelReceive1 = new Label();
panelDomains = new Panel();
groupBoxDomains = new GroupBox();
panelDomainList = new Panel();
labelDomainSearch = new Label();
textBoxDomainSearch = new TextBox();
statusStripmain.SuspendLayout();
@ -96,6 +98,7 @@ namespace FireWallet
panelRecieve.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxReceiveQR).BeginInit();
panelDomains.SuspendLayout();
groupBoxDomains.SuspendLayout();
SuspendLayout();
//
// statusStripmain
@ -618,6 +621,7 @@ namespace FireWallet
//
// panelDomains
//
panelDomains.Controls.Add(groupBoxDomains);
panelDomains.Controls.Add(labelDomainSearch);
panelDomains.Controls.Add(textBoxDomainSearch);
panelDomains.Location = new Point(120, 27);
@ -626,23 +630,44 @@ namespace FireWallet
panelDomains.TabIndex = 18;
panelDomains.Visible = false;
//
// groupBoxDomains
//
groupBoxDomains.Controls.Add(panelDomainList);
groupBoxDomains.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
groupBoxDomains.Location = new Point(18, 59);
groupBoxDomains.Name = "groupBoxDomains";
groupBoxDomains.Size = new Size(887, 466);
groupBoxDomains.TabIndex = 2;
groupBoxDomains.TabStop = false;
groupBoxDomains.Text = "Domains";
//
// panelDomainList
//
panelDomainList.AutoScroll = true;
panelDomainList.Dock = DockStyle.Fill;
panelDomainList.Location = new Point(3, 25);
panelDomainList.Name = "panelDomainList";
panelDomainList.Size = new Size(881, 438);
panelDomainList.TabIndex = 0;
//
// labelDomainSearch
//
labelDomainSearch.AutoSize = true;
labelDomainSearch.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
labelDomainSearch.Location = new Point(92, 47);
labelDomainSearch.Location = new Point(18, 15);
labelDomainSearch.Name = "labelDomainSearch";
labelDomainSearch.Size = new Size(57, 21);
labelDomainSearch.Size = new Size(60, 21);
labelDomainSearch.TabIndex = 1;
labelDomainSearch.Text = "Search";
labelDomainSearch.Text = "Search:";
//
// textBoxDomainSearch
//
textBoxDomainSearch.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
textBoxDomainSearch.Location = new Point(155, 44);
textBoxDomainSearch.Location = new Point(84, 12);
textBoxDomainSearch.Name = "textBoxDomainSearch";
textBoxDomainSearch.Size = new Size(206, 29);
textBoxDomainSearch.Size = new Size(261, 29);
textBoxDomainSearch.TabIndex = 0;
textBoxDomainSearch.TextChanged += textBoxDomainSearch_TextChanged;
textBoxDomainSearch.KeyDown += textBoxDomainSearch_KeyDown;
//
// MainForm
@ -680,6 +705,7 @@ namespace FireWallet
((System.ComponentModel.ISupportInitialize)pictureBoxReceiveQR).EndInit();
panelDomains.ResumeLayout(false);
panelDomains.PerformLayout();
groupBoxDomains.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
@ -737,5 +763,7 @@ namespace FireWallet
private Label labelDomainSearch;
private TextBox textBoxDomainSearch;
private Button buttonBatch;
private GroupBox groupBoxDomains;
private Panel panelDomainList;
}
}

View File

@ -4,6 +4,7 @@ using Newtonsoft.Json.Linq;
using Point = System.Drawing.Point;
using Size = System.Drawing.Size;
using IronBarCode;
using System.Text.RegularExpressions;
namespace FireWallet
{
@ -344,6 +345,8 @@ namespace FireWallet
{
groupBoxaccount.Left = (this.ClientSize.Width - groupBoxaccount.Width) / 2;
groupBoxaccount.Top = (this.ClientSize.Height - groupBoxaccount.Height) / 2;
groupBoxDomains.Width = panelDomains.Width - 20;
groupBoxDomains.Left = 10;
}
#endregion
#region Accounts
@ -486,7 +489,7 @@ namespace FireWallet
content = "{\"method\": \"selectwallet\",\"params\":[ \"" + account + "\"]}";
await APIPost(path, true, content);
}
private async Task UpdateBalance()
{
@ -874,6 +877,10 @@ namespace FireWallet
buttonNavDomains.ForeColor = ColorTranslator.FromHtml(theme["selected-fg"]);
}
textBoxDomainSearch.Focus();
groupBoxDomains.Width = panelDomains.Width - 20;
groupBoxDomains.Left = 10;
UpdateDomains();
}
#endregion
#region Send
@ -1026,7 +1033,53 @@ namespace FireWallet
labelReceive2.Left = (panelRecieve.Width - labelReceive2.Width) / 2;
}
#endregion
#region Domains
public string[] Domains { get; set; }
private async void UpdateDomains()
{
string response = await APIGet("wallet/" + account + "/name?own=true", true);
JArray names = JArray.Parse(response);
Domains = new string[names.Count];
int i = 0;
panelDomainList.Controls.Clear();
foreach (JObject name in names)
{
Domains[i] = name["name"].ToString();
Panel domainTMP = new Panel();
domainTMP.Width = panelDomainList.Width - 20 - SystemInformation.VerticalScrollBarWidth;
domainTMP.Height = 30;
domainTMP.Top = 30 * (i);
domainTMP.Left = 10;
domainTMP.BorderStyle = BorderStyle.FixedSingle;
// On Click open domain
domainTMP.Click += new EventHandler((sender, e) =>
{
DomainForm domainForm = new DomainForm(name["name"].ToString(), userSettings["explorer-tx"], userSettings["explorer-domain"]);
domainForm.Show();
});
Label domainName = new Label();
domainName.Text = Domains[i];
domainName.Top = 5;
domainName.Left = 5;
domainName.AutoSize = true;
JObject stats = JObject.Parse(name["stats"].ToString());
Label expiry = new Label();
expiry.Text = "Expires: " + stats["blocksUntilExpire"].ToString() + " blocks";
expiry.Top = 5;
expiry.Left = domainTMP.Width - expiry.Width - 5;
expiry.AutoSize = true;
domainTMP.Controls.Add(domainName);
domainTMP.Controls.Add(expiry);
panelDomainList.Controls.Add(domainTMP);
i++;
}
}
#endregion
private void textBoxDomainSearch_KeyDown(object sender, KeyEventArgs e)
{
@ -1074,8 +1127,6 @@ namespace FireWallet
batchMode = false;
batchForm.Dispose();
}
#endregion
private void buttonBatch_Click(object sender, EventArgs e)
{
if (!batchMode)
@ -1086,5 +1137,13 @@ namespace FireWallet
}
else batchForm.Focus();
}
#endregion
private void textBoxDomainSearch_TextChanged(object sender, EventArgs e)
{
string domainSearch = textBoxDomainSearch.Text;
domainSearch = Regex.Replace(textBoxDomainSearch.Text, "[^a-zA-Z0-9-_]", "");
textBoxDomainSearch.Text = domainSearch;
}
}
}