/// <summary> /// Event: When the user chosen another timeframe /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBoxTimeframe_SelectedIndexChanged(object sender, EventArgs e) { // update date/time in From and To boxes TimeframeItem item = comboBoxTimeframe.SelectedItem as TimeframeItem; if (item != null) { dateTimePickerFrom.Value = item.From; if (dateTimePickerTo.Checked) { dateTimePickerTo.Value = item.To; } } }
/// <summary> /// Constructor /// </summary> /// <param name="controller">PriceHistory API controller</param> internal RequestHistoryForm(PriceAPIController controller) { InitializeComponent(); // Fills the list of the offers available for (int i = 0; i < controller.Offers.Count; i++) { comboBoxInstrument.Items.Add(controller.Offers[i].Instrument); } if (comboBoxInstrument.Items.Count > 0) { comboBoxInstrument.SelectedIndex = 0; } // Fills the list of the timeframes available except tick timeframes (as // ticks are not supported by PriceHistory API) O2GTimeframeCollection timeframes = controller.Timeframes; for (int i = 0; i < timeframes.Count; i++) { O2GTimeframe tf = timeframes[i]; if (tf.Unit == O2GTimeframeUnit.Tick) { continue; } TimeframeItem item = new TimeframeItem(tf); comboBoxTimeframe.Items.Add(item); } if (comboBoxTimeframe.Items.Count > 0) { comboBoxTimeframe.SelectedIndex = 0; } // Initialize the range for date/time controls dateTimePickerFrom.MinDate = new DateTime(1980, 1, 1); dateTimePickerFrom.MaxDate = DateTime.Now; dateTimePickerTo.MinDate = new DateTime(1980, 1, 1); }