From 9296f3747513cfab17a79548204b8d7199f6b888 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 8 Jun 2023 18:19:39 +1000 Subject: [PATCH] main: Cleaned up code --- FireWallet/MainForm.Designer.cs | 52 +++++++++++++++++++++++++++++++ FireWallet/MainForm.cs | 54 ++++++++++++++------------------- 2 files changed, 75 insertions(+), 31 deletions(-) diff --git a/FireWallet/MainForm.Designer.cs b/FireWallet/MainForm.Designer.cs index d8d1291..0d40b4b 100644 --- a/FireWallet/MainForm.Designer.cs +++ b/FireWallet/MainForm.Designer.cs @@ -101,6 +101,10 @@ namespace FireWallet textBoxExAddr = new TextBox(); labelSettings4 = new Label(); textBoxExTX = new TextBox(); + groupBoxSettingsMisc = new GroupBox(); + labelSettings5 = new Label(); + numericUpDownConfirmations = new NumericUpDown(); + labelSettings6 = new Label(); statusStripmain.SuspendLayout(); panelaccount.SuspendLayout(); groupBoxaccount.SuspendLayout(); @@ -115,6 +119,8 @@ namespace FireWallet groupBoxDomains.SuspendLayout(); panelSettings.SuspendLayout(); groupBoxSettingsExplorer.SuspendLayout(); + groupBoxSettingsMisc.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownConfirmations).BeginInit(); SuspendLayout(); // // statusStripmain @@ -705,6 +711,7 @@ namespace FireWallet // // panelSettings // + panelSettings.Controls.Add(groupBoxSettingsMisc); panelSettings.Controls.Add(labelSettingsSaved); panelSettings.Controls.Add(buttonSettingsSave); panelSettings.Controls.Add(groupBoxSettingsExplorer); @@ -819,6 +826,44 @@ namespace FireWallet textBoxExTX.Size = new Size(307, 29); textBoxExTX.TabIndex = 1; // + // groupBoxSettingsMisc + // + groupBoxSettingsMisc.Controls.Add(labelSettings6); + groupBoxSettingsMisc.Controls.Add(numericUpDownConfirmations); + groupBoxSettingsMisc.Controls.Add(labelSettings5); + groupBoxSettingsMisc.Location = new Point(14, 210); + groupBoxSettingsMisc.Name = "groupBoxSettingsMisc"; + groupBoxSettingsMisc.Size = new Size(487, 194); + groupBoxSettingsMisc.TabIndex = 7; + groupBoxSettingsMisc.TabStop = false; + groupBoxSettingsMisc.Text = "Misc Settings"; + // + // labelSettings5 + // + labelSettings5.AutoSize = true; + labelSettings5.Location = new Point(11, 36); + labelSettings5.Name = "labelSettings5"; + labelSettings5.Size = new Size(112, 21); + labelSettings5.TabIndex = 0; + labelSettings5.Text = "Confirmations:"; + // + // numericUpDown1 + // + numericUpDownConfirmations.Location = new Point(129, 34); + numericUpDownConfirmations.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownConfirmations.Name = "numericUpDown1"; + numericUpDownConfirmations.Size = new Size(120, 29); + numericUpDownConfirmations.TabIndex = 1; + // + // labelSettings6 + // + labelSettings6.AutoSize = true; + labelSettings6.Location = new Point(255, 36); + labelSettings6.Name = "labelSettings6"; + labelSettings6.Size = new Size(54, 21); + labelSettings6.TabIndex = 2; + labelSettings6.Text = "blocks"; + // // MainForm // AutoScaleDimensions = new SizeF(7F, 15F); @@ -861,6 +906,9 @@ namespace FireWallet panelSettings.PerformLayout(); groupBoxSettingsExplorer.ResumeLayout(false); groupBoxSettingsExplorer.PerformLayout(); + groupBoxSettingsMisc.ResumeLayout(false); + groupBoxSettingsMisc.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownConfirmations).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -933,5 +981,9 @@ namespace FireWallet private Button buttonSettingsSave; private GroupBox groupBoxSettingsExplorer; private Label labelSettingsSaved; + private GroupBox groupBoxSettingsMisc; + private Label labelSettings6; + private NumericUpDown numericUpDownConfirmations; + private Label labelSettings5; } } \ No newline at end of file diff --git a/FireWallet/MainForm.cs b/FireWallet/MainForm.cs index a21770c..9cd79df 100644 --- a/FireWallet/MainForm.cs +++ b/FireWallet/MainForm.cs @@ -228,7 +228,8 @@ namespace FireWallet } } if (c.GetType() == typeof(TextBox) || c.GetType() == typeof(Button) - || c.GetType() == typeof(ComboBox) || c.GetType() == typeof(StatusStrip) || c.GetType() == typeof(ToolStrip)) + || c.GetType() == typeof(ComboBox) || c.GetType() == typeof(StatusStrip) || c.GetType() == typeof(ToolStrip) + || c.GetType() == typeof(NumericUpDown)) { c.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); c.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); @@ -772,16 +773,8 @@ namespace FireWallet #region Nav private async void PortfolioPanel_Click(object sender, EventArgs e) { - panelSend.Hide(); - panelPortfolio.Show(); - panelRecieve.Hide(); - panelDomains.Hide(); - buttonNavSend.BackColor = ColorTranslator.FromHtml(theme["background"]); - buttonNavSend.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - buttonNavReceive.BackColor = ColorTranslator.FromHtml(theme["background"]); - buttonNavReceive.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - buttonNavDomains.BackColor = ColorTranslator.FromHtml(theme["background"]); - buttonNavDomains.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); + hidePages(); + await UpdateBalance(); GetTXHistory(); labelBalance.Text = "Available: " + balance.ToString() + " HNS"; @@ -798,12 +791,6 @@ namespace FireWallet { hidePages(); panelSend.Show(); - buttonNavPortfolio.BackColor = ColorTranslator.FromHtml(theme["background"]); - buttonNavPortfolio.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - buttonNavReceive.BackColor = ColorTranslator.FromHtml(theme["background"]); - buttonNavReceive.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - buttonNavDomains.BackColor = ColorTranslator.FromHtml(theme["background"]); - buttonNavDomains.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); if (theme.ContainsKey("selected-bg") && theme.ContainsKey("selected-fg")) { buttonNavSend.BackColor = ColorTranslator.FromHtml(theme["selected-bg"]); @@ -837,12 +824,6 @@ namespace FireWallet { hidePages(); panelRecieve.Show(); - buttonNavSend.BackColor = ColorTranslator.FromHtml(theme["background"]); - buttonNavSend.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - buttonNavPortfolio.BackColor = ColorTranslator.FromHtml(theme["background"]); - buttonNavPortfolio.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - buttonNavDomains.BackColor = ColorTranslator.FromHtml(theme["background"]); - buttonNavDomains.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); if (theme.ContainsKey("selected-bg") && theme.ContainsKey("selected-fg")) { @@ -877,13 +858,6 @@ namespace FireWallet hidePages(); panelDomains.Show(); - buttonNavSend.BackColor = ColorTranslator.FromHtml(theme["background"]); - buttonNavSend.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - buttonNavPortfolio.BackColor = ColorTranslator.FromHtml(theme["background"]); - buttonNavPortfolio.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - buttonNavReceive.BackColor = ColorTranslator.FromHtml(theme["background"]); - buttonNavReceive.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - if (theme.ContainsKey("selected-bg") && theme.ContainsKey("selected-fg")) { buttonNavDomains.BackColor = ColorTranslator.FromHtml(theme["selected-bg"]); @@ -903,16 +877,34 @@ namespace FireWallet panelRecieve.Hide(); panelDomains.Hide(); panelSettings.Hide(); + buttonNavPortfolio.BackColor = ColorTranslator.FromHtml(theme["background"]); + buttonNavPortfolio.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); + buttonNavSend.BackColor = ColorTranslator.FromHtml(theme["background"]); + buttonNavSend.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); + buttonNavReceive.BackColor = ColorTranslator.FromHtml(theme["background"]); + buttonNavReceive.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); + buttonNavDomains.BackColor = ColorTranslator.FromHtml(theme["background"]); + buttonNavDomains.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); + buttonNavSettings.BackColor = ColorTranslator.FromHtml(theme["background"]); + buttonNavSettings.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); } private void buttonNavSettings_Click(object sender, EventArgs e) { hidePages(); + if (theme.ContainsKey("selected-bg") && theme.ContainsKey("selected-fg")) + { + buttonNavSettings.BackColor = ColorTranslator.FromHtml(theme["selected-bg"]); + buttonNavSettings.ForeColor = ColorTranslator.FromHtml(theme["selected-fg"]); + } + panelSettings.Show(); buttonSettingsSave.Top = panelSettings.Height - buttonSettingsSave.Height - 10; + labelSettingsSaved.Top = buttonSettingsSave.Top + 10; textBoxExTX.Text = userSettings["explorer-tx"]; textBoxExAddr.Text = userSettings["explorer-addr"]; textBoxExBlock.Text = userSettings["explorer-block"]; textBoxExName.Text = userSettings["explorer-domain"]; + numericUpDownConfirmations.Value = int.Parse(userSettings["confirmations"]); labelSettingsSaved.Hide(); } #endregion @@ -1193,7 +1185,7 @@ namespace FireWallet sw.WriteLine("explorer-block: " + textBoxExBlock.Text); sw.WriteLine("explorer-domain: " + textBoxExName.Text); - sw.WriteLine("confirmations: " + userSettings["confirmations"]); + sw.WriteLine("confirmations: " + numericUpDownConfirmations.Value); sw.WriteLine("portfolio-tx: " + userSettings["portfolio-tx"]); sw.WriteLine("hide-splash: " + userSettings["hide-splash"]); sw.Dispose();