public async void Play_Experiment(Device tool) { for (double i = 0; i < 120; i += 0.5) { DataChartNode active = null; foreach (ExperimentNode node in Exp.Cards) { if (node.GetType() == typeof(DataChartNode)) { active = node as DataChartNode; } } Debug.WriteLine("Playing"); DataPoint d = await Get_DataPoints(i); Debug.WriteLine(d.X); active.Add_Data_Point(d); } Playing = true; ProgressRing ring = new ProgressRing() { Height = 25, Width = 25, IsActive = true }; PlayExperimentButton.Content = ring; PlayExperimentButton.Click -= Play_Click; PlayExperimentButton.Click += Abort_Experiment; }
public async void Create_New_Card(object sender, RoutedEventArgs e) { ExperimentNode obj = ((MenuFlyoutItem)sender).Tag as ExperimentNode; string sel = ((PivotItem)RootPivot.SelectedItem).Header as string; if (obj.GetType() == typeof(DataChartNode)) { DataChartNode chart = ((DataChartNode)obj); List <VariableNode> dVars = Exp.GetVariables(VariableNode.VariableType.Dependent); List <VariableNode> iVars = Exp.GetVariables(VariableNode.VariableType.Independent); string title = ""; if (dVars.Count > 0 && iVars.Count > 0) { ChartVariable chartDialog = new ChartVariable(dVars, iVars); var result = await chartDialog.ShowAsync(); if (result == ContentDialogResult.Primary) { int iD = chartDialog.iD; int iI = chartDialog.iI; title = iVars[iI].Measurement_Name + " (" + iVars[iI].Unit_Name + ") vs " + dVars[iD].Measurement_Name + " (" + dVars[iD].Unit_Name + ")"; chart.Independent = iVars[iI]; chart.Dependent = dVars[iD]; chart.Title = title; ListView list = (ListView)FindName(sel.Replace(" ", "") + "Cards"); list.Items.Add(obj); Exp.AddNode(obj); Exp.Save(); } } else { ContentDialog dialog = new ContentDialog() { Title = "Please specify experiment variables", Content = "To create a chart, experiment variables must be created in" + "the Problem Tab. Go to the tab and specify at least one Independent and " + "Dependent Variable.", PrimaryButtonText = "OK" }; await dialog.ShowAsync(); } } else { Exp.AddNode(obj); ListView list = (ListView)FindName(sel.Replace(" ", "") + "Cards"); list.Items.Add(obj); Exp.Save(); } }
public async void Run_Manual() { DataChartNode active = null; foreach (ExperimentNode node in Exp.Cards) { if (node.GetType() == typeof(DataChartNode)) { active = node as DataChartNode; } } for (double i = 0; i < 120; i += 0.5) { Debug.WriteLine("Playing"); DataPoint d = await Get_DataPoints(i); Debug.WriteLine(d.X); active.Add_Data_Point(d); ListViewItem temp = (ListViewItem)DataAnalysisCards.ContainerFromItem(active); Chart c = FindByName("chart", temp) as Chart; if (active.Type == DataChartNode.ChartType.Line) { ((LineSeries)c.Series[0]).ItemsSource = null; ((LineSeries)c.Series[0]).ItemsSource = active.Data; } else if (active.Type == DataChartNode.ChartType.Bar) { ((LineSeries)c.Series[0]).ItemsSource = null; ((LineSeries)c.Series[0]).ItemsSource = active.Data; } else if (active.Type == DataChartNode.ChartType.Scatter) { ((LineSeries)c.Series[0]).ItemsSource = null; ((LineSeries)c.Series[0]).ItemsSource = active.Data; } } }