Загрузка данных


Понял — чтобы форма открывалась в визуальном конструкторе (Design view) и элементы можно было двигать мышкой, нужна стандартная структура WinForms: отдельно `Designer.cs` (описание элементов) и отдельно `.cs` (логика). Вот три файла для вашего проекта:

**Form1.Designer.cs**
```csharp
namespace ArraySortSearchApp
{
    partial class Form1
    {
        private System.ComponentModel.IContainer components = null;

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.lblInput = new System.Windows.Forms.Label();
            this.txtInput = new System.Windows.Forms.TextBox();
            this.btnSort = new System.Windows.Forms.Button();
            this.lblTarget = new System.Windows.Forms.Label();
            this.txtTarget = new System.Windows.Forms.TextBox();
            this.btnSearch = new System.Windows.Forms.Button();
            this.txtOutput = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // lblInput
            // 
            this.lblInput.AutoSize = true;
            this.lblInput.Location = new System.Drawing.Point(10, 10);
            this.lblInput.Name = "lblInput";
            this.lblInput.Size = new System.Drawing.Size(220, 15);
            this.lblInput.Text = "Введите 10 чисел через запятую:";
            // 
            // txtInput
            // 
            this.txtInput.Location = new System.Drawing.Point(10, 35);
            this.txtInput.Name = "txtInput";
            this.txtInput.Size = new System.Drawing.Size(560, 23);
            // 
            // btnSort
            // 
            this.btnSort.Location = new System.Drawing.Point(10, 65);
            this.btnSort.Name = "btnSort";
            this.btnSort.Size = new System.Drawing.Size(220, 30);
            this.btnSort.Text = "Заполнить и отсортировать";
            this.btnSort.UseVisualStyleBackColor = true;
            this.btnSort.Click += new System.EventHandler(this.BtnSort_Click);
            // 
            // lblTarget
            // 
            this.lblTarget.AutoSize = true;
            this.lblTarget.Location = new System.Drawing.Point(10, 105);
            this.lblTarget.Name = "lblTarget";
            this.lblTarget.Size = new System.Drawing.Size(115, 15);
            this.lblTarget.Text = "Число для поиска:";
            // 
            // txtTarget
            // 
            this.txtTarget.Location = new System.Drawing.Point(160, 102);
            this.txtTarget.Name = "txtTarget";
            this.txtTarget.Size = new System.Drawing.Size(100, 23);
            // 
            // btnSearch
            // 
            this.btnSearch.Location = new System.Drawing.Point(270, 100);
            this.btnSearch.Name = "btnSearch";
            this.btnSearch.Size = new System.Drawing.Size(200, 27);
            this.btnSearch.Text = "Найти (бинарный поиск)";
            this.btnSearch.UseVisualStyleBackColor = true;
            this.btnSearch.Click += new System.EventHandler(this.BtnSearch_Click);
            // 
            // txtOutput
            // 
            this.txtOutput.Location = new System.Drawing.Point(10, 140);
            this.txtOutput.Multiline = true;
            this.txtOutput.Name = "txtOutput";
            this.txtOutput.ReadOnly = true;
            this.txtOutput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
            this.txtOutput.Size = new System.Drawing.Size(560, 300);
            // 
            // Form1
            // 
            this.ClientSize = new System.Drawing.Size(600, 470);
            this.Controls.Add(this.txtOutput);
            this.Controls.Add(this.btnSearch);
            this.Controls.Add(this.txtTarget);
            this.Controls.Add(this.lblTarget);
            this.Controls.Add(this.btnSort);
            this.Controls.Add(this.txtInput);
            this.Controls.Add(this.lblInput);
            this.Name = "Form1";
            this.Text = "Массив, сортировка, поиск";
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private System.Windows.Forms.Label lblInput;
        private System.Windows.Forms.TextBox txtInput;
        private System.Windows.Forms.Button btnSort;
        private System.Windows.Forms.Label lblTarget;
        private System.Windows.Forms.TextBox txtTarget;
        private System.Windows.Forms.Button btnSearch;
        private System.Windows.Forms.TextBox txtOutput;
    }
}
```

**Form1.cs**
```csharp
using System;
using System.Windows.Forms;

namespace ArraySortSearchApp
{
    public partial class Form1 : Form
    {
        private int[] numbers;

        public Form1()
        {
            InitializeComponent();
        }

        private void BtnSort_Click(object sender, EventArgs e)
        {
            txtOutput.Clear();

            string[] parts = txtInput.Text.Split(',');
            if (parts.Length != 10)
            {
                MessageBox.Show("Введите ровно 10 чисел через запятую.");
                return;
            }

            numbers = new int[10];
            for (int i = 0; i < 10; i++)
            {
                if (!int.TryParse(parts[i].Trim(), out numbers[i]))
                {
                    MessageBox.Show("Одно из значений — не целое число.");
                    return;
                }
            }

            txtOutput.AppendText("Массив до сортировки: " + string.Join(", ", numbers) + Environment.NewLine);

            for (int i = 0; i < numbers.Length - 1; i++)
            {
                for (int j = 0; j < numbers.Length - 1 - i; j++)
                {
                    if (numbers[j] > numbers[j + 1])
                    {
                        int temp = numbers[j];
                        numbers[j] = numbers[j + 1];
                        numbers[j + 1] = temp;
                    }
                }
                txtOutput.AppendText($"После прохода {i + 1}: {string.Join(", ", numbers)}" + Environment.NewLine);
            }

            txtOutput.AppendText("Массив после сортировки: " + string.Join(", ", numbers) + Environment.NewLine);
        }

        private void BtnSearch_Click(object sender, EventArgs e)
        {
            if (numbers == null)
            {
                MessageBox.Show("Сначала заполните и отсортируйте массив.");
                return;
            }

            if (!int.TryParse(txtTarget.Text.Trim(), out int target))
            {
                MessageBox.Show("Введите корректное число для поиска.");
                return;
            }

            txtOutput.AppendText(Environment.NewLine + $"Поиск числа {target}:" + Environment.NewLine);

            int left = 0;
            int right = numbers.Length - 1;
            int result = -1;

            while (left <= right)
            {
                int middle = (left + right) / 2;
                txtOutput.AppendText($"left={left}, right={right}, middle={middle} (numbers[middle]={numbers[middle]})" + Environment.NewLine);

                if (numbers[middle] == target)
                {
                    result = middle;
                    break;
                }

                if (target < numbers[middle])
                    right = middle - 1;
                else
                    left = middle + 1;
            }

            if (result != -1)
                txtOutput.AppendText($"Число {target} найдено на индексе {result}." + Environment.NewLine);
            else
                txtOutput.AppendText($"Число {target} в массиве не найдено." + Environment.NewLine);
        }
    }
}
```

**Program.cs**
```csharp
namespace ArraySortSearchApp
{
    internal static class Program
    {
        [STAThread]
        static void Main()
        {
            ApplicationConfiguration.Initialize();
            Application.Run(new Form1());
        }
    }
}
```

**Что сделать в Visual Studio:**
1. Замените содержимое существующих `Form1.cs`, `Form1.Designer.cs` и `Program.cs` на эти файлы (файл `Form1.Designer.cs` может быть скрыт — раскройте `Form1.cs` в Solution Explorer, нажав на стрелочку слева от него).
2. Если у вас проект называется не `ArraySortSearchApp` — замените namespace на ваш.
3. Пересоберите проект (Build → Rebuild Solution).
4. Дважды кликните по `Form1.cs` в Solution Explorer — откроется визуальный конструктор, и вы увидите форму с элементами, которые можно двигать мышкой.