Esempio n. 1
0
        public Livedata(LiveFeed currLiveFeed)
        {
            InitializeComponent();
            this.SLiveFeed = currLiveFeed;

            var mapper = Mappers.Xy <MeasureModel>()
                         .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X
                         .Y(model => model.Value);         //use the value property as Y

            //lets save the mapper globally.
            Charting.For <MeasureModel>(mapper);

            //the values property will store our values array
            ChartValuesPrice = new ChartValues <MeasureModel>();
            //ChartValuesAsk = new ChartValues<MeasureModel>();
            //ChartValuesBid = new ChartValues<MeasureModel>();

            //lets set how to display the X Labels
            DateTimeFormatter = value => new DateTime((long)value).ToString("hh:mm:ss");

            AxisStep = TimeSpan.FromSeconds(1).Ticks;
            SetAxisLimits(DateTime.Now);

            //The next code simulates data changes every 1000 ms
            Timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(1000)
            };
            Timer.Tick            += TimerOnTick;
            IsDataInjectionRunning = false;

            DataContext = this;

            if (IsDataInjectionRunning)
            {
                Timer.Stop();
                IsDataInjectionRunning = false;
            }
            else
            {
                Timer.Start();
                IsDataInjectionRunning = true;
            }

            //this.Foreground = new SolidColorBrush(Colors.Black);
            //this.priceSeries.Foreground = new SolidColorBrush(Colors.Red);
            //this.Background = new SolidColorBrush(Colors.Black);

            //this.priceSeries.DataContext = ChartValuesPrice;
            //this.askSeries.DataContext = ChartValuesAsk;
            //this.bidSeries.DataContext = ChartValuesBid;
        }
Esempio n. 2
0
        private void addStockListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var      listBox   = sender as ListBox;
            LiveFeed sLiveFeed = listBox.SelectedItem as LiveFeed;

            this.LiveFeedAdd = sLiveFeed as LiveFeed;

            if (LivedataToAddList != null)
            {
                //LivedataToAddList.Where(l => l.SStock.Ticker == SAddStock.Ticker).Equals(SAddStock as Stock);

                this.livedataChartAdd.DataContext = LivedataToAddList.Where(l => l.SLiveFeed.Ticker == StockToAdd.Ticker);
            }
        }
Esempio n. 3
0
        private void addStockButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.addStockListBox.SelectedItem != null)
            {
                int volume;
                int.TryParse(this.addStockVolumeTextBox.Text, out volume);

                if (volume != 0)
                {
                    LiveFeed sStockFeed = this.addStockListBox.SelectedItem as LiveFeed;
                    LiveFeedAdd = sStockFeed as LiveFeed;
                    StockToAdd  = new Position {
                        Ticker = LiveFeedAdd.Ticker, CompanyName = LiveFeedAdd.Ticker, Shares = volume, SharesProfitLoss = LiveFeedAdd.Price
                    };

                    MessageBox.Show("Stock successfully added", "Stock Added", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show("Unknown error occured");
                }
            }
        }