Skip to content

Commit

Permalink
usability improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
salfter committed May 22, 2013
1 parent a65304b commit d0b3b9b
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 46 deletions.
72 changes: 32 additions & 40 deletions CoinProfitability/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 42 additions & 6 deletions CoinProfitability/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@ namespace CoinProfitability
{
public partial class Form1 : Form
{
public Form1()
private class Item
{
InitializeComponent();
public string Name;
public string Value;
public Item(string szName, string szValue)
{
Name=szName;
Value = szValue;
}
public override string ToString()
{
return Name;
}
}

private void tbInterval_TextChanged(object sender, EventArgs e)
public Form1()
{
OnChanged();
InitializeComponent();
}

private void tbHashrate_TextChanged(object sender, EventArgs e)
Expand All @@ -47,8 +57,8 @@ private void OnChanged()
{
try
{
BigInteger interval = new BigInteger(Convert.ToInt64(tbInterval.Text));
BigInteger hashrate = new BigInteger(Convert.ToInt64(tbHashrate.Text));
BigInteger interval = new BigInteger(Convert.ToInt64(((Item)(cbInterval.SelectedItem)).Value));
BigInteger hashrate = new BigInteger(Convert.ToInt64(tbHashrate.Text)) * Convert.ToInt64(((Item)(cbHashrateUnit.SelectedItem)).Value);
BigInteger reward = new BigInteger(Convert.ToInt64(tbReward.Text)) * 100000000;
decimal difficulty = Convert.ToDecimal(tbDifficulty.Text);

Expand All @@ -59,11 +69,37 @@ private void OnChanged()

if (tbExchangeRate.Text != "")
tbIncomeBTC.Text = (Convert.ToDecimal(tbExchangeRate.Text) * (decimal)revenue / (decimal)100000000).ToString("F8");
else
tbIncomeBTC.Text = "---";
}
catch
{
tbIncome.Text = tbIncomeBTC.Text = "---";
}
}

private void Form1_Load(object sender, EventArgs e)
{
cbInterval.Items.Add(new Item("Week", "604800"));
cbInterval.Items.Add(new Item("Day", "86400"));
cbInterval.Items.Add(new Item("Hour", "3600"));
cbInterval.SelectedIndex = 1;

cbHashrateUnit.Items.Add(new Item("GH/s", "1000000000"));
cbHashrateUnit.Items.Add(new Item("MH/s", "1000000"));
cbHashrateUnit.Items.Add(new Item("kH/s", "1000"));
cbHashrateUnit.Items.Add(new Item("H/s", "1"));
cbHashrateUnit.SelectedIndex = 1;
}

private void cbInterval_SelectedIndexChanged(object sender, EventArgs e)
{
OnChanged();
}

private void cbHashrateUnit_SelectedIndexChanged(object sender, EventArgs e)
{
OnChanged();
}
}
}

0 comments on commit d0b3b9b

Please sign in to comment.