private void ShowChartClick(object sender, RoutedEventArgs e) { var security = SelectedSecurity; CandleSeries series; if (IsRealTime.IsChecked == true) { var type = CandleType.GetSelectedValue <CandleTypes>().Value; switch (type) { case CandleTypes.TimeFrame: series = new CandleSeries(typeof(TimeFrameCandle), security, TimeFrame.Value.Value.TimeOfDay); break; case CandleTypes.Tick: series = new CandleSeries(typeof(TickCandle), security, VolumeCtrl.Text.To <int>()); break; case CandleTypes.Volume: series = new CandleSeries(typeof(VolumeCandle), security, VolumeCtrl.Text.To <decimal>()); break; case CandleTypes.Range: series = new CandleSeries(typeof(RangeCandle), security, PriceRange.Value); break; default: throw new ArgumentOutOfRangeException(); } } else { var timeFrame = (TimeSpan)HistoryInterval.SelectedItem; series = new CandleSeries(typeof(TimeFrameCandle), security, timeFrame); } _chartWindows.SafeAdd(series, key => { var wnd = new ChartWindow { Title = "{0} {1} {2}".Put(security.Code, series.CandleType.Name.Replace("Candle", string.Empty), series.Arg) }; wnd.MakeHideable(); var area = new ChartArea(); wnd.Chart.Areas.Add(area); var candlesElem = new ChartCandleElement(); area.Elements.Add(candlesElem); series.ProcessCandle += candle => wnd.Chart.Draw(candlesElem, candle); return(wnd); }).Show(); _candleManager.Start(series, (DateTime)From.Value, (DateTime)To.Value); }
private void CandleTypesSelectionChanged(object sender, SelectionChangedEventArgs e) { var type = CandleType.GetSelectedValue <CandleTypes>().Value; TimeFrame.SetVisibility(type == CandleTypes.TimeFrame); PriceRange.SetVisibility(type == CandleTypes.Range); VolumeCtrl.SetVisibility(type == CandleTypes.Tick || type == CandleTypes.Volume); }