Exemple #1
0
 /// <summary>
 /// Получить накопленные новости.
 /// </summary>
 /// <returns>Накопленные новости.</returns>
 public IEnumerable <News> GetNews()
 {
     ThrowIfError();
     return(_newsBuffer.SyncGet(c => c.CopyAndClear()));
 }
        private void DrawTimerOnElapsed()
        {
            try
            {
                if (_isDisposed)
                {
                    return;
                }

                _isStopped = false;

                var elements = _elements.SyncGet(c => c.CopyAndClear());

                var candleElement = elements.OfType <ChartCandleElement>().FirstOrDefault();

                if (candleElement == null)
                {
                    foreach (var e in elements.OfType <ChartIndicatorElement>())
                    {
                        var element = e;

                        var allValues = _candles
                                        .Take(_candlesCount)
                                        .Select(candle => new RefPair <DateTimeOffset, IDictionary <IChartElement, object> >(candle.OpenTime, new Dictionary <IChartElement, object>
                        {
                            { element, CreateIndicatorValue(element, candle) }
                        }))
                                        .ToList();

                        GuiDispatcher.GlobalDispatcher.AddAction(() =>
                        {
                            ChartPanel.Reset(new[] { element });
                            ChartPanel.Draw(allValues);
                        });
                    }
                }
                else
                {
                    foreach (var batch in _candles.Batch(50))
                    {
                        if (_isStopped || _isDisposed)
                        {
                            break;
                        }

                        var values = new List <RefPair <DateTimeOffset, IDictionary <IChartElement, object> > >();

                        foreach (var c in batch)
                        {
                            var candle = c;

                            var pair = new RefPair <DateTimeOffset, IDictionary <IChartElement, object> >(candle.OpenTime, new Dictionary <IChartElement, object>());

                            _candlesCount++;

                            //// ограничиваем кол-во передаваемых свечек, чтобы не фризился интерфейс
                            //if (_candlesCount % 100 == 0)
                            //	System.Threading.Thread.Sleep(200);

                            foreach (var el in ChartPanel.Elements)
                            {
                                el.DoIf <IChartElement, ChartCandleElement>(e => pair.Second.Add(e, candle));
                                el.DoIf <IChartElement, ChartIndicatorElement>(e => pair.Second.Add(e, CreateIndicatorValue(e, candle)));
                            }

                            values.Add(pair);
                        }

                        ChartPanel.Draw(values);
                    }
                }

                GuiDispatcher.GlobalDispatcher.AddAction(() => CancelButton.Visibility = Visibility.Collapsed);
            }
            catch (Exception ex)
            {
                ex.LogError();
            }
        }
 /// <summary>
 /// Get accumulated news.
 /// </summary>
 /// <returns>News.</returns>
 public IEnumerable <NewsMessage> GetNews()
 => _newsBuffer.SyncGet(c => c.CopyAndClear());
Exemple #4
0
 /// <summary>
 /// Get accumulated <see cref="BoardStateMessage"/>.
 /// </summary>
 /// <returns>States.</returns>
 public IEnumerable <BoardStateMessage> GetBoardStates()
 => _boardStatesBuffer.SyncGet(c => c.CopyAndClear());