//ergebnis anzeigen private void callback_invoke(NumVariator.result result) { stepsDone++; for (int i = 0; i < result.rms.Length; i++) { betarmsseries[i].Points.AddXY(result.beta / Math.PI, result.rms[i]); } for (int i = 0; i < result.ljapunow.Length; i++) { if (result.ljapunow[i] > -50 && result.ljapunow[i] < 50) betaljapseries[i].Points.AddXY(result.beta / Math.PI, result.ljapunow[i]); } if (stepsDone > (int)stepsUpDown.Value) { for (int i = 0; i < result.ljapunow.Length; i++) { betaljapseries[i].Sort(PointSortOrder.Ascending, "X"); betarmsseries[i].Sort(PointSortOrder.Ascending, "X"); betarmsseries[i].ChartType = SeriesChartType.Spline; betarmsseries[i]["LineTension"] = "0.65"; betaljapseries[i].ChartType = SeriesChartType.Spline; betaljapseries[i]["LineTension"] = "0.65"; } //wir sind fertig betaRunButton.Text = "Run Simulation"; } Application.DoEvents(); }
private void betaRunButton_Click(object sender, EventArgs e) { if (variatorThread != null && variatorThread.IsAlive) { variatorThread.Abort(); betaRunButton.Text = "Run Simulation"; } else { betaRunButton.Text = "Stop Simulation"; betaRmsChart.Series.Clear(); betaLjapChart.Series.Clear(); betarmsseries = new Series[cluster.Length]; betaljapseries = new Series[cluster.Length]; betaRmsChart.ChartAreas[0].AxisX.Minimum = (double)betaMinUpDown.Value; betaRmsChart.ChartAreas[0].AxisX.Maximum = (double)betaMaxUpDown.Value; betaLjapChart.ChartAreas[0].AxisX.Minimum = (double)betaMinUpDown.Value; betaLjapChart.ChartAreas[0].AxisX.Maximum = (double)betaMaxUpDown.Value; for (int i = 0; i < cluster.Length; i++) { System.Windows.Media.Color coltmp = Vertex.cluster_colors[i % Vertex.cluster_colors.Length]; betarmsseries[i] = new Series("Cluster " + i.ToString()); betarmsseries[i].ChartArea = "ChartArea1"; betaRmsChart.Series.Add(betarmsseries[i]); betarmsseries[i].ChartType = SeriesChartType.FastPoint; betarmsseries[i].Color = Color.FromArgb(255, coltmp.R, coltmp.G, coltmp.B); betarmsseries[i].BorderWidth = 2; betaljapseries[i] = new Series("Cluster " + i.ToString()); betaljapseries[i].ChartArea = "ChartArea1"; betaLjapChart.Series.Add(betaljapseries[i]); betaljapseries[i].ChartType = SeriesChartType.FastPoint; betaljapseries[i].Color = Color.FromArgb(255, coltmp.R, coltmp.G, coltmp.B); betaljapseries[i].BorderWidth = 2; if (i % 2 != 0) { betaljapseries[i].BorderDashStyle = ChartDashStyle.Dash; } } stepsDone = 0; Action<NumVariator.result> callback_action = callback; variator = new NumVariator(adjmatrix, TMat, (double)betaMinUpDown.Value * Math.PI, (double)betaMaxUpDown.Value * Math.PI, (int)stepsUpDown.Value, sigma, delta, noise, pertubation, (int)preUpDown.Value, (int)recUpDown.Value, cluster, callback_action); variatorThread = new Thread(variator.DoWork); variatorThread.Start(); } }
private void callback(NumVariator.result result) { //wird auf dem anderen thread aufgerufen. damit winforms sachen geändert werden können muss das anscheinend über invoke gehen callbackDelegate callbackD = new callbackDelegate(callback_invoke); this.Invoke(callbackD, result); }