public static void DrawChart(Chart chart, int[] testArr, ChartType type = ChartType.Comparsions) { Form prompt = new Form() { Width = 500, Height = 100, FormBorderStyle = FormBorderStyle.FixedDialog, Text = "Построение графика", StartPosition = FormStartPosition.CenterScreen }; ProgressBar progressBar = new ProgressBar() { Left = 10, Width = 450, Top = 20, Height = 20 }; progressBar.Value = 0; prompt.Controls.Add(progressBar); prompt.Show(); var twoWaysInsertions = chart.Series[0]; twoWaysInsertions.Points.Clear(); var twoWaysInsertionsList = chart.Series[1]; twoWaysInsertionsList.Points.Clear(); var bubbleSort = chart.Series[2]; bubbleSort.Points.Clear(); int[] arr = (int[])testArr.Clone(); progressBar.Minimum = 0; progressBar.Maximum = (testArr.Length * 3); for (int i = 1; i < testArr.Length; i++) { arr = (int[])testArr.Clone(); Sorter.TwoWaysInsertionSort(arr, 0, i); twoWaysInsertions.Points.AddXY(i, (type == ChartType.Comparsions) ? Sorter.ComparsionsCount : Sorter.SwapsCount); progressBar.Value++; arr = new int[i + 1]; Array.Copy(testArr, 0, arr, 0, i); DoubleLinkedList list = new DoubleLinkedList(arr); Sorter.TwoWaysListInsertionSort(ref list); twoWaysInsertionsList.Points.AddXY(i, (type == ChartType.Comparsions) ? Sorter.ComparsionsCount : Sorter.SwapsCount); progressBar.Value++; arr = (int[])testArr.Clone(); Sorter.BubbleSort(arr, 0, i); bubbleSort.Points.AddXY(i, (type == ChartType.Comparsions) ? Sorter.ComparsionsCount : Sorter.SwapsCount); progressBar.Value++; } prompt.Close(); }