Merge branch 'feature/ThemeCustomization' into develop

This commit is contained in:
Nathan Woodburn 2023-07-16 22:59:10 +10:00
commit 7909f111cb
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -8,6 +8,48 @@ public partial class MainForm : Form
{ {
private bool testedLogin; private bool testedLogin;
#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()
{
{ "Discord", "https://l.woodburn.au/discord" },
{ "Separator", "" },
{ "Github", "https://github.com/nathanwoodburn/FireWalletLite" }
};
// Min Confirmations for transactions to be considered valid
public int MinConfirmations = 1;
public Dictionary<string, string> Theme { get; set; } = new()
{
{ "background", "#000000" },
{ "foreground", "#8e05c2"},
{ "background-alt", "#3e065f"},
{ "foreground-alt", "#ffffff"}
};
#endregion
#region Variables
private readonly HttpClient httpClient = new();
private decimal Balance { get; set; }
public string Account = "primary";
public string Password { get; set; }
#endregion
public MainForm() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
@ -243,50 +285,15 @@ public partial class MainForm : Form
notifyForm2.Dispose(); notifyForm2.Dispose();
} }
#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()
{
{ "Discord", "https://l.woodburn.au/discord" },
{ "Separator", "" },
{ "Github", "https://github.com/nathanwoodburn/FireWalletLite" }
};
// Min Confirmations for transactions to be considered valid
public int MinConfirmations = 1;
#endregion
#region Variables
public Dictionary<string, string> Theme { get; set; }
private readonly HttpClient httpClient = new();
private decimal Balance { get; set; }
public string Account = "primary";
public string Password { get; set; }
#endregion
#region Theming #region Theming
private void UpdateTheme() private void UpdateTheme()
{ {
// Check if file exists // Check if file exists
if (!Directory.Exists(dir)) CreateConfig(dir); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
if (!File.Exists(dir + "theme.txt")) CreateConfig(dir); if (File.Exists(dir + "theme.txt")) // Use custom theme
{
// Read file // Read file
var sr = new StreamReader(dir + "theme.txt"); var sr = new StreamReader(dir + "theme.txt");
@ -299,6 +306,7 @@ public partial class MainForm : Form
} }
sr.Dispose(); sr.Dispose();
}
if (!Theme.ContainsKey("background") || !Theme.ContainsKey("background-alt") || if (!Theme.ContainsKey("background") || !Theme.ContainsKey("background-alt") ||
!Theme.ContainsKey("foreground") || !Theme.ContainsKey("foreground-alt")) !Theme.ContainsKey("foreground") || !Theme.ContainsKey("foreground-alt"))
@ -341,20 +349,6 @@ public partial class MainForm : Form
if (c.GetType() == typeof(Panel)) c.Dock = DockStyle.Fill; if (c.GetType() == typeof(Panel)) c.Dock = DockStyle.Fill;
} }
private void CreateConfig(string dir)
{
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
var streamWriter = new StreamWriter(dir + "theme.txt");
streamWriter.WriteLine("background: #000000");
streamWriter.WriteLine("foreground: #8e05c2");
streamWriter.WriteLine("background-alt: #3e065f");
streamWriter.WriteLine("foreground-alt: #ffffff");
streamWriter.WriteLine("error: #ff0000");
streamWriter.Dispose();
AddLog("Created theme file");
}
#endregion #endregion
#region API #region API