C# 'da ekran çözünürlüğüne göre Scale işlemi

Başlatan Mucit23, 04 Temmuz 2022, 12:50:14

Mucit23

C# da yaptığım tasarımı tam ekran yatığımda Ekran çözünürlüğüne göre tam oturmasını istiyorum. Bunu Scale işlemini kullanarak yapmaya çalıştım. Ama sanki tam olmadı. Tam ekran yaptığımda komponentler form içinde ekrana tam oturmuyor.

Resize Eventine yazdığım kod bu şekilde
        private void Form1_Resize(object sender, EventArgs e)
        {
            if (WindowState != LastWindowState)
            {
                LastWindowState = WindowState;

                if (WindowState == FormWindowState.Maximized)
                {
                    WidthNow = 1080;
                    HeightNow = 720;

                    this.Location = new Point(0, 0);
                    this.Size = Screen.PrimaryScreen.WorkingArea.Size;
                    
                    float WidthRatio = ((float)Screen.PrimaryScreen.WorkingArea.Size.Width / (float)WidthNow);
                    float HeightRatio = ((float)Screen.PrimaryScreen.WorkingArea.Size.Height / (float)HeightNow);
                    this.Scale(new SizeF(WidthRatio, HeightRatio));

                }
                if (WindowState == FormWindowState.Normal)
                {
                    WidthNow = Screen.PrimaryScreen.WorkingArea.Size.Width;
                    HeightNow = Screen.PrimaryScreen.WorkingArea.Size.Height;

                    this.Location = new Point(0, 0);

                    this.Size = new Size(1080, 720);
                    float WidthRatio = ((float)1080 / (float)WidthNow);
                    float HeightRatio = ((float)720 / (float)HeightNow);
                    this.Scale(new SizeF(WidthRatio, HeightRatio));
                }
            }

Bu işi yapmanın daha güzel bir yolu var mıdır?