private void MainForm_Resize(object sender, EventArgs e) { // Вычисляем коэффициенты…
- User
private void MainForm_Resize(object sender, EventArgs e) { // Вычисляем коэффициенты изменения float widthRatio = (float)this.ClientSize.Width / initialWidth; float heightRatio = (float)this.ClientSize.Height / initialHeight; Console.WriteLine(widthRatio);
code// Установка новых размеров TextBox if ((float)this.ClientSize.Width>FWidth) { textBox1.Width = (int)(textBox1.Width + 1); textBox2.Width = (int)(textBox2.Width + 1); textBox3.Width = (int)(textBox3.Width + 1); } if ((float)this.ClientSize.Width<FWidth) { textBox1.Width = (int)(textBox1.Width - 1); textBox2.Width = (int)(textBox2.Width - 1); textBox3.Width = (int)(textBox3.Width - 1); } if ((float)this.ClientSize.Height>FHeight) { textBox1.Height = (int)(textBox1.Height + heightRatio); textBox2.Height = (int)(textBox2.Height + heightRatio); textBox3.Height = (int)(textBox3.Height + heightRatio); } if ((float)this.ClientSize.Height<FHeight) { textBox1.Height = (int)(textBox1.Height - heightRatio); textBox2.Height = (int)(textBox2.Height - heightRatio); textBox3.Height = (int)(textBox3.Height - heightRatio); } // Установка новых позиций TextBox textBox1.Location = new Point( (int)(textBox1InitialLocation.X * widthRatio), (int)(textBox1InitialLocation.Y * heightRatio) ); textBox2.Location = new Point( (int)(textBox2InitialLocation.X * widthRatio), (int)(textBox2InitialLocation.Y * heightRatio) ); textBox3.Location = new Point( (int)(textBox3InitialLocation.X * widthRatio), (int)(textBox3InitialLocation.Y * heightRatio) ); FWidth = (int)this.ClientSize.Width; FHeight = (int)this.ClientSize.Height;} в этом коде изменение размеров textBox происходит неправильно (чем медленней изменяешь окно, тем быстрее изменяется размер textBox)
- Assistant