private void RemoveCoin_Click(object sender, EventArgs e) { using (ManageCoins form = new ManageCoins(_coinConfigs)) { if (form.ShowDialog() != DialogResult.OK) { return; } _coinConfigs.RemoveAll(a => a.Name.ExtEquals(form.InputText) && a.Index == form.CoinIndex); //Reset coin indexes foreach (CoinConfig coinConfig in _coinConfigs) { int index = 0; foreach (CoinConfig sameCoinConfig in _coinConfigs.Where(c => c.Name == coinConfig.Name).ToList()) { sameCoinConfig.Index = index; index++; } } } _loadLines = true; SelectPortfolio(string.Empty); }
private void AddCoin_Click(object sender, EventArgs e) { using (ManageCoins form = new ManageCoins(_coinNames)) { if (form.ShowDialog() != DialogResult.OK) { return; } if (!_coinNames.Any(c => c.ExtEquals(form.InputText))) { MessageBox.Show("Coin does not exist.", "Error"); return; } _coinConfigs.Add(new CoinConfig { Name = form.InputText, Bought = 0, Paid = 0, StartupPrice = 0, Index = _coinConfigs.Count(c => c.Name.ExtEquals(form.InputText)) }); _loadLines = true; SelectPortfolio(string.Empty); } }