private void RemoveCoin_Click(object sender, EventArgs e) { //Get coin to remove InputForm form = new InputForm("Remove", _coinConfigs.OrderBy(c => c.coin).Select(c => c.coin).ToList()); if (form.ShowDialog() != DialogResult.OK) return; //Check if coin exists if (_coinConfigs.Any(a => a.coin.Equals(form.InputText.ToUpper()))) { //Update coin configs based on changed values foreach (var coinGuiLine in _coinGuiLines) { var coinConfig = _coinConfigs.Single(c => c.coin == coinGuiLine.CoinName); coinConfig.bought = Convert.ToDecimal(coinGuiLine.BoughtTextBox.Text); coinConfig.paid = Convert.ToDecimal(coinGuiLine.PaidTextBox.Text); coinConfig.SetStartupPrice = false; } //Remove coin config _coinConfigs.RemoveAll(a => a.coin.Equals(form.InputText.ToUpper())); RemoveDelegate remove = new RemoveDelegate(Remove); BeginInvoke(remove); } else { MessageBox.Show("Coin does not exist."); } }
private void AddCoin_Click(object sender, EventArgs e) { //Check if coin list has been downloaded while(_coinNames.Count <= 0) { if (MessageBox.Show("Please wait while coin list is being downloaded.", "Loading", MessageBoxButtons.RetryCancel) == DialogResult.Cancel) return; } try { using (var webClient = new WebClient()) { //Get coin to add InputForm form = new InputForm("Add", _coinNames.Except(_coinConfigs.Select(c => c.coin).ToList()).ToList()); if (form.ShowDialog() != DialogResult.OK) return; if (!_coinNames.Contains(form.InputText.ToUpper())) { MessageBox.Show("Coin does not exist."); return; } //Check if coin exists if (!_coinConfigs.Any(a => a.coin.Equals(form.InputText.ToUpper()))) { //Update coin configs based on changed values foreach (var coinGuiLine in _coinGuiLines) { var coinConfig = _coinConfigs.Single(c => c.coin == coinGuiLine.CoinName); coinConfig.bought = Convert.ToDecimal(coinGuiLine.BoughtTextBox.Text); coinConfig.paid = Convert.ToDecimal(coinGuiLine.PaidTextBox.Text); coinConfig.SetStartupPrice = false; } //Add config _coinConfigs.Add(new CoinConfig { coin = form.InputText.ToUpper(), bought = 0, paid = 0, StartupPrice = 0, SetStartupPrice = true }); RemoveDelegate remove = new RemoveDelegate(Remove); BeginInvoke(remove); } else { MessageBox.Show("Coin already added."); } } } catch (WebException) { //Update status UpdateStatusDelegate updateStatus = new UpdateStatusDelegate(UpdateStatus); BeginInvoke(updateStatus, "No internet connection"); } }
private void AddCoin_Click(object sender, EventArgs e) { //Check if coin list has been downloaded while (_coinNames.Count <= 0) { if (MessageBox.Show("Please wait while coin list is being downloaded.", "Loading", MessageBoxButtons.RetryCancel) == DialogResult.Cancel) { return; } } //Get coin to add InputForm form = new InputForm("Add", _coinNames.ToList()); if (form.ShowDialog() != DialogResult.OK) { return; } //Check if coin exists if (!_coinNames.Contains(form.InputText.ToUpper())) { MessageBox.Show("Coin does not exist."); return; } //Update coin config bought and paid values foreach (var coinGuiLine in _coinGuiLines) { var coinConfig = _coinConfigs.Single(c => c.coin == coinGuiLine.CoinName && c.coinIndex == coinGuiLine.CoinIndex); coinConfig.bought = Convert.ToDecimal(coinGuiLine.BoughtTextBox.Text); coinConfig.paid = Convert.ToDecimal(coinGuiLine.PaidTextBox.Text); coinConfig.SetStartupPrice = false; } //Add coin config _coinConfigs.Add(new CoinConfig { coin = form.InputText.ToUpper(), coinIndex = _coinConfigs.Count(c => c.coin.Equals(form.InputText.ToUpper())), bought = 0, paid = 0, StartupPrice = 0, SetStartupPrice = true }); RemoveDelegate remove = new RemoveDelegate(Remove); BeginInvoke(remove); }
private void RemoveCoin_Click(object sender, EventArgs e) { //Get coin to remove InputForm form = new InputForm("Remove", _coinConfigs); if (form.ShowDialog() != DialogResult.OK) { return; } //Check if coin exists if (!_coinConfigs.Any(a => a.coin.Equals(form.InputText.ToUpper()) && a.coinIndex == form.CoinIndex)) { MessageBox.Show("Coin does not exist."); return; } //Update coin config bought and paid values foreach (var coinGuiLine in _coinGuiLines) { var coinConfig = _coinConfigs.Single(c => c.coin == coinGuiLine.CoinName && c.coinIndex == coinGuiLine.CoinIndex); coinConfig.bought = Convert.ToDecimal(coinGuiLine.BoughtTextBox.Text); coinConfig.paid = Convert.ToDecimal(coinGuiLine.PaidTextBox.Text); coinConfig.SetStartupPrice = false; } //Remove coin config _coinConfigs.RemoveAll(a => a.coin.Equals(form.InputText.ToUpper()) && a.coinIndex == form.CoinIndex); //Reset coin indexes ResetCoinIndex(); RemoveDelegate remove = new RemoveDelegate(Remove); BeginInvoke(remove); }