2023-07-15 20:46:58 +10:00
|
|
|
|
using System.Diagnostics;
|
2023-07-05 16:44:34 +10:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
namespace FireWallet;
|
|
|
|
|
|
|
|
|
|
public partial class NotifyForm : Form
|
2023-07-05 16:44:34 +10:00
|
|
|
|
{
|
2023-07-15 22:17:49 +10:00
|
|
|
|
private bool allowClose = true;
|
|
|
|
|
private readonly string altLink;
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
private readonly bool Linkcopy;
|
2023-07-19 15:06:25 +10:00
|
|
|
|
public Dictionary<string, string> Theme { get; set; } = new()
|
|
|
|
|
{
|
|
|
|
|
{ "background", "#000000" },
|
2023-07-19 22:38:17 +10:00
|
|
|
|
{ "foreground", "#fcba03"},
|
2023-07-19 15:06:25 +10:00
|
|
|
|
{ "background-alt", "#3e065f"},
|
|
|
|
|
{ "foreground-alt", "#ffffff"}
|
|
|
|
|
};
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
public NotifyForm(string Message)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
labelmessage.Text = Message;
|
|
|
|
|
altLink = "";
|
|
|
|
|
}
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
public NotifyForm(string Message, string altText, string altLink)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
labelmessage.Text = Message;
|
|
|
|
|
buttonALT.Text = altText;
|
|
|
|
|
buttonALT.Visible = true;
|
|
|
|
|
this.altLink = altLink;
|
|
|
|
|
buttonOK.Focus();
|
|
|
|
|
Linkcopy = false;
|
|
|
|
|
}
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
public NotifyForm(string Message, bool allowClose)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
labelmessage.Text = Message;
|
|
|
|
|
buttonOK.Focus();
|
|
|
|
|
Linkcopy = false;
|
|
|
|
|
buttonOK.Visible = allowClose;
|
|
|
|
|
allowClose = allowClose;
|
|
|
|
|
}
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
public NotifyForm(string Message, string altText, string altLink, bool Linkcopy)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
labelmessage.Text = Message;
|
|
|
|
|
buttonALT.Text = altText;
|
|
|
|
|
buttonALT.Visible = true;
|
|
|
|
|
this.altLink = altLink;
|
|
|
|
|
buttonOK.Focus();
|
|
|
|
|
this.Linkcopy = Linkcopy;
|
|
|
|
|
|
|
|
|
|
if (Linkcopy)
|
|
|
|
|
// Small font to fix more data
|
|
|
|
|
labelmessage.Font = new Font(labelmessage.Font.FontFamily, 10);
|
|
|
|
|
}
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
public void CloseNotification()
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
private void NotifyForm_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateTheme();
|
|
|
|
|
}
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
private void OK_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
allowClose = true;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
private void buttonALT_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Linkcopy)
|
|
|
|
|
{
|
|
|
|
|
// Copy link to clipboard
|
|
|
|
|
Clipboard.SetText(altLink);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
// Open link
|
|
|
|
|
var psi = new ProcessStartInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = altLink,
|
|
|
|
|
UseShellExecute = true
|
|
|
|
|
};
|
|
|
|
|
Process.Start(psi);
|
|
|
|
|
}
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
private void NotifyForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!allowClose) e.Cancel = true;
|
|
|
|
|
}
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
#region Theming
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
private void UpdateTheme()
|
|
|
|
|
{
|
2023-07-19 15:06:25 +10:00
|
|
|
|
if (!Theme.ContainsKey("background") || !Theme.ContainsKey("background-alt") ||
|
|
|
|
|
!Theme.ContainsKey("foreground") || !Theme.ContainsKey("foreground-alt")) return;
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-19 15:06:25 +10:00
|
|
|
|
// Apply Theme
|
|
|
|
|
BackColor = ColorTranslator.FromHtml(Theme["background"]);
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
// Foreground
|
2023-07-19 15:06:25 +10:00
|
|
|
|
ForeColor = ColorTranslator.FromHtml(Theme["foreground"]);
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
// Need to specify this for each groupbox to override the black text
|
|
|
|
|
foreach (Control c in Controls) ThemeControl(c);
|
|
|
|
|
}
|
2023-07-05 16:44:34 +10:00
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
private void ThemeControl(Control c)
|
|
|
|
|
{
|
2023-07-19 23:26:30 +10:00
|
|
|
|
FontFamily ff = new FontFamily("Verdana");
|
|
|
|
|
c.Font = new Font(ff, c.Font.Size, c.Font.Style);
|
2023-07-15 22:17:49 +10:00
|
|
|
|
if (c.GetType() == typeof(GroupBox) || c.GetType() == typeof(Panel))
|
2023-07-05 16:44:34 +10:00
|
|
|
|
{
|
2023-07-19 15:06:25 +10:00
|
|
|
|
c.ForeColor = ColorTranslator.FromHtml(Theme["foreground"]);
|
2023-07-15 22:17:49 +10:00
|
|
|
|
foreach (Control sub in c.Controls) ThemeControl(sub);
|
2023-07-05 16:44:34 +10:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-15 22:17:49 +10:00
|
|
|
|
if (c.GetType() == typeof(TextBox) || c.GetType() == typeof(Button)
|
|
|
|
|
|| c.GetType() == typeof(ComboBox) || c.GetType() == typeof(StatusStrip))
|
2023-07-05 16:44:34 +10:00
|
|
|
|
{
|
2023-07-19 15:06:25 +10:00
|
|
|
|
c.ForeColor = ColorTranslator.FromHtml(Theme["foreground-alt"]);
|
|
|
|
|
c.BackColor = ColorTranslator.FromHtml(Theme["background-alt"]);
|
2023-07-05 16:44:34 +10:00
|
|
|
|
}
|
2023-07-15 22:17:49 +10:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|