private void SinCount_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) // Нажали <ENTER> { foreach (var i in tb) { this.Controls.Remove(i); } int s = 0; try { s = Convert.ToInt32(SinCount.Text); } catch (Exception ex) { Console.WriteLine(ex.Message); } tb = new SinPanel[s]; if (s == 0) { this.Size = new System.Drawing.Size(this.Width, this.Height); } for (int i = 0; i < s; i++) { tb[i] = new SinPanel(); tb[i].Location = new System.Drawing.Point(SinCount.Location.X + -5 + ((i) * tb[i].Width), 50); tb[i].Name = "sinTextBox" + i; if (this.Width < SinCount.Location.X - 5 + (s * tb[i].Width)) { this.Size = new System.Drawing.Size(SinCount.Location.X + 5 + ((i + 1) * tb[i].Width), this.Height); } this.Controls.Add(tb[i]); } } }
private void Start_Click_1(object sender, EventArgs e) { ////////////////// ОЧИСТКА ГРАФИКОВ И ФОРМЫ ///////////////////// //SignGraph.Series[0].Points.Clear(); //SignGraph.Series[1].Points.Clear(); //SignGraph.Series[2].Points.Clear(); //forform.Clear(); ////////////////// ОПРЕДЕЛЕНИЕ ПЕРЕМЕННЫХ ///////////////////// UInt32 _end = Convert.ToUInt32(this.end.Text); int length = 0; SinPanel tb = sinPanel1; //SignGraph.Series[0].Points.Clear(); int ampl = Convert.ToInt32(sinPanel1.tbA.Text); //амлитуда double freq = Convert.ToDouble(sinPanel1.tbB.Text); //частота double phase = 0.0; //фаза начальная UInt16 first = 0; //начало UInt32 last = _end; //конец if (SqWindow.Checked) { forform.SqSinGen(ampl, freq, phase, first, last); } else if (TrWindow.Checked) { forform.TrSinGen(ampl, freq, phase, first, Convert.ToInt32(last)); } else if (CosWindow.Checked) { forform.CosSinGen(ampl, freq, phase, first, last); } forform.SignalwithWhiteNoise(Convert.ToInt32(NoisePerc.Text)); NoiseText.Text = forform.GetCoef().ToString(); sign = forform.SignReturn(); ////////////////// СОЗДАНИЕ ГРАФИКОВ ///////////////////// SignGraph.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; SignGraph.Series[0].Color = Color.Red; SignGraph.Series[0].BorderWidth = 1; SignGraph.Series[1].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; SignGraph.Series[1].Color = Color.Black; SignGraph.Series[1].BorderWidth = 1; SignGraph.Series[2].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; SignGraph.Series[2].Color = Color.Green; SignGraph.Series[2].BorderWidth = 1; length = forform.GetS(); ////////////////// ПОСТРОЕНИЕ ///////////////////// for (int i = 0; i < length; i++) { //double x; int x; x = i; double y = forform.GetYPoints(i); SignGraph.Series[0].Points.AddXY(x, y); // this.SignGraph.ChartAreas[0].AxisX.Interval = length / 10; this.SignGraph.ChartAreas[0].AxisX.Minimum = 0; } }