Ejemplo n.º 1
0
		private void Window1_Loaded(object sender, RoutedEventArgs e)
		{
			RingCurrentConsumptions = new RingCurrentConsumptions();
			var plotViewModel = DataContext as PlotViewModel;
			if (plotViewModel == null)
				return;

			plotViewModel.UpdateFromDBAction = UpdateFromDB;

			updateCollectionTimer = new DispatcherTimer();
			updateCollectionTimer.Interval = TimeSpan.FromMilliseconds(1000);
			updateCollectionTimer.Tick += Update;
			updateCollectionTimer.Start();

			restr = new ViewportAxesRangeRestriction();
			restr.YRange = new DisplayRange(-5, 250);
			plotter.Viewport.Restrictions.Add(restr);
		}
Ejemplo n.º 2
0
		private void ButtonOnline_OnClick(object sender, RoutedEventArgs e)
		{
			RingCurrentConsumptions = new RingCurrentConsumptions();
			if (updateCollectionTimer != null)
			{
				updateCollectionTimer.Tick -= Update;
				updateCollectionTimer.Stop();
			}

			plotter.Children.RemoveAll(typeof(MarkerPointsGraph));
			plotter.Children.RemoveAll(typeof(LineGraph));

			updateCollectionTimer = new DispatcherTimer();
			updateCollectionTimer.Interval = TimeSpan.FromMilliseconds(1000);
			updateCollectionTimer.Tick += Update;
			updateCollectionTimer.Start();

			var ds = new EnumerableDataSource<CurrentConsumption>(RingCurrentConsumptions);
			ds.SetXMapping(x => dateAxis.ConvertToDouble(x.DateTime));
			ds.SetYMapping(y => y.Current);
			plotter.AddLineGraph(ds, new Pen(Brushes.Green, 2), new CirclePointMarker { Size = 5.0, Fill = Brushes.Red }, new PenDescription("Статистика токопотребления"));
		}