private void SubscribePrices()
        {
            var prices        = ApplicationSettings.Instance.PricesToWatch;
            var priceInfoList = new ObservableCollection <PriceInfo>();

            foreach (var market in prices)
            {
                var id        = market.MarketId;
                var priceInfo = new PriceInfo {
                    MarketId = id, MarketName = market.Name
                };
                priceInfo.Color = new SolidColorBrush(PriceGraph.GetGraphColor(id.ToString()));
                priceInfoList.Add(priceInfo);

                PriceGraphSingle.SetGraphBrush(priceInfo.MarketId.ToString(), priceInfo.Color);

                State.Data.SubscribePrices(id,
                                           price =>
                {
                    //var priceBar = State.Data.GetPriceBar(price.MarketId);

                    priceInfo.Price  = price.Price;
                    priceInfo.Change = price.Change;
                    OnGraphUpdate(price);
                });
            }

            PricesView.DataContext = priceInfoList;
        }
        private void OnGraphUpdate(PriceDTO val)
        {
            var item = new GraphItem {
                Value = (double)val.Price, Time = val.TickDate
            };
            var key = val.MarketId.ToString();

            PriceGraph.AddItem(key, item);
            PriceGraphSingle.AddItem(key, item);
        }
        private void OnGraphUpdate(PriceDTO val)
        {
            // NOTE this code is a temporary workaround until datetime bug is fixed
            var ticksString = val.TickDate.Substring(7, val.TickDate.Length - 10);
            var time        = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddMilliseconds(Int64.Parse(ticksString));

            var item = new GraphItem {
                Value = (double)val.Price, Time = time
            };
            var key = val.MarketId.ToString();

            PriceGraph.AddItem(key, item);
            PriceGraphSingle.AddItem(key, item);
        }
 private void PricesView_SelectedChanged(object sender, SelectedPriceChangedArgs e)
 {
     PriceGraphSingle.SetCurrentVisible(e.Val.MarketId.ToString());
 }