private void button2_Click(object sender, EventArgs e) { int period; if(!int.TryParse(textBox1.Text, out period)) MessageBox.Show("Число років прогнозування має бути цілим"); IForecast lineFc; if (count[0] < count[1]) lineFc = new LiniarForecast(); else lineFc = new LiniarDownForecast(); double[] _years; double[] _counts; lineFc.MakeForecast(years, count, out _years, out _counts, period ); string[] lables = new string[_years.Length]; for (int i = 0; i < _years.Length; i++) { lables[i] = string.Format("{0}", _years[i]); } double[] bars = new double[_counts.Length]; double[] forecastyears = new double[_counts.Length]; for (int i = _counts.Length - period; i < _counts.Length; i++) { forecastyears[i] = _years[i]; bars[i] = _counts[i]; } zedGraphControl1.GraphPane.XAxis.Scale.TextLabels = lables; zedGraphControl1.GraphPane.AddBar("Лінійний прогноз", forecastyears, bars, Color.FromArgb(100, 12, 22, 200)); zedGraphControl1.GraphPane.AddCurve("Лінійний прогноз", _years, _counts, Color.BlueViolet); zedGraphControl1.AxisChange(); zedGraphControl1.Refresh(); }