public DynamicLine() { InitializeComponent(); //In this case we will not only plot double values //to make it easier to handle "live-data" we are going to use WeatherViewModel class //we need to let LiveCharts know how to use this model //first we create a new configuration for WeatherViewModel var config = new SeriesConfiguration<WeatherViewModel>(); //now we map X and Y //we will use Temperature as Y config.Y(model => model.Temperature); //and DateTime as X, we convert to OADate so we can plot it easly. config.X(model => model.DateTime.ToOADate()); //now we create our series with this configuration Series = new SeriesCollection(config) {new LineSeries {Values = new ChartValues<WeatherViewModel>()}}; //to display a custom label we will use a formatter, //formatters are just functions that take a double value as parameter //and return a string, in this case we will convert the OADate to DateTime //and then use a custom date format XFormatter = val => DateTime.FromOADate(val).ToString("hh:mm:ss tt"); //now for Y we are rounding and adding ° for degrees YFormatter = val => Math.Round(val) + " °"; //Don't forget DataContext so we can bind these properties. DataContext = this; _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; _timer.Tick += TimerOnTick; }
public DynamicLine() { InitializeComponent(); //In this case we will not only plot double values //to make it easier to handle "live-data" we are going to use WeatherViewModel class //we need to let LiveCharts know how to use this model //first we create a new configuration for WeatherViewModel var config = new SeriesConfiguration <WeatherViewModel>(); //now we map X and Y //we will use Temperature as Y config.Y(model => model.Temperature); //and DateTime as X, we convert to OADate so we can plot it easly. //config.X(model => model.DateTime.ToOADate()); config.X(x => x.Test); //now we create our series with this configuration Series = new SeriesCollection(config) { new LineSeries { Values = new ChartValues <WeatherViewModel>(), PointRadius = 0 } }; //to display a custom label we will use a formatter, //formatters are just functions that take a double value as parameter //and return a string, in this case we will convert the OADate to DateTime //and then use a custom date format //XFormatter = val => DateTime.FromOADate(val).ToString("hh:mm:ss tt"); //now for Y we are rounding and adding ° for degrees YFormatter = val => Math.Round(val) + " °"; //Don't forget DataContext so we can bind these properties. DataContext = this; _timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(500) }; _timer.Tick += TimerOnTick; }
private void InitializeChart() { var config = new SeriesConfiguration <UsageViewModel>(); config.Y(x => x.Usage); config.X(x => x.Time.ToOADate()); Series = new SeriesCollection(config) { new LineSeries { Values = new ChartValues <UsageViewModel>(), PointRadius = 0, }, new LineSeries { Values = new ChartValues <UsageViewModel>(), PointRadius = 0, } }; DataContext = this; YFormatter = val => ""; XFormatter = val => ""; }
public MainWindow() { InitializeComponent(); timer.Start(); setUpBaudRates(); var config = new SeriesConfiguration <tempGraph>(); config.Y(model => model.temperature); config.X(model => model.time.ToOADate()); Series = new SeriesCollection(config) { new LineSeries { Values = new ChartValues <tempGraph>() } }; Series.Add(new LineSeries { Values = new ChartValues <tempGraph>() }); Series.Add(new LineSeries { Values = new ChartValues <tempGraph>() }); Series[0].Title = "External Temperature"; Series[1].Title = "Internal Temperature"; Series[2].Title = "Ground Temperature"; XFormatter = val => DateTime.FromOADate(val).ToString("mm.ss"); YFormatter = val => val + " °"; DataContext = this; _timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) }; _timer.Tick += TimerOnTick; _timer.Start(); var config2 = new SeriesConfiguration <pressureGraph>(); config2.Y(model => model.pressure); config2.X(model => model.time.ToOADate()); Series2 = new SeriesCollection(config2) { new LineSeries { Values = new ChartValues <pressureGraph>() } }; Series2.Add(new LineSeries { Values = new ChartValues <pressureGraph>() }); Series2[0].Title = "Barometric Pressure"; Series2[1].Title = "Ground Barometric Pressure"; XFormatter2 = val => DateTime.FromOADate(val).ToString("mm.ss"); YFormatter2 = val => val + "hPa"; DataContext = this; _timer2 = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) }; _timer2.Tick += Timer2OnTick; _timer2.Start(); this.Show(); setUpPossibleInputsForSerialPort(); ///AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Binding binding_1 = new Binding("SelectedValue"); binding_1.Source = VideoDevicesComboBox; WebcamCtrl.SetBinding(Webcam.VideoDeviceProperty, binding_1); Binding binding_2 = new Binding("SelectedValue"); binding_2.Source = AudioDevicesComboBox; WebcamCtrl.SetBinding(Webcam.AudioDeviceProperty, binding_2); // Create directory for saving video files string videoPath = @"C:\VideoClips"; if (!Directory.Exists(videoPath)) { Directory.CreateDirectory(videoPath); } // Create directory for saving image files string imagePath = @"C:\WebcamSnapshots"; if (!Directory.Exists(imagePath)) { Directory.CreateDirectory(imagePath); } //AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA // Set some properties of the Webcam control WebcamCtrl.VideoDirectory = videoPath; WebcamCtrl.ImageDirectory = imagePath; WebcamCtrl.FrameRate = 72; WebcamCtrl.FrameSize = new System.Drawing.Size(1080, 720); // Find available a/v devices var vidDevices = EncoderDevices.FindDevices(EncoderDeviceType.Video); var audDevices = EncoderDevices.FindDevices(EncoderDeviceType.Audio); VideoDevicesComboBox.ItemsSource = vidDevices; AudioDevicesComboBox.ItemsSource = audDevices; VideoDevicesComboBox.SelectedIndex = 0; AudioDevicesComboBox.SelectedIndex = 0; releaseServo.IsEnabled = false; servoArm.IsEnabled = false; t1.IsEnabled = false; t2.IsEnabled = false; bw.DoWork += Bw_DoWork; bw.RunWorkerCompleted += Bw_RunWorkerCompleted; bw.RunWorkerAsync(); }
static ReactiveObservableCollectionWrapper() { DefaultConfiguration.Y(model => model.Count); DefaultConfiguration.X(model => model.Time.ToOADate()); }
public MainWindow() { InitializeComponent(); timer.Start(); setUpBaudRates(); var config = new SeriesConfiguration<tempGraph>(); config.Y(model => model.temperature); config.X(model => model.time.ToOADate()); Series = new SeriesCollection(config) { new LineSeries { Values = new ChartValues<tempGraph>() } }; Series.Add(new LineSeries { Values = new ChartValues<tempGraph>() }); Series.Add(new LineSeries { Values = new ChartValues<tempGraph>() }); Series[0].Title = "External Temperature"; Series[1].Title = "Internal Temperature"; Series[2].Title = "Ground Temperature"; XFormatter = val => DateTime.FromOADate(val).ToString("mm.ss"); YFormatter = val => val + " °"; DataContext = this; _timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) }; _timer.Tick += TimerOnTick; _timer.Start(); var config2 = new SeriesConfiguration<pressureGraph>(); config2.Y(model => model.pressure); config2.X(model => model.time.ToOADate()); Series2 = new SeriesCollection(config2) { new LineSeries { Values = new ChartValues<pressureGraph>() } }; Series2.Add(new LineSeries { Values = new ChartValues<pressureGraph>() }); Series2[0].Title = "Barometric Pressure"; Series2[1].Title = "Ground Barometric Pressure"; XFormatter2 = val => DateTime.FromOADate(val).ToString("mm.ss"); YFormatter2 = val => val + "hPa"; DataContext = this; _timer2 = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) }; _timer2.Tick += Timer2OnTick; _timer2.Start(); this.Show(); setUpPossibleInputsForSerialPort(); ///AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Binding binding_1 = new Binding("SelectedValue"); binding_1.Source = VideoDevicesComboBox; WebcamCtrl.SetBinding(Webcam.VideoDeviceProperty, binding_1); Binding binding_2 = new Binding("SelectedValue"); binding_2.Source = AudioDevicesComboBox; WebcamCtrl.SetBinding(Webcam.AudioDeviceProperty, binding_2); // Create directory for saving video files string videoPath = @"C:\VideoClips"; if (!Directory.Exists(videoPath)) { Directory.CreateDirectory(videoPath); } // Create directory for saving image files string imagePath = @"C:\WebcamSnapshots"; if (!Directory.Exists(imagePath)) { Directory.CreateDirectory(imagePath); } //AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA // Set some properties of the Webcam control WebcamCtrl.VideoDirectory = videoPath; WebcamCtrl.ImageDirectory = imagePath; WebcamCtrl.FrameRate = 72; WebcamCtrl.FrameSize = new System.Drawing.Size(1080, 720); // Find available a/v devices var vidDevices = EncoderDevices.FindDevices(EncoderDeviceType.Video); var audDevices = EncoderDevices.FindDevices(EncoderDeviceType.Audio); VideoDevicesComboBox.ItemsSource = vidDevices; AudioDevicesComboBox.ItemsSource = audDevices; VideoDevicesComboBox.SelectedIndex = 0; AudioDevicesComboBox.SelectedIndex = 0; releaseServo.IsEnabled = false; servoArm.IsEnabled = false; t1.IsEnabled = false; t2.IsEnabled = false; bw.DoWork += Bw_DoWork; bw.RunWorkerCompleted += Bw_RunWorkerCompleted; bw.RunWorkerAsync(); }