Merge branch 'develop'
This commit is contained in:
commit
14dad4ba35
@ -2,296 +2,295 @@
|
|||||||
using FireWallet;
|
using FireWallet;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace FireWalletLite
|
namespace FireWalletLite;
|
||||||
|
|
||||||
|
public partial class DomainForm : Form
|
||||||
{
|
{
|
||||||
public partial class DomainForm : Form
|
private readonly string Domain;
|
||||||
|
private readonly MainForm Main;
|
||||||
|
|
||||||
|
public DomainForm(MainForm main, string domain)
|
||||||
{
|
{
|
||||||
private MainForm Main;
|
InitializeComponent();
|
||||||
private string Domain;
|
Main = main;
|
||||||
public DomainForm(MainForm main, string domain)
|
Domain = domain;
|
||||||
|
Text = domain + "/";
|
||||||
|
// Theme form
|
||||||
|
BackColor = ColorTranslator.FromHtml(main.Theme["background"]);
|
||||||
|
ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]);
|
||||||
|
foreach (Control control in Controls) main.ThemeControl(control);
|
||||||
|
labelName.Text = domain + "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonExplorer_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var psi = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
FileName = Main.DomainExplorer + Domain,
|
||||||
this.Main = main;
|
UseShellExecute = true
|
||||||
this.Domain = domain;
|
};
|
||||||
Text = domain + "/";
|
Process.Start(psi);
|
||||||
// Theme form
|
}
|
||||||
BackColor = ColorTranslator.FromHtml(main.Theme["background"]);
|
|
||||||
ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]);
|
private void DomainForm_Load(object sender, EventArgs e)
|
||||||
foreach (Control control in Controls)
|
{
|
||||||
|
if (!File.Exists(Main.dir + "domains.json")) return;
|
||||||
|
|
||||||
|
var domains = JArray.Parse(File.ReadAllText(Main.dir + "domains.json"));
|
||||||
|
foreach (JObject domain in domains)
|
||||||
|
if (domain["name"].ToString() == Domain)
|
||||||
|
if (domain.ContainsKey("status"))
|
||||||
|
switch (domain["status"].ToString())
|
||||||
|
{
|
||||||
|
case "transferring":
|
||||||
|
buttonFinalize.Visible = true;
|
||||||
|
buttonCancel.Visible = true;
|
||||||
|
buttonTransfer.Visible = false;
|
||||||
|
textBoxTransferAddress.Visible = false;
|
||||||
|
break;
|
||||||
|
case "closed":
|
||||||
|
buttonCancel.Visible = false;
|
||||||
|
buttonFinalize.Visible = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void buttonRenew_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var content = "{\"method\": \"renew\", \"params\": [\"" + Domain + "\"]}";
|
||||||
|
var response = await Main.APIPost("", true, content);
|
||||||
|
if (response == "Error")
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Error renewing domain");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var jObject = JObject.Parse(response);
|
||||||
|
if (jObject.ContainsKey("result"))
|
||||||
|
{
|
||||||
|
Main.AddLog(jObject["result"].ToString());
|
||||||
|
var result = (JObject)jObject["result"];
|
||||||
|
if (result.ContainsKey("txid"))
|
||||||
{
|
{
|
||||||
main.ThemeControl(control);
|
var txid = result["txid"].ToString();
|
||||||
|
var notify = new NotifyForm("Renewed domain", "Explorer", Main.TXExplorer + txid);
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
}
|
}
|
||||||
labelName.Text = domain + "/";
|
else
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonExplorer_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ProcessStartInfo psi = new ProcessStartInfo
|
|
||||||
{
|
{
|
||||||
FileName = Main.DomainExplorer + Domain,
|
var notify = new NotifyForm("Error renewing domain");
|
||||||
UseShellExecute = true
|
notify.ShowDialog();
|
||||||
};
|
notify.Dispose();
|
||||||
Process.Start(psi);
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Error renewing domain");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
Main.AddLog(jObject.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void buttonTransfer_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var address = textBoxTransferAddress.Text;
|
||||||
|
var valid = await Main.ValidAddress(address);
|
||||||
|
if (!valid)
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Invalid address");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DomainForm_Load(object sender, EventArgs e)
|
var path = "wallet/" + Main.Account + "/transfer";
|
||||||
|
var content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain +
|
||||||
|
"\", \"broadcast\": true, \"sign\": true, \"address\": \"" + address + "\"}";
|
||||||
|
var response = await Main.APIPost(path, true, content);
|
||||||
|
if (response == "Error")
|
||||||
{
|
{
|
||||||
if (!File.Exists(Main.dir + "domains.json")) return;
|
var notify = new NotifyForm("Error transferring domain");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
JArray domains = JArray.Parse(File.ReadAllText(Main.dir + "domains.json"));
|
var jObject = JObject.Parse(response);
|
||||||
|
if (jObject.ContainsKey("hash"))
|
||||||
|
{
|
||||||
|
var txid = jObject["hash"].ToString();
|
||||||
|
var notify = new NotifyForm("Transferred domain", "Explorer", Main.TXExplorer + txid);
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
AddDomainInfo("transferring");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Error transferring domain");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonFinalize_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var path = "wallet/" + Main.Account + "/finalize";
|
||||||
|
var content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain +
|
||||||
|
"\", \"broadcast\": true, \"sign\": true}";
|
||||||
|
var response = Main.APIPost(path, true, content).Result;
|
||||||
|
if (response == "Error")
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Error finalizing transfer");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var jObject = JObject.Parse(response);
|
||||||
|
if (jObject.ContainsKey("hash"))
|
||||||
|
{
|
||||||
|
var txid = jObject["hash"].ToString();
|
||||||
|
var notify = new NotifyForm("Finalized domain", "Explorer", Main.TXExplorer + txid);
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
AddDomainInfo("closed");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Error finalizing domain");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var path = "wallet/" + Main.Account + "/cancel";
|
||||||
|
var content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain +
|
||||||
|
"\", \"broadcast\": true, \"sign\": true}";
|
||||||
|
var response = Main.APIPost(path, true, content).Result;
|
||||||
|
if (response == "Error")
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Error cancelling transfer");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var jObject = JObject.Parse(response);
|
||||||
|
if (jObject.ContainsKey("hash"))
|
||||||
|
{
|
||||||
|
var txid = jObject["hash"].ToString();
|
||||||
|
var notify = new NotifyForm("Canceled transfer", "Explorer", Main.TXExplorer + txid);
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
AddDomainInfo("closed");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Error cancelling transfer");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddDomainInfo(string status)
|
||||||
|
{
|
||||||
|
if (File.Exists(Main.dir + "domains.json"))
|
||||||
|
{
|
||||||
|
var found = false;
|
||||||
|
var domains = JArray.Parse(File.ReadAllText(Main.dir + "domains.json"));
|
||||||
foreach (JObject domain in domains)
|
foreach (JObject domain in domains)
|
||||||
{
|
|
||||||
if (domain["name"].ToString() == Domain)
|
if (domain["name"].ToString() == Domain)
|
||||||
{
|
{
|
||||||
|
found = true;
|
||||||
if (domain.ContainsKey("status"))
|
if (domain.ContainsKey("status"))
|
||||||
{
|
domain["status"] = status;
|
||||||
switch (domain["status"].ToString())
|
else
|
||||||
{
|
domain.Add("status", status);
|
||||||
case "transferring":
|
|
||||||
buttonFinalize.Visible = true;
|
|
||||||
buttonCancel.Visible = true;
|
|
||||||
buttonTransfer.Visible = false;
|
|
||||||
textBoxTransferAddress.Visible = false;
|
|
||||||
break;
|
|
||||||
case "closed":
|
|
||||||
buttonCancel.Visible = false;
|
|
||||||
buttonFinalize.Visible = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void buttonRenew_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string content = "{\"method\": \"renew\", \"params\": [\"" + Domain + "\"]}";
|
|
||||||
string response = await Main.APIPost("", true, content);
|
|
||||||
if (response == "Error")
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Error renewing domain");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JObject jObject = JObject.Parse(response);
|
|
||||||
if (jObject.ContainsKey("result"))
|
|
||||||
{
|
|
||||||
Main.AddLog(jObject["result"].ToString());
|
|
||||||
JObject result = (JObject)jObject["result"];
|
|
||||||
if (result.ContainsKey("txid"))
|
|
||||||
{
|
|
||||||
string txid = result["txid"].ToString();
|
|
||||||
NotifyForm notify = new NotifyForm("Renewed domain", "Explorer", Main.TXExplorer + txid);
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Error renewing domain");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Error renewing domain");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
Main.AddLog(jObject.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void buttonTransfer_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string address = textBoxTransferAddress.Text;
|
|
||||||
bool valid = await Main.ValidAddress(address);
|
|
||||||
if (!valid)
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Invalid address");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
string path = "wallet/" + Main.Account + "/transfer";
|
|
||||||
string content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain + "\", \"broadcast\": true, \"sign\": true, \"address\": \"" + address + "\"}";
|
|
||||||
string response = await Main.APIPost(path, true, content);
|
|
||||||
if (response == "Error")
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Error transferring domain");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JObject jObject = JObject.Parse(response);
|
|
||||||
if (jObject.ContainsKey("hash"))
|
|
||||||
{
|
|
||||||
string txid = jObject["hash"].ToString();
|
|
||||||
NotifyForm notify = new NotifyForm("Transferred domain", "Explorer", Main.TXExplorer + txid);
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
AddDomainInfo("transferring");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Error transferring domain");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonFinalize_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string path = "wallet/" + Main.Account + "/finalize";
|
|
||||||
string content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain + "\", \"broadcast\": true, \"sign\": true}";
|
|
||||||
string response = Main.APIPost(path, true, content).Result;
|
|
||||||
if (response == "Error")
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Error finalizing transfer");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JObject jObject = JObject.Parse(response);
|
|
||||||
if (jObject.ContainsKey("hash"))
|
|
||||||
{
|
|
||||||
string txid = jObject["hash"].ToString();
|
|
||||||
NotifyForm notify = new NotifyForm("Finalized domain", "Explorer", Main.TXExplorer + txid);
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
AddDomainInfo("closed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Error finalizing domain");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void buttonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string path = "wallet/" + Main.Account + "/cancel";
|
|
||||||
string content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain + "\", \"broadcast\": true, \"sign\": true}";
|
|
||||||
string response = Main.APIPost(path, true, content).Result;
|
|
||||||
if (response == "Error")
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Error cancelling transfer");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JObject jObject = JObject.Parse(response);
|
|
||||||
if (jObject.ContainsKey("hash"))
|
|
||||||
{
|
|
||||||
string txid = jObject["hash"].ToString();
|
|
||||||
NotifyForm notify = new NotifyForm("Canceled transfer", "Explorer", Main.TXExplorer + txid);
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
AddDomainInfo("closed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Error cancelling transfer");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddDomainInfo(string status)
|
|
||||||
{
|
|
||||||
if (File.Exists(Main.dir + "domains.json"))
|
|
||||||
{
|
|
||||||
bool found = false;
|
|
||||||
JArray domains = JArray.Parse(File.ReadAllText(Main.dir + "domains.json"));
|
|
||||||
foreach (JObject domain in domains)
|
|
||||||
{
|
|
||||||
if (domain["name"].ToString() == Domain)
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
if (domain.ContainsKey("status"))
|
|
||||||
{
|
|
||||||
domain["status"] = status;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
domain.Add("status", status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
|
||||||
JObject domain = new JObject();
|
|
||||||
domain["name"] = Domain;
|
|
||||||
domain["status"] = status;
|
|
||||||
domains.Add(domain);
|
|
||||||
}
|
|
||||||
File.WriteAllText(Main.dir + "domains.json", domains.ToString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
JArray domains = new JArray();
|
var domain = new JObject();
|
||||||
JObject domain = new JObject();
|
|
||||||
domain["name"] = Domain;
|
domain["name"] = Domain;
|
||||||
domain["status"] = status;
|
domain["status"] = status;
|
||||||
domains.Add(domain);
|
domains.Add(domain);
|
||||||
File.WriteAllText(Main.dir + "domains.json", domains.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File.WriteAllText(Main.dir + "domains.json", domains.ToString());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private async void buttonSign_Click(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
if (buttonSign.Text == "Save")
|
var domains = new JArray();
|
||||||
{
|
var domain = new JObject();
|
||||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
domain["name"] = Domain;
|
||||||
saveFileDialog.Filter = "Text File|*.txt";
|
domain["status"] = status;
|
||||||
saveFileDialog.Title = "Save Signature";
|
domains.Add(domain);
|
||||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
File.WriteAllText(Main.dir + "domains.json", domains.ToString());
|
||||||
{
|
|
||||||
JObject signature = new JObject();
|
|
||||||
signature["domain"] = Domain;
|
|
||||||
signature["message"] = textBoxSignMessage.Text;
|
|
||||||
signature["signature"] = textBoxSignature.Text;
|
|
||||||
signature["time"] = DateTime.Now.ToString();
|
|
||||||
File.WriteAllText(saveFileDialog.FileName, signature.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (textBoxSignMessage.Text == "")
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Enter a message to sign");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
string content = "{\"method\": \"signmessagewithname\", \"params\": [\"" + Domain + "\", \"" + textBoxSignMessage.Text + "\"]}";
|
|
||||||
string response = await Main.APIPost("", true, content);
|
|
||||||
if (response == "Error")
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Error signing message");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JObject jObject = JObject.Parse(response);
|
|
||||||
if (jObject.ContainsKey("result"))
|
|
||||||
{
|
|
||||||
textBoxSignature.Text = jObject["result"].ToString();
|
|
||||||
buttonSign.Text = "Save";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Main.AddLog(response);
|
|
||||||
NotifyForm notify = new NotifyForm("Error signing message");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void textBoxSignMessage_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
buttonSign.Text = "Sign";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private async void buttonSign_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (buttonSign.Text == "Save")
|
||||||
|
{
|
||||||
|
var saveFileDialog = new SaveFileDialog();
|
||||||
|
saveFileDialog.Filter = "Text File|*.txt";
|
||||||
|
saveFileDialog.Title = "Save Signature";
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
var signature = new JObject();
|
||||||
|
signature["domain"] = Domain;
|
||||||
|
signature["message"] = textBoxSignMessage.Text;
|
||||||
|
signature["signature"] = textBoxSignature.Text;
|
||||||
|
signature["time"] = DateTime.Now.ToString();
|
||||||
|
File.WriteAllText(saveFileDialog.FileName, signature.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textBoxSignMessage.Text == "")
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Enter a message to sign");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var content = "{\"method\": \"signmessagewithname\", \"params\": [\"" + Domain + "\", \"" +
|
||||||
|
textBoxSignMessage.Text + "\"]}";
|
||||||
|
var response = await Main.APIPost("", true, content);
|
||||||
|
if (response == "Error")
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Error signing message");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var jObject = JObject.Parse(response);
|
||||||
|
if (jObject.ContainsKey("result"))
|
||||||
|
{
|
||||||
|
textBoxSignature.Text = jObject["result"].ToString();
|
||||||
|
buttonSign.Text = "Save";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Main.AddLog(response);
|
||||||
|
var notify = new NotifyForm("Error signing message");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void textBoxSignMessage_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
buttonSign.Text = "Sign";
|
||||||
|
}
|
||||||
|
}
|
@ -1,59 +1,56 @@
|
|||||||
using FireWallet;
|
using FireWallet;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace FireWalletLite
|
namespace FireWalletLite;
|
||||||
|
|
||||||
|
public partial class FirstLoginForm : Form
|
||||||
{
|
{
|
||||||
public partial class FirstLoginForm : Form
|
private readonly MainForm main;
|
||||||
|
private string seedPhrase;
|
||||||
|
|
||||||
|
public FirstLoginForm(string seedPhrase, MainForm mainForm)
|
||||||
{
|
{
|
||||||
String seedPhrase;
|
InitializeComponent();
|
||||||
MainForm main;
|
this.seedPhrase = seedPhrase;
|
||||||
public FirstLoginForm(string seedPhrase, MainForm mainForm)
|
main = mainForm;
|
||||||
{
|
// Theme form
|
||||||
InitializeComponent();
|
BackColor = ColorTranslator.FromHtml(mainForm.Theme["background"]);
|
||||||
this.seedPhrase = seedPhrase;
|
ForeColor = ColorTranslator.FromHtml(mainForm.Theme["foreground"]);
|
||||||
this.main = mainForm;
|
foreach (Control control in Controls) mainForm.ThemeControl(control);
|
||||||
// Theme form
|
textBoxSeed.Text = seedPhrase;
|
||||||
this.BackColor = ColorTranslator.FromHtml(mainForm.Theme["background"]);
|
|
||||||
this.ForeColor = ColorTranslator.FromHtml(mainForm.Theme["foreground"]);
|
|
||||||
foreach (Control control in Controls)
|
|
||||||
{
|
|
||||||
mainForm.ThemeControl(control);
|
|
||||||
}
|
|
||||||
textBoxSeed.Text = seedPhrase;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void Start_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (textBoxPassword.Text.Length < 8)
|
|
||||||
{
|
|
||||||
NotifyForm notifyForm = new NotifyForm("Please choose a longer password!");
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (textBoxPassword.Text != textBoxPassword2.Text)
|
|
||||||
{
|
|
||||||
NotifyForm notifyForm = new NotifyForm("Passwords do not match!");
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encrypt wallet
|
|
||||||
string content = "{\"method\":\"encryptwallet\",\"params\":[\"" + textBoxPassword.Text + "\"]}";
|
|
||||||
string response = await main.APIPost("",true,content);
|
|
||||||
main.AddLog("Encrypt wallet: " + response);
|
|
||||||
JObject jObject = JObject.Parse(response);
|
|
||||||
if (jObject["error"].ToString() != "")
|
|
||||||
{
|
|
||||||
NotifyForm notifyForm = new NotifyForm("Error encrypting wallet: " + jObject["error"].ToString());
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
return;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
this.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private async void Start_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (textBoxPassword.Text.Length < 8)
|
||||||
|
{
|
||||||
|
var notifyForm = new NotifyForm("Please choose a longer password!");
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textBoxPassword.Text != textBoxPassword2.Text)
|
||||||
|
{
|
||||||
|
var notifyForm = new NotifyForm("Passwords do not match!");
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encrypt wallet
|
||||||
|
var content = "{\"method\":\"encryptwallet\",\"params\":[\"" + textBoxPassword.Text + "\"]}";
|
||||||
|
var response = await main.APIPost("", true, content);
|
||||||
|
main.AddLog("Encrypt wallet: " + response);
|
||||||
|
var jObject = JObject.Parse(response);
|
||||||
|
if (jObject["error"].ToString() != "")
|
||||||
|
{
|
||||||
|
var notifyForm = new NotifyForm("Error encrypting wallet: " + jObject["error"]);
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
@ -2,237 +2,243 @@ using System.Diagnostics;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using FireWallet;
|
using FireWallet;
|
||||||
|
|
||||||
namespace FireWalletLite
|
namespace FireWalletLite;
|
||||||
|
|
||||||
|
public partial class Loader : Form
|
||||||
{
|
{
|
||||||
public partial class Loader : Form
|
public Loader()
|
||||||
{
|
{
|
||||||
#region Constants
|
InitializeComponent();
|
||||||
MainForm mainForm = new MainForm();
|
|
||||||
bool hideScreen = false;
|
|
||||||
Process HSDProcess;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public Loader()
|
var splashScreen = new SplashScreen(false);
|
||||||
|
splashScreen.Show();
|
||||||
|
Application.DoEvents();
|
||||||
|
var start = DateTime.Now;
|
||||||
|
// Install and load node
|
||||||
|
var dir = mainForm.dir;
|
||||||
|
HSDProcess = new Process();
|
||||||
|
if (!Directory.Exists(dir)) Environment.Exit(1);
|
||||||
|
var hsdPath = dir + "hsd\\bin\\hsd.exe";
|
||||||
|
if (!Directory.Exists(dir + "hsd"))
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
var repositoryUrl = "https://github.com/handshake-org/hsd.git";
|
||||||
|
var destinationPath = dir + "hsd";
|
||||||
|
CloneRepository(repositoryUrl, destinationPath);
|
||||||
|
}
|
||||||
|
|
||||||
SplashScreen splashScreen = new SplashScreen(false);
|
// Start HSD
|
||||||
splashScreen.Show();
|
HSDProcess.StartInfo.RedirectStandardInput = true;
|
||||||
|
HSDProcess.StartInfo.RedirectStandardOutput = false;
|
||||||
|
HSDProcess.StartInfo.UseShellExecute = false;
|
||||||
|
HSDProcess.StartInfo.FileName = "node.exe";
|
||||||
|
HSDProcess.StartInfo.Arguments = dir + "hsd\\bin\\hsd --agent=FireWallet --spv --prefix " + dir + "\\hsd_data";
|
||||||
|
HSDProcess.StartInfo.CreateNoWindow = hideScreen;
|
||||||
|
if (hideScreen)
|
||||||
|
{
|
||||||
|
HSDProcess.StartInfo.RedirectStandardError = true;
|
||||||
|
// Send errors to log
|
||||||
|
HSDProcess.ErrorDataReceived += (sender, e) => mainForm.AddLog("HSD Error: " + e.Data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HSDProcess.StartInfo.RedirectStandardError = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HSDProcess.Start();
|
||||||
|
while ((DateTime.Now - start).TotalSeconds < 5)
|
||||||
|
{
|
||||||
|
Thread.Sleep(10);
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
DateTime start = DateTime.Now;
|
}
|
||||||
// Install and load node
|
|
||||||
string dir = mainForm.dir;
|
splashScreen.CloseSplash();
|
||||||
HSDProcess = new Process();
|
while (!splashScreen.IsClosed)
|
||||||
if (!Directory.Exists(dir)) Environment.Exit(1);
|
{
|
||||||
string hsdPath = dir + "hsd\\bin\\hsd.exe";
|
Thread.Sleep(10);
|
||||||
if (!Directory.Exists(dir + "hsd"))
|
Application.DoEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
splashScreen.Dispose();
|
||||||
|
mainForm.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Constants
|
||||||
|
|
||||||
|
private readonly MainForm mainForm = new();
|
||||||
|
private readonly bool hideScreen = true;
|
||||||
|
private readonly Process HSDProcess;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Git
|
||||||
|
|
||||||
|
public void CloneRepository(string repositoryUrl, string destinationPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Check if git is installed
|
||||||
|
var testInstalled = new Process();
|
||||||
|
testInstalled.StartInfo.FileName = "git";
|
||||||
|
testInstalled.StartInfo.Arguments = "-v";
|
||||||
|
testInstalled.StartInfo.RedirectStandardOutput = true;
|
||||||
|
testInstalled.StartInfo.UseShellExecute = false;
|
||||||
|
testInstalled.StartInfo.CreateNoWindow = true;
|
||||||
|
testInstalled.Start();
|
||||||
|
var outputInstalled = testInstalled.StandardOutput.ReadToEnd();
|
||||||
|
testInstalled.WaitForExit();
|
||||||
|
|
||||||
|
if (!outputInstalled.Contains("git version"))
|
||||||
{
|
{
|
||||||
string repositoryUrl = "https://github.com/handshake-org/hsd.git";
|
mainForm.AddLog("Git is not installed");
|
||||||
string destinationPath = dir + "hsd";
|
var notifyForm = new NotifyForm("Git is not installed\nPlease install it to install HSD dependencies",
|
||||||
CloneRepository(repositoryUrl, destinationPath);
|
"Install", "https://git-scm.com/download/win");
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
Environment.Exit(21);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// Start HSD
|
|
||||||
HSDProcess.StartInfo.RedirectStandardInput = true;
|
// Check if node installed
|
||||||
HSDProcess.StartInfo.RedirectStandardOutput = false;
|
testInstalled = new Process();
|
||||||
HSDProcess.StartInfo.UseShellExecute = false;
|
testInstalled.StartInfo.FileName = "node";
|
||||||
HSDProcess.StartInfo.FileName = "node.exe";
|
testInstalled.StartInfo.Arguments = "-v";
|
||||||
HSDProcess.StartInfo.Arguments = dir + "hsd\\bin\\hsd --agent=FireWallet --spv --prefix " + dir + "\\hsd_data";
|
testInstalled.StartInfo.RedirectStandardOutput = true;
|
||||||
HSDProcess.StartInfo.CreateNoWindow = hideScreen;
|
testInstalled.StartInfo.UseShellExecute = false;
|
||||||
if (hideScreen)
|
testInstalled.StartInfo.CreateNoWindow = true;
|
||||||
|
testInstalled.Start();
|
||||||
|
outputInstalled = testInstalled.StandardOutput.ReadToEnd();
|
||||||
|
testInstalled.WaitForExit();
|
||||||
|
|
||||||
|
if (!outputInstalled.Contains("v"))
|
||||||
{
|
{
|
||||||
HSDProcess.StartInfo.RedirectStandardError = true;
|
mainForm.AddLog("Node is not installed");
|
||||||
// Send errors to log
|
var notifyForm = new NotifyForm("Node is not installed\nPlease install it to install HSD dependencies",
|
||||||
HSDProcess.ErrorDataReceived += (sender, e) => mainForm.AddLog("HSD Error: " + e.Data);
|
"Install", "https://nodejs.org/en/download");
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
Environment.Exit(22);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Check if npm installed
|
||||||
|
testInstalled = new Process();
|
||||||
|
testInstalled.StartInfo.FileName = "cmd.exe";
|
||||||
|
testInstalled.StartInfo.Arguments = "npm -v";
|
||||||
|
testInstalled.StartInfo.RedirectStandardOutput = true;
|
||||||
|
testInstalled.StartInfo.UseShellExecute = false;
|
||||||
|
testInstalled.StartInfo.CreateNoWindow = false;
|
||||||
|
testInstalled.Start();
|
||||||
|
// Wait 3 seconds and then kill
|
||||||
|
Thread.Sleep(3000);
|
||||||
|
testInstalled.Kill();
|
||||||
|
outputInstalled = testInstalled.StandardOutput.ReadToEnd();
|
||||||
|
testInstalled.WaitForExit();
|
||||||
|
if (Regex.IsMatch(outputInstalled, @"^\d+\.\d+\.\d+$"))
|
||||||
|
{
|
||||||
|
mainForm.AddLog("NPM is not installed");
|
||||||
|
mainForm.AddLog(outputInstalled);
|
||||||
|
var notifyForm = new NotifyForm("NPM is not installed\nPlease install it to install HSD dependencies",
|
||||||
|
"Install", "https://docs.npmjs.com/downloading-and-installing-node-js-and-npm");
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
Environment.Exit(23);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mainForm.AddLog("Prerequisites installed");
|
||||||
|
|
||||||
|
var startInfo = new ProcessStartInfo();
|
||||||
|
startInfo.FileName = "git";
|
||||||
|
startInfo.Arguments = $"clone {repositoryUrl} {destinationPath}";
|
||||||
|
|
||||||
|
if (repositoryUrl == "https://github.com/handshake-org/hsd.git")
|
||||||
|
startInfo.Arguments = $"clone --depth 1 --branch latest {repositoryUrl} {destinationPath}";
|
||||||
|
|
||||||
|
startInfo.RedirectStandardOutput = true;
|
||||||
|
startInfo.UseShellExecute = false;
|
||||||
|
startInfo.CreateNoWindow = hideScreen;
|
||||||
|
|
||||||
|
var process = new Process();
|
||||||
|
process.StartInfo = startInfo;
|
||||||
|
process.Start();
|
||||||
|
|
||||||
|
var output = process.StandardOutput.ReadToEnd();
|
||||||
|
process.WaitForExit();
|
||||||
|
|
||||||
|
while (!process.HasExited) output += process.StandardOutput.ReadToEnd();
|
||||||
|
var psiNpmRunDist = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "cmd",
|
||||||
|
RedirectStandardInput = true,
|
||||||
|
WorkingDirectory = destinationPath,
|
||||||
|
CreateNoWindow = hideScreen
|
||||||
|
};
|
||||||
|
var pNpmRunDist = Process.Start(psiNpmRunDist);
|
||||||
|
pNpmRunDist.StandardInput.WriteLine("npm install & exit");
|
||||||
|
pNpmRunDist.WaitForExit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
mainForm.AddLog("Git/NPM Install FAILED");
|
||||||
|
mainForm.AddLog(ex.Message);
|
||||||
|
if (ex.Message.Contains("to start process 'git'"))
|
||||||
|
{
|
||||||
|
var notifyForm = new NotifyForm("Git needs to be installed\nCheck logs for more details");
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
}
|
||||||
|
else if (ex.Message.Contains("to start process 'node'"))
|
||||||
|
{
|
||||||
|
var notifyForm = new NotifyForm("Node needs to be installed\nCheck logs for more details");
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
}
|
||||||
|
else if (ex.Message.Contains("to start process 'npm'"))
|
||||||
|
{
|
||||||
|
var notifyForm = new NotifyForm("NPM needs to be installed\nCheck logs for more details");
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HSDProcess.StartInfo.RedirectStandardError = false;
|
var notifyForm = new NotifyForm("Git/NPM Install FAILED\nCheck logs for more details");
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
}
|
}
|
||||||
HSDProcess.Start();
|
|
||||||
while ((DateTime.Now - start).TotalSeconds < 5)
|
Environment.Exit(24);
|
||||||
{
|
|
||||||
Thread.Sleep(10);
|
|
||||||
Application.DoEvents();
|
|
||||||
}
|
|
||||||
splashScreen.CloseSplash();
|
|
||||||
while (!splashScreen.IsClosed)
|
|
||||||
{
|
|
||||||
Thread.Sleep(10);
|
|
||||||
Application.DoEvents();
|
|
||||||
}
|
|
||||||
splashScreen.Dispose();
|
|
||||||
mainForm.Show();
|
|
||||||
}
|
}
|
||||||
#region Git
|
|
||||||
public void CloneRepository(string repositoryUrl, string destinationPath)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Check if git is installed
|
|
||||||
Process testInstalled = new Process();
|
|
||||||
testInstalled.StartInfo.FileName = "git";
|
|
||||||
testInstalled.StartInfo.Arguments = "-v";
|
|
||||||
testInstalled.StartInfo.RedirectStandardOutput = true;
|
|
||||||
testInstalled.StartInfo.UseShellExecute = false;
|
|
||||||
testInstalled.StartInfo.CreateNoWindow = true;
|
|
||||||
testInstalled.Start();
|
|
||||||
string outputInstalled = testInstalled.StandardOutput.ReadToEnd();
|
|
||||||
testInstalled.WaitForExit();
|
|
||||||
|
|
||||||
if (!outputInstalled.Contains("git version"))
|
|
||||||
{
|
|
||||||
mainForm.AddLog("Git is not installed");
|
|
||||||
NotifyForm notifyForm = new NotifyForm("Git is not installed\nPlease install it to install HSD dependencies", "Install", "https://git-scm.com/download/win");
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
Environment.Exit(21);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if node installed
|
|
||||||
testInstalled = new Process();
|
|
||||||
testInstalled.StartInfo.FileName = "node";
|
|
||||||
testInstalled.StartInfo.Arguments = "-v";
|
|
||||||
testInstalled.StartInfo.RedirectStandardOutput = true;
|
|
||||||
testInstalled.StartInfo.UseShellExecute = false;
|
|
||||||
testInstalled.StartInfo.CreateNoWindow = true;
|
|
||||||
testInstalled.Start();
|
|
||||||
outputInstalled = testInstalled.StandardOutput.ReadToEnd();
|
|
||||||
testInstalled.WaitForExit();
|
|
||||||
|
|
||||||
if (!outputInstalled.Contains("v"))
|
|
||||||
{
|
|
||||||
mainForm.AddLog("Node is not installed");
|
|
||||||
NotifyForm notifyForm = new NotifyForm("Node is not installed\nPlease install it to install HSD dependencies", "Install", "https://nodejs.org/en/download");
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
Environment.Exit(22);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Check if npm installed
|
|
||||||
testInstalled = new Process();
|
|
||||||
testInstalled.StartInfo.FileName = "cmd.exe";
|
|
||||||
testInstalled.StartInfo.Arguments = "npm -v";
|
|
||||||
testInstalled.StartInfo.RedirectStandardOutput = true;
|
|
||||||
testInstalled.StartInfo.UseShellExecute = false;
|
|
||||||
testInstalled.StartInfo.CreateNoWindow = false;
|
|
||||||
testInstalled.Start();
|
|
||||||
// Wait 3 seconds and then kill
|
|
||||||
Thread.Sleep(3000);
|
|
||||||
testInstalled.Kill();
|
|
||||||
outputInstalled = testInstalled.StandardOutput.ReadToEnd();
|
|
||||||
testInstalled.WaitForExit();
|
|
||||||
if (Regex.IsMatch(outputInstalled, @"^\d+\.\d+\.\d+$"))
|
|
||||||
{
|
|
||||||
mainForm.AddLog("NPM is not installed");
|
|
||||||
mainForm.AddLog(outputInstalled);
|
|
||||||
NotifyForm notifyForm = new NotifyForm("NPM is not installed\nPlease install it to install HSD dependencies", "Install", "https://docs.npmjs.com/downloading-and-installing-node-js-and-npm");
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
Environment.Exit(23);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mainForm.AddLog("Prerequisites installed");
|
|
||||||
|
|
||||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
|
||||||
startInfo.FileName = "git";
|
|
||||||
startInfo.Arguments = $"clone {repositoryUrl} {destinationPath}";
|
|
||||||
|
|
||||||
if (repositoryUrl == "https://github.com/handshake-org/hsd.git")
|
|
||||||
{
|
|
||||||
startInfo.Arguments = $"clone --depth 1 --branch latest {repositoryUrl} {destinationPath}";
|
|
||||||
}
|
|
||||||
|
|
||||||
startInfo.RedirectStandardOutput = true;
|
|
||||||
startInfo.UseShellExecute = false;
|
|
||||||
startInfo.CreateNoWindow = hideScreen;
|
|
||||||
|
|
||||||
Process process = new Process();
|
|
||||||
process.StartInfo = startInfo;
|
|
||||||
process.Start();
|
|
||||||
|
|
||||||
string output = process.StandardOutput.ReadToEnd();
|
|
||||||
process.WaitForExit();
|
|
||||||
|
|
||||||
while (!process.HasExited)
|
|
||||||
{
|
|
||||||
output += process.StandardOutput.ReadToEnd();
|
|
||||||
}
|
|
||||||
var psiNpmRunDist = new ProcessStartInfo
|
|
||||||
{
|
|
||||||
FileName = "cmd",
|
|
||||||
RedirectStandardInput = true,
|
|
||||||
WorkingDirectory = destinationPath,
|
|
||||||
CreateNoWindow = hideScreen
|
|
||||||
};
|
|
||||||
var pNpmRunDist = Process.Start(psiNpmRunDist);
|
|
||||||
pNpmRunDist.StandardInput.WriteLine("npm install & exit");
|
|
||||||
pNpmRunDist.WaitForExit();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
mainForm.AddLog("Git/NPM Install FAILED");
|
|
||||||
mainForm.AddLog(ex.Message);
|
|
||||||
if (ex.Message.Contains("to start process 'git'"))
|
|
||||||
{
|
|
||||||
NotifyForm notifyForm = new NotifyForm("Git needs to be installed\nCheck logs for more details");
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
}
|
|
||||||
else if (ex.Message.Contains("to start process 'node'"))
|
|
||||||
{
|
|
||||||
NotifyForm notifyForm = new NotifyForm("Node needs to be installed\nCheck logs for more details");
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
}
|
|
||||||
else if (ex.Message.Contains("to start process 'npm'"))
|
|
||||||
{
|
|
||||||
NotifyForm notifyForm = new NotifyForm("NPM needs to be installed\nCheck logs for more details");
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
NotifyForm notifyForm = new NotifyForm("Git/NPM Install FAILED\nCheck logs for more details");
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
}
|
|
||||||
Environment.Exit(24);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public bool CheckNodeInstalled()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Create a new process to execute the 'node' command
|
|
||||||
Process process = new Process();
|
|
||||||
process.StartInfo.FileName = "node";
|
|
||||||
process.StartInfo.Arguments = "--version";
|
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
|
||||||
process.StartInfo.UseShellExecute = false;
|
|
||||||
process.StartInfo.CreateNoWindow = true;
|
|
||||||
|
|
||||||
// Start the process and read the output
|
|
||||||
process.Start();
|
|
||||||
string output = process.StandardOutput.ReadToEnd();
|
|
||||||
|
|
||||||
// Wait for the process to exit
|
|
||||||
process.WaitForExit();
|
|
||||||
|
|
||||||
// Check if the output contains a version number
|
|
||||||
return !string.IsNullOrEmpty(output);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// An exception occurred, indicating that 'node' is not installed or accessible
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CheckNodeInstalled()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Create a new process to execute the 'node' command
|
||||||
|
var process = new Process();
|
||||||
|
process.StartInfo.FileName = "node";
|
||||||
|
process.StartInfo.Arguments = "--version";
|
||||||
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
|
process.StartInfo.UseShellExecute = false;
|
||||||
|
process.StartInfo.CreateNoWindow = true;
|
||||||
|
|
||||||
|
// Start the process and read the output
|
||||||
|
process.Start();
|
||||||
|
var output = process.StandardOutput.ReadToEnd();
|
||||||
|
|
||||||
|
// Wait for the process to exit
|
||||||
|
process.WaitForExit();
|
||||||
|
|
||||||
|
// Check if the output contains a version number
|
||||||
|
return !string.IsNullOrEmpty(output);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// An exception occurred, indicating that 'node' is not installed or accessible
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
13
FireWalletLite/MainForm.Designer.cs
generated
13
FireWalletLite/MainForm.Designer.cs
generated
@ -44,7 +44,6 @@
|
|||||||
LoginButton = new Button();
|
LoginButton = new Button();
|
||||||
panelPortfolio = new Panel();
|
panelPortfolio = new Panel();
|
||||||
groupBoxHistory = new GroupBox();
|
groupBoxHistory = new GroupBox();
|
||||||
panelHistory = new Panel();
|
|
||||||
buttonRenew = new Button();
|
buttonRenew = new Button();
|
||||||
groupBoxDomains = new GroupBox();
|
groupBoxDomains = new GroupBox();
|
||||||
panelDomainList = new Panel();
|
panelDomainList = new Panel();
|
||||||
@ -59,7 +58,6 @@
|
|||||||
((System.ComponentModel.ISupportInitialize)pictureBoxLogo).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxLogo).BeginInit();
|
||||||
groupBoxLogin.SuspendLayout();
|
groupBoxLogin.SuspendLayout();
|
||||||
panelPortfolio.SuspendLayout();
|
panelPortfolio.SuspendLayout();
|
||||||
groupBoxHistory.SuspendLayout();
|
|
||||||
groupBoxDomains.SuspendLayout();
|
groupBoxDomains.SuspendLayout();
|
||||||
panelNav.SuspendLayout();
|
panelNav.SuspendLayout();
|
||||||
groupBoxAccount.SuspendLayout();
|
groupBoxAccount.SuspendLayout();
|
||||||
@ -195,7 +193,6 @@
|
|||||||
//
|
//
|
||||||
// groupBoxHistory
|
// groupBoxHistory
|
||||||
//
|
//
|
||||||
groupBoxHistory.Controls.Add(panelHistory);
|
|
||||||
groupBoxHistory.Location = new Point(102, 226);
|
groupBoxHistory.Location = new Point(102, 226);
|
||||||
groupBoxHistory.Name = "groupBoxHistory";
|
groupBoxHistory.Name = "groupBoxHistory";
|
||||||
groupBoxHistory.Size = new Size(299, 293);
|
groupBoxHistory.Size = new Size(299, 293);
|
||||||
@ -203,14 +200,6 @@
|
|||||||
groupBoxHistory.TabStop = false;
|
groupBoxHistory.TabStop = false;
|
||||||
groupBoxHistory.Text = "History";
|
groupBoxHistory.Text = "History";
|
||||||
//
|
//
|
||||||
// panelHistory
|
|
||||||
//
|
|
||||||
panelHistory.Dock = DockStyle.Fill;
|
|
||||||
panelHistory.Location = new Point(3, 19);
|
|
||||||
panelHistory.Name = "panelHistory";
|
|
||||||
panelHistory.Size = new Size(293, 271);
|
|
||||||
panelHistory.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// buttonRenew
|
// buttonRenew
|
||||||
//
|
//
|
||||||
buttonRenew.Enabled = false;
|
buttonRenew.Enabled = false;
|
||||||
@ -331,7 +320,6 @@
|
|||||||
groupBoxLogin.ResumeLayout(false);
|
groupBoxLogin.ResumeLayout(false);
|
||||||
groupBoxLogin.PerformLayout();
|
groupBoxLogin.PerformLayout();
|
||||||
panelPortfolio.ResumeLayout(false);
|
panelPortfolio.ResumeLayout(false);
|
||||||
groupBoxHistory.ResumeLayout(false);
|
|
||||||
groupBoxDomains.ResumeLayout(false);
|
groupBoxDomains.ResumeLayout(false);
|
||||||
panelNav.ResumeLayout(false);
|
panelNav.ResumeLayout(false);
|
||||||
groupBoxAccount.ResumeLayout(false);
|
groupBoxAccount.ResumeLayout(false);
|
||||||
@ -365,6 +353,5 @@
|
|||||||
private ToolStripStatusLabel LabelSyncWarning;
|
private ToolStripStatusLabel LabelSyncWarning;
|
||||||
private ToolStripDropDownButton DropDownHelp;
|
private ToolStripDropDownButton DropDownHelp;
|
||||||
private GroupBox groupBoxHistory;
|
private GroupBox groupBoxHistory;
|
||||||
private Panel panelHistory;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
@ -1,266 +1,249 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace FireWallet
|
namespace FireWallet;
|
||||||
|
|
||||||
|
public partial class NotifyForm : Form
|
||||||
{
|
{
|
||||||
public partial class NotifyForm : Form
|
private bool allowClose = true;
|
||||||
|
private readonly string altLink;
|
||||||
|
|
||||||
|
private readonly string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
|
||||||
|
"\\FireWallet\\";
|
||||||
|
|
||||||
|
private readonly bool Linkcopy;
|
||||||
|
private Dictionary<string, string> theme;
|
||||||
|
|
||||||
|
public NotifyForm(string Message)
|
||||||
{
|
{
|
||||||
string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FireWallet\\";
|
InitializeComponent();
|
||||||
Dictionary<string, string> theme;
|
labelmessage.Text = Message;
|
||||||
string altLink;
|
altLink = "";
|
||||||
bool Linkcopy;
|
}
|
||||||
bool allowClose = true;
|
|
||||||
public NotifyForm(string Message)
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotifyForm(string Message, bool allowClose)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
labelmessage.Text = Message;
|
||||||
|
buttonOK.Focus();
|
||||||
|
Linkcopy = false;
|
||||||
|
buttonOK.Visible = allowClose;
|
||||||
|
allowClose = allowClose;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseNotification()
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NotifyForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UpdateTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OK_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
allowClose = true;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonALT_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (Linkcopy)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
// Copy link to clipboard
|
||||||
labelmessage.Text = Message;
|
Clipboard.SetText(altLink);
|
||||||
altLink = "";
|
return;
|
||||||
}
|
|
||||||
public void CloseNotification()
|
|
||||||
{
|
|
||||||
this.Close();
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
public NotifyForm(string Message, bool allowClose)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
labelmessage.Text = Message;
|
|
||||||
buttonOK.Focus();
|
|
||||||
Linkcopy = false;
|
|
||||||
buttonOK.Visible = allowClose;
|
|
||||||
allowClose = allowClose;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotifyForm(string Message, string altText, string altLink, bool Linkcopy)
|
// Open link
|
||||||
|
var psi = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
FileName = altLink,
|
||||||
labelmessage.Text = Message;
|
UseShellExecute = true
|
||||||
buttonALT.Text = altText;
|
};
|
||||||
buttonALT.Visible = true;
|
Process.Start(psi);
|
||||||
this.altLink = altLink;
|
}
|
||||||
buttonOK.Focus();
|
|
||||||
this.Linkcopy = Linkcopy;
|
|
||||||
|
|
||||||
if (Linkcopy)
|
private void NotifyForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
// Small font to fix more data
|
if (!allowClose) e.Cancel = true;
|
||||||
labelmessage.Font = new Font(labelmessage.Font.FontFamily, 10);
|
}
|
||||||
}
|
|
||||||
|
#region Theming
|
||||||
|
|
||||||
|
private void UpdateTheme()
|
||||||
|
{
|
||||||
|
// Check if file exists
|
||||||
|
if (!Directory.Exists(dir)) CreateConfig(dir);
|
||||||
|
if (!File.Exists(dir + "theme.txt")) CreateConfig(dir);
|
||||||
|
|
||||||
|
// Read file
|
||||||
|
var sr = new StreamReader(dir + "theme.txt");
|
||||||
|
theme = new Dictionary<string, string>();
|
||||||
|
while (!sr.EndOfStream)
|
||||||
|
{
|
||||||
|
var line = sr.ReadLine();
|
||||||
|
var split = line.Split(':');
|
||||||
|
theme.Add(split[0].Trim(), split[1].Trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Theming
|
sr.Dispose();
|
||||||
private void UpdateTheme()
|
|
||||||
|
if (!theme.ContainsKey("background") || !theme.ContainsKey("background-alt") ||
|
||||||
|
!theme.ContainsKey("foreground") || !theme.ContainsKey("foreground-alt")) return;
|
||||||
|
|
||||||
|
// Apply theme
|
||||||
|
BackColor = ColorTranslator.FromHtml(theme["background"]);
|
||||||
|
|
||||||
|
// Foreground
|
||||||
|
ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
|
||||||
|
|
||||||
|
|
||||||
|
// Need to specify this for each groupbox to override the black text
|
||||||
|
foreach (Control c in Controls) ThemeControl(c);
|
||||||
|
|
||||||
|
|
||||||
|
// Transparancy
|
||||||
|
applyTransparency(theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ThemeControl(Control c)
|
||||||
|
{
|
||||||
|
if (c.GetType() == typeof(GroupBox) || c.GetType() == typeof(Panel))
|
||||||
{
|
{
|
||||||
// Check if file exists
|
c.ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
|
||||||
if (!Directory.Exists(dir))
|
foreach (Control sub in c.Controls) ThemeControl(sub);
|
||||||
{
|
|
||||||
CreateConfig(dir);
|
|
||||||
}
|
|
||||||
if (!File.Exists(dir + "theme.txt"))
|
|
||||||
{
|
|
||||||
CreateConfig(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read file
|
|
||||||
StreamReader sr = new StreamReader(dir + "theme.txt");
|
|
||||||
theme = new Dictionary<string, string>();
|
|
||||||
while (!sr.EndOfStream)
|
|
||||||
{
|
|
||||||
string line = sr.ReadLine();
|
|
||||||
string[] split = line.Split(':');
|
|
||||||
theme.Add(split[0].Trim(), split[1].Trim());
|
|
||||||
}
|
|
||||||
sr.Dispose();
|
|
||||||
|
|
||||||
if (!theme.ContainsKey("background") || !theme.ContainsKey("background-alt") || !theme.ContainsKey("foreground") || !theme.ContainsKey("foreground-alt"))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply theme
|
|
||||||
this.BackColor = ColorTranslator.FromHtml(theme["background"]);
|
|
||||||
|
|
||||||
// Foreground
|
|
||||||
this.ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
|
|
||||||
|
|
||||||
|
|
||||||
// Need to specify this for each groupbox to override the black text
|
|
||||||
foreach (Control c in Controls)
|
|
||||||
{
|
|
||||||
ThemeControl(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Transparancy
|
|
||||||
applyTransparency(theme);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
private void ThemeControl(Control c)
|
|
||||||
{
|
|
||||||
if (c.GetType() == typeof(GroupBox) || c.GetType() == typeof(Panel))
|
|
||||||
{
|
|
||||||
c.ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
|
|
||||||
foreach (Control sub in c.Controls)
|
|
||||||
{
|
|
||||||
ThemeControl(sub);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (c.GetType() == typeof(TextBox) || c.GetType() == typeof(Button)
|
|
||||||
|| c.GetType() == typeof(ComboBox) || c.GetType() == typeof(StatusStrip))
|
|
||||||
{
|
|
||||||
c.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]);
|
|
||||||
c.BackColor = ColorTranslator.FromHtml(theme["background-alt"]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyTransparency(Dictionary<string, string> theme)
|
if (c.GetType() == typeof(TextBox) || c.GetType() == typeof(Button)
|
||||||
|
|| c.GetType() == typeof(ComboBox) || c.GetType() == typeof(StatusStrip))
|
||||||
{
|
{
|
||||||
if (theme.ContainsKey("transparent-mode"))
|
c.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]);
|
||||||
{
|
c.BackColor = ColorTranslator.FromHtml(theme["background-alt"]);
|
||||||
switch (theme["transparent-mode"])
|
|
||||||
{
|
|
||||||
case "mica":
|
|
||||||
var accent = new AccentPolicy { AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND };
|
|
||||||
var accentStructSize = Marshal.SizeOf(accent);
|
|
||||||
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
|
|
||||||
Marshal.StructureToPtr(accent, accentPtr, false);
|
|
||||||
var data = new WindowCompositionAttributeData
|
|
||||||
{
|
|
||||||
Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
|
|
||||||
SizeOfData = accentStructSize,
|
|
||||||
Data = accentPtr
|
|
||||||
};
|
|
||||||
User32.SetWindowCompositionAttribute(Handle, ref data);
|
|
||||||
Marshal.FreeHGlobal(accentPtr);
|
|
||||||
break;
|
|
||||||
case "key":
|
|
||||||
if (theme.ContainsKey("transparency-key"))
|
|
||||||
{
|
|
||||||
switch (theme["transparency-key"])
|
|
||||||
{
|
|
||||||
case "alt":
|
|
||||||
this.TransparencyKey = ColorTranslator.FromHtml(theme["background-alt"]);
|
|
||||||
break;
|
|
||||||
case "main":
|
|
||||||
this.TransparencyKey = ColorTranslator.FromHtml(theme["background"]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
this.TransparencyKey = ColorTranslator.FromHtml(theme["transparency-key"]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "percent":
|
|
||||||
if (theme.ContainsKey("transparency-percent"))
|
|
||||||
{
|
|
||||||
Opacity = Convert.ToDouble(theme["transparency-percent"]) / 100;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateConfig(string dir)
|
|
||||||
{
|
|
||||||
if (!Directory.Exists(dir))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(dir);
|
|
||||||
}
|
|
||||||
StreamWriter sw = new StreamWriter(dir + "theme.txt");
|
|
||||||
sw.WriteLine("background: #000000");
|
|
||||||
sw.WriteLine("foreground: #8e05c2");
|
|
||||||
sw.WriteLine("background-alt: #3e065f");
|
|
||||||
sw.WriteLine("foreground-alt: #ffffff");
|
|
||||||
sw.WriteLine("transparent-mode: off");
|
|
||||||
sw.WriteLine("transparency-key: main");
|
|
||||||
sw.WriteLine("transparency-percent: 90");
|
|
||||||
|
|
||||||
sw.Dispose();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Required for mica effect
|
|
||||||
internal enum AccentState
|
|
||||||
{
|
|
||||||
ACCENT_DISABLED = 0,
|
|
||||||
ACCENT_ENABLE_GRADIENT = 1,
|
|
||||||
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
|
|
||||||
ACCENT_ENABLE_BLURBEHIND = 3,
|
|
||||||
ACCENT_INVALID_STATE = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
internal enum WindowCompositionAttribute
|
|
||||||
{
|
|
||||||
WCA_ACCENT_POLICY = 19
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
internal struct AccentPolicy
|
|
||||||
{
|
|
||||||
public AccentState AccentState;
|
|
||||||
public int AccentFlags;
|
|
||||||
public int GradientColor;
|
|
||||||
public int AnimationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
internal struct WindowCompositionAttributeData
|
|
||||||
{
|
|
||||||
public WindowCompositionAttribute Attribute;
|
|
||||||
public IntPtr Data;
|
|
||||||
public int SizeOfData;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static class User32
|
|
||||||
{
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private void NotifyForm_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UpdateTheme();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OK_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
allowClose = true;
|
|
||||||
this.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonALT_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (Linkcopy)
|
|
||||||
{
|
|
||||||
// Copy link to clipboard
|
|
||||||
Clipboard.SetText(altLink);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Open link
|
|
||||||
ProcessStartInfo psi = new ProcessStartInfo
|
|
||||||
{
|
|
||||||
FileName = altLink,
|
|
||||||
UseShellExecute = true
|
|
||||||
};
|
|
||||||
Process.Start(psi);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void NotifyForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
||||||
{
|
|
||||||
if (!allowClose) e.Cancel = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void applyTransparency(Dictionary<string, string> theme)
|
||||||
|
{
|
||||||
|
if (theme.ContainsKey("transparent-mode"))
|
||||||
|
switch (theme["transparent-mode"])
|
||||||
|
{
|
||||||
|
case "mica":
|
||||||
|
var accent = new AccentPolicy { AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND };
|
||||||
|
var accentStructSize = Marshal.SizeOf(accent);
|
||||||
|
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
|
||||||
|
Marshal.StructureToPtr(accent, accentPtr, false);
|
||||||
|
var data = new WindowCompositionAttributeData
|
||||||
|
{
|
||||||
|
Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
|
||||||
|
SizeOfData = accentStructSize,
|
||||||
|
Data = accentPtr
|
||||||
|
};
|
||||||
|
User32.SetWindowCompositionAttribute(Handle, ref data);
|
||||||
|
Marshal.FreeHGlobal(accentPtr);
|
||||||
|
break;
|
||||||
|
case "key":
|
||||||
|
if (theme.ContainsKey("transparency-key"))
|
||||||
|
switch (theme["transparency-key"])
|
||||||
|
{
|
||||||
|
case "alt":
|
||||||
|
TransparencyKey = ColorTranslator.FromHtml(theme["background-alt"]);
|
||||||
|
break;
|
||||||
|
case "main":
|
||||||
|
TransparencyKey = ColorTranslator.FromHtml(theme["background"]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
TransparencyKey = ColorTranslator.FromHtml(theme["transparency-key"]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "percent":
|
||||||
|
if (theme.ContainsKey("transparency-percent"))
|
||||||
|
Opacity = Convert.ToDouble(theme["transparency-percent"]) / 100;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateConfig(string dir)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
|
||||||
|
var sw = new StreamWriter(dir + "theme.txt");
|
||||||
|
sw.WriteLine("background: #000000");
|
||||||
|
sw.WriteLine("foreground: #8e05c2");
|
||||||
|
sw.WriteLine("background-alt: #3e065f");
|
||||||
|
sw.WriteLine("foreground-alt: #ffffff");
|
||||||
|
sw.WriteLine("transparent-mode: off");
|
||||||
|
sw.WriteLine("transparency-key: main");
|
||||||
|
sw.WriteLine("transparency-percent: 90");
|
||||||
|
|
||||||
|
sw.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Required for mica effect
|
||||||
|
internal enum AccentState
|
||||||
|
{
|
||||||
|
ACCENT_DISABLED = 0,
|
||||||
|
ACCENT_ENABLE_GRADIENT = 1,
|
||||||
|
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
|
||||||
|
ACCENT_ENABLE_BLURBEHIND = 3,
|
||||||
|
ACCENT_INVALID_STATE = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum WindowCompositionAttribute
|
||||||
|
{
|
||||||
|
WCA_ACCENT_POLICY = 19
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct AccentPolicy
|
||||||
|
{
|
||||||
|
public AccentState AccentState;
|
||||||
|
public int AccentFlags;
|
||||||
|
public int GradientColor;
|
||||||
|
public int AnimationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct WindowCompositionAttributeData
|
||||||
|
{
|
||||||
|
public WindowCompositionAttribute Attribute;
|
||||||
|
public IntPtr Data;
|
||||||
|
public int SizeOfData;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static class User32
|
||||||
|
{
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
@ -1,17 +1,16 @@
|
|||||||
namespace FireWalletLite
|
namespace FireWalletLite;
|
||||||
|
|
||||||
|
internal static class Program
|
||||||
{
|
{
|
||||||
internal static class Program
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
private static void Main()
|
||||||
{
|
{
|
||||||
/// <summary>
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
/// The main entry point for the application.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
/// </summary>
|
ApplicationConfiguration.Initialize();
|
||||||
[STAThread]
|
Application.Run(new Loader());
|
||||||
static void Main()
|
|
||||||
{
|
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
|
||||||
// see https://aka.ms/applicationconfiguration.
|
|
||||||
ApplicationConfiguration.Initialize();
|
|
||||||
Application.Run(new Loader());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,42 +1,39 @@
|
|||||||
using QRCoder;
|
using QRCoder;
|
||||||
|
|
||||||
namespace FireWalletLite
|
namespace FireWalletLite;
|
||||||
|
|
||||||
|
public partial class ReceiveForm : Form
|
||||||
{
|
{
|
||||||
public partial class ReceiveForm : Form
|
private readonly string address;
|
||||||
|
private MainForm main;
|
||||||
|
|
||||||
|
public ReceiveForm(string address, MainForm main)
|
||||||
{
|
{
|
||||||
string address;
|
InitializeComponent();
|
||||||
MainForm main;
|
this.address = address;
|
||||||
public ReceiveForm(string address, MainForm main)
|
this.main = main;
|
||||||
{
|
// Theme form
|
||||||
InitializeComponent();
|
BackColor = ColorTranslator.FromHtml(main.Theme["background"]);
|
||||||
this.address = address;
|
ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]);
|
||||||
this.main = main;
|
foreach (Control control in Controls) main.ThemeControl(control);
|
||||||
// Theme form
|
textBoxReceive.Text = address;
|
||||||
this.BackColor = ColorTranslator.FromHtml(main.Theme["background"]);
|
textBoxReceive.Left = (ClientSize.Width - textBoxReceive.Width) / 2;
|
||||||
this.ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]);
|
label1.Left = (ClientSize.Width - label1.Width) / 2;
|
||||||
foreach (Control control in Controls)
|
buttonCopy.Left = (ClientSize.Width - buttonCopy.Width) / 2;
|
||||||
{
|
|
||||||
main.ThemeControl(control);
|
|
||||||
}
|
|
||||||
textBoxReceive.Text = address;
|
|
||||||
textBoxReceive.Left = (this.ClientSize.Width - textBoxReceive.Width) / 2;
|
|
||||||
label1.Left = (this.ClientSize.Width - label1.Width) / 2;
|
|
||||||
buttonCopy.Left = (this.ClientSize.Width - buttonCopy.Width) / 2;
|
|
||||||
|
|
||||||
|
|
||||||
|
var qrcode = new QRCodeGenerator();
|
||||||
QRCodeGenerator qrcode = new QRCodeGenerator();
|
var qrData = qrcode.CreateQrCode(address, QRCodeGenerator.ECCLevel.Q);
|
||||||
QRCodeData qrData = qrcode.CreateQrCode(address, QRCodeGenerator.ECCLevel.Q);
|
var qrCode = new QRCode(qrData);
|
||||||
QRCode qrCode = new QRCode(qrData);
|
pictureBoxReceiveQR.Image = qrCode.GetGraphic(20, main.Theme["foreground"], main.Theme["background"]);
|
||||||
pictureBoxReceiveQR.Image = qrCode.GetGraphic(20, main.Theme["foreground"], main.Theme["background"]);
|
pictureBoxReceiveQR.SizeMode = PictureBoxSizeMode.Zoom;
|
||||||
pictureBoxReceiveQR.SizeMode = PictureBoxSizeMode.Zoom;
|
pictureBoxReceiveQR.Width = ClientSize.Width / 2;
|
||||||
pictureBoxReceiveQR.Width = this.ClientSize.Width / 2;
|
pictureBoxReceiveQR.Height = ClientSize.Width / 2;
|
||||||
pictureBoxReceiveQR.Height = this.ClientSize.Width / 2;
|
pictureBoxReceiveQR.Left = (ClientSize.Width - pictureBoxReceiveQR.Width) / 2;
|
||||||
pictureBoxReceiveQR.Left = (this.ClientSize.Width - pictureBoxReceiveQR.Width) / 2;
|
|
||||||
}
|
|
||||||
private void buttonCopy_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Clipboard.SetText(address);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void buttonCopy_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Clipboard.SetText(address);
|
||||||
|
}
|
||||||
|
}
|
@ -1,106 +1,102 @@
|
|||||||
using FireWallet;
|
using FireWallet;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace FireWalletLite
|
namespace FireWalletLite;
|
||||||
|
|
||||||
|
public partial class SendForm : Form
|
||||||
{
|
{
|
||||||
public partial class SendForm : Form
|
private readonly int fee = 1;
|
||||||
|
private readonly MainForm main;
|
||||||
|
private readonly decimal unlockedbalance;
|
||||||
|
|
||||||
|
public SendForm(decimal Unlockedbalance, MainForm main)
|
||||||
{
|
{
|
||||||
int fee = 1;
|
InitializeComponent();
|
||||||
decimal unlockedbalance;
|
this.main = main;
|
||||||
MainForm main;
|
unlockedbalance = Unlockedbalance;
|
||||||
public SendForm(decimal Unlockedbalance, MainForm main)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.main = main;
|
|
||||||
this.unlockedbalance = Unlockedbalance;
|
|
||||||
|
|
||||||
// Theme form
|
// Theme form
|
||||||
this.BackColor = ColorTranslator.FromHtml(main.Theme["background"]);
|
BackColor = ColorTranslator.FromHtml(main.Theme["background"]);
|
||||||
this.ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]);
|
ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]);
|
||||||
foreach (Control control in Controls)
|
foreach (Control control in Controls) main.ThemeControl(control);
|
||||||
{
|
|
||||||
main.ThemeControl(control);
|
|
||||||
}
|
|
||||||
|
|
||||||
labelMax.Text = "Max: " + (unlockedbalance - fee).ToString() + " HNS";
|
labelMax.Text = "Max: " + (unlockedbalance - fee) + " HNS";
|
||||||
if (unlockedbalance < fee)
|
if (unlockedbalance < fee) labelMax.Text = "Max: 0 HNS";
|
||||||
{
|
//buttonSend.Enabled = false;
|
||||||
labelMax.Text = "Max: 0 HNS";
|
// Allign controls
|
||||||
//buttonSend.Enabled = false;
|
labelAddress.Left = (ClientSize.Width - labelAddress.Width) / 2;
|
||||||
}
|
labelAmount.Left = (ClientSize.Width - labelAmount.Width) / 2;
|
||||||
|
textBoxAddress.Left = (ClientSize.Width - textBoxAddress.Width) / 2;
|
||||||
// Allign controls
|
labelMax.Left = (ClientSize.Width - labelMax.Width) / 2;
|
||||||
labelAddress.Left = (this.ClientSize.Width - labelAddress.Width) / 2;
|
textBoxAmount.Left = (ClientSize.Width - textBoxAmount.Width - labelHNSToken.Width - 10) / 2;
|
||||||
labelAmount.Left = (this.ClientSize.Width - labelAmount.Width) / 2;
|
labelHNSToken.Left = textBoxAmount.Left + textBoxAmount.Width + 10;
|
||||||
textBoxAddress.Left = (this.ClientSize.Width - textBoxAddress.Width) / 2;
|
buttonSend.Left = (ClientSize.Width - buttonSend.Width) / 2;
|
||||||
labelMax.Left = (this.ClientSize.Width - labelMax.Width) / 2;
|
|
||||||
textBoxAmount.Left = (this.ClientSize.Width - textBoxAmount.Width - labelHNSToken.Width - 10) / 2;
|
|
||||||
labelHNSToken.Left = textBoxAmount.Left + textBoxAmount.Width + 10;
|
|
||||||
buttonSend.Left = (this.ClientSize.Width - buttonSend.Width) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void buttonSend_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
buttonSend.Enabled = false;
|
|
||||||
string address = textBoxAddress.Text;
|
|
||||||
if (textBoxAddress.Text.Substring(0,1) == "@")
|
|
||||||
{
|
|
||||||
// HIP-02 not supported yet
|
|
||||||
NotifyForm notify = new NotifyForm("HIP-02 not supported yet");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
buttonSend.Enabled = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
bool valid = await main.ValidAddress(address);
|
|
||||||
if (!valid)
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Invalid address");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
buttonSend.Enabled = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
decimal amount = 0;
|
|
||||||
if (!decimal.TryParse(textBoxAmount.Text, out amount))
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Invalid amount");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (amount > unlockedbalance - fee)
|
|
||||||
{
|
|
||||||
NotifyForm notify = new NotifyForm("Insufficient balance");
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string content = "{\"method\": \"sendtoaddress\",\"params\": [ \"" + address + "\", " +
|
|
||||||
amount.ToString() + "]}";
|
|
||||||
string output = await main.APIPost("", true, content);
|
|
||||||
JObject APIresp = JObject.Parse(output);
|
|
||||||
if (APIresp["error"].ToString() != "")
|
|
||||||
{
|
|
||||||
main.AddLog("Failed:");
|
|
||||||
main.AddLog(APIresp.ToString());
|
|
||||||
JObject error = JObject.Parse(APIresp["error"].ToString());
|
|
||||||
string ErrorMessage = error["message"].ToString();
|
|
||||||
|
|
||||||
NotifyForm notify = new NotifyForm("Error Transaction Failed\n" + ErrorMessage);
|
|
||||||
notify.ShowDialog();
|
|
||||||
notify.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
string hash = APIresp["result"].ToString();
|
|
||||||
string link = main.TXExplorer + hash;
|
|
||||||
NotifyForm notifySuccess = new NotifyForm("Transaction Sent\nThis transaction could take up to 20 minutes to mine",
|
|
||||||
"Explorer", link);
|
|
||||||
notifySuccess.ShowDialog();
|
|
||||||
notifySuccess.Dispose();
|
|
||||||
this.Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private async void buttonSend_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
buttonSend.Enabled = false;
|
||||||
|
var address = textBoxAddress.Text;
|
||||||
|
if (textBoxAddress.Text.Substring(0, 1) == "@")
|
||||||
|
{
|
||||||
|
// HIP-02 not supported yet
|
||||||
|
var notify = new NotifyForm("HIP-02 not supported yet");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
buttonSend.Enabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var valid = await main.ValidAddress(address);
|
||||||
|
if (!valid)
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Invalid address");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
buttonSend.Enabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
decimal amount = 0;
|
||||||
|
if (!decimal.TryParse(textBoxAmount.Text, out amount))
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Invalid amount");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amount > unlockedbalance - fee)
|
||||||
|
{
|
||||||
|
var notify = new NotifyForm("Insufficient balance");
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var content = "{\"method\": \"sendtoaddress\",\"params\": [ \"" + address + "\", " +
|
||||||
|
amount + "]}";
|
||||||
|
var output = await main.APIPost("", true, content);
|
||||||
|
var APIresp = JObject.Parse(output);
|
||||||
|
if (APIresp["error"].ToString() != "")
|
||||||
|
{
|
||||||
|
main.AddLog("Failed:");
|
||||||
|
main.AddLog(APIresp.ToString());
|
||||||
|
var error = JObject.Parse(APIresp["error"].ToString());
|
||||||
|
var ErrorMessage = error["message"].ToString();
|
||||||
|
|
||||||
|
var notify = new NotifyForm("Error Transaction Failed\n" + ErrorMessage);
|
||||||
|
notify.ShowDialog();
|
||||||
|
notify.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hash = APIresp["result"].ToString();
|
||||||
|
var link = main.TXExplorer + hash;
|
||||||
|
var notifySuccess = new NotifyForm("Transaction Sent\nThis transaction could take up to 20 minutes to mine",
|
||||||
|
"Explorer", link);
|
||||||
|
notifySuccess.ShowDialog();
|
||||||
|
notifySuccess.Dispose();
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
@ -1,96 +1,104 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
|
||||||
|
namespace FireWallet;
|
||||||
|
|
||||||
namespace FireWallet
|
public partial class SplashScreen : Form
|
||||||
{
|
{
|
||||||
public partial class SplashScreen : Form
|
private bool close;
|
||||||
{
|
private float opacity;
|
||||||
public SplashScreen(bool timer)
|
private Bitmap splash;
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
close = false;
|
|
||||||
IsClosed = false;
|
|
||||||
}
|
|
||||||
bool close;
|
|
||||||
float opacity = 0.0f;
|
|
||||||
private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e)
|
|
||||||
{
|
|
||||||
if (!close)
|
|
||||||
{
|
|
||||||
e.Cancel = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public bool IsClosed { get; set; }
|
|
||||||
public void CloseSplash()
|
|
||||||
{
|
|
||||||
close = true;
|
|
||||||
|
|
||||||
// Fade out
|
public SplashScreen(bool timer)
|
||||||
timerIn.Stop();
|
{
|
||||||
timerOut.Start();
|
InitializeComponent();
|
||||||
}
|
close = false;
|
||||||
private void label2_Click(object sender, EventArgs e)
|
IsClosed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsClosed { get; set; }
|
||||||
|
|
||||||
|
private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
if (!close) e.Cancel = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseSplash()
|
||||||
|
{
|
||||||
|
close = true;
|
||||||
|
|
||||||
|
// Fade out
|
||||||
|
timerIn.Stop();
|
||||||
|
timerOut.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void label2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var psi = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
ProcessStartInfo psi = new ProcessStartInfo
|
FileName = "https://nathan.woodburn.au",
|
||||||
|
UseShellExecute = true
|
||||||
|
};
|
||||||
|
Process.Start(psi);
|
||||||
|
}
|
||||||
|
|
||||||
|
//new Bitmap(Properties.Resources.FWSplash);
|
||||||
|
private void SplashScreen_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
splash = pictureBoxNew.Image as Bitmap;
|
||||||
|
pictureBoxNew.Visible = true;
|
||||||
|
TransparencyKey = Color.FromArgb(0, 0, 0);
|
||||||
|
pictureBoxNew.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image SetImageOpacity(Image image, float opacity)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var bmp = new Bitmap(image.Width, image.Height);
|
||||||
|
using (var gfx = Graphics.FromImage(bmp))
|
||||||
{
|
{
|
||||||
FileName = "https://nathan.woodburn.au",
|
var matrix = new ColorMatrix();
|
||||||
UseShellExecute = true
|
matrix.Matrix33 = opacity;
|
||||||
};
|
var attributes = new ImageAttributes();
|
||||||
Process.Start(psi);
|
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
||||||
}
|
gfx.DrawImage(image, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, image.Width, image.Height,
|
||||||
Bitmap splash;
|
GraphicsUnit.Pixel, attributes);
|
||||||
//new Bitmap(Properties.Resources.FWSplash);
|
|
||||||
private void SplashScreen_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
splash = pictureBoxNew.Image as Bitmap;
|
|
||||||
pictureBoxNew.Visible = true;
|
|
||||||
this.TransparencyKey = Color.FromArgb(0, 0, 0);
|
|
||||||
pictureBoxNew.Invalidate();
|
|
||||||
}
|
|
||||||
public Image SetImageOpacity(Image image, float opacity)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Bitmap bmp = new Bitmap(image.Width, image.Height);
|
|
||||||
using (Graphics gfx = Graphics.FromImage(bmp))
|
|
||||||
{
|
|
||||||
ColorMatrix matrix = new ColorMatrix();
|
|
||||||
matrix.Matrix33 = opacity;
|
|
||||||
ImageAttributes attributes = new ImageAttributes();
|
|
||||||
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
|
||||||
gfx.DrawImage(image, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes);
|
|
||||||
}
|
|
||||||
return bmp;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return bmp;
|
||||||
}
|
}
|
||||||
private void timerIn_Tick(object sender, EventArgs e)
|
catch
|
||||||
{
|
{
|
||||||
if (opacity >= 1)
|
return null;
|
||||||
{
|
|
||||||
timerIn.Stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
opacity += 0.05f;
|
|
||||||
pictureBoxNew.Image = SetImageOpacity(splash, opacity);
|
|
||||||
pictureBoxNew.Invalidate();
|
|
||||||
}
|
|
||||||
private void timerOut_Tick(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (opacity <= 0)
|
|
||||||
{
|
|
||||||
timerOut.Stop();
|
|
||||||
IsClosed = true;
|
|
||||||
this.Close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
opacity -= 0.05f;
|
|
||||||
pictureBoxNew.Image = SetImageOpacity(splash, opacity);
|
|
||||||
pictureBoxNew.Invalidate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void timerIn_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (opacity >= 1)
|
||||||
|
{
|
||||||
|
timerIn.Stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
opacity += 0.05f;
|
||||||
|
pictureBoxNew.Image = SetImageOpacity(splash, opacity);
|
||||||
|
pictureBoxNew.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void timerOut_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (opacity <= 0)
|
||||||
|
{
|
||||||
|
timerOut.Stop();
|
||||||
|
IsClosed = true;
|
||||||
|
Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
opacity -= 0.05f;
|
||||||
|
pictureBoxNew.Image = SetImageOpacity(splash, opacity);
|
||||||
|
pictureBoxNew.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user