public void ChangeColor(StockFile.STOCKTYPE Type, Color NewColor) { DataChart.Series[(int)Type].Color = NewColor; }
private void LoadDataButton_Click(object sender, EventArgs e) { OpenFileDialog ofDialog = new OpenFileDialog(); StreamReader stream = null; ofDialog.Filter = @"CSV Files (*.csv)|*.csv|All Files|*.*"; ofDialog.Title = @"Locate CSV File (finance.yahoo.com)"; ofDialog.Multiselect = true; GC.Collect(); try { if (ofDialog.ShowDialog() == DialogResult.OK) { State.Wait(); foreach (string i in ofDialog.FileNames) { if (stream != null) stream.Close(); stream = new StreamReader(i); StockFile tempStock = new StockFile(stream.ReadToEnd(), i); Stocks.Add(tempStock); FileListBox.Items.Add(tempStock.StockName.Split('\\').Last()); } State.Clear(); } } catch(Exception FileException) { MessageBox.Show("Error in loading file(s)\n" + FileException.Message); } finally { ofDialog.Dispose(); FileListBox.SelectedIndex = FileListBox.Items.Count - 1; //automatically select last } }
public void SetTimeRange(StockFile.STOCKTYPE Type, DateTime From, DateTime To) { State.Wait(); if (Stock.DrawData[(int)Type] || Stock.DataDirty[(int)Type]) { Series tempSeries = Stock[(StockFile.STOCKTYPE)Type]; //hard copy here for (int i = 0; i < tempSeries.Points.Count(); ) { //The order by default seems to be in reverse, so this should be first if ((tempSeries.Points[i].XValue > To.ToOADate()) || (tempSeries.Points[i].XValue < From.ToOADate())) tempSeries.Points.Remove(tempSeries.Points[i]); else i++; } DataChart.Series.RemoveAt((int)Type); DataChart.Series.Insert((int)Type, tempSeries); Stock.DataDirty[(int)Type] = false; } DataChart.ChartAreas["StockArea"].RecalculateAxesScale(); GC.Collect(); State.Clear(); }