private void addWatchlistBtn_Click(object sender, EventArgs e) { if (this.watchListComboBox.Text == string.Empty) { System.Windows.Forms.MessageBox.Show("Empty watch list Name", "Error"); return; } if (watchLists.Find(wl => wl.Name == this.watchListComboBox.Text) != null) { System.Windows.Forms.MessageBox.Show("Watchlist " + this.watchListComboBox.Text + " already exists !!!", "Error"); return; } StockWatchList newWatchList = new StockWatchList(this.watchListComboBox.Text); watchLists.Add(newWatchList); this.stockWatchListsBindingSource.DataSource = null; this.stockWatchListsBindingSource.DataSource = watchLists; if (this.StockWatchListsChanged != null) { this.StockWatchListsChanged(); } this.watchListComboBox.SelectedItem = newWatchList; }
private void CreateWatchList(string postfix) { if (this.palmaresView.SelectedItems.Count != 0) { int weekOfTheYear = (this.EndDate.DayOfYear + 4) / 7; string watchListName = this.groupComboBox.SelectedItem.ToString() + "_" + postfix + "_" + weekOfTheYear.ToString("00"); StockWatchList swl = WatchLists.Find(wl => wl.Name == watchListName); if (swl == null) { swl = new StockWatchList(watchListName); WatchLists.Add(swl); } foreach (ListViewItem selectedItem in this.palmaresView.SelectedItems) { if (!swl.StockList.Contains(selectedItem.ToString())) { swl.StockList.Add(selectedItem.Text); } } if (this.StockWatchListsChanged != null) { this.StockWatchListsChanged(); } } }