تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
تغير حجم نوافذ برنامج عندما تتغير دقة عرض الشاشة screen resolution
#1
لتنفيذ هذه الطريقة في لغة C#، سنقوم بتحويل الخطوات إلى مشروع C# باستخدام WinForms. هذا سيتضمن كتابة فئات ووظائف مشابهة لتلك التي في VB6. فيما يلي شرح لكيفية تنفيذ هذه الطريقة:

إنشاء مشروع جديد في Visual Studio:

افتح Visual Studio وأنشئ مشروع جديد من نوع "Windows Forms App (.NET Framework)".
إضافة كود Module (في C# ستكون كلاس):

أضف كلاس جديد للمشروع وقم بتسميته FormControl. في هذا الكلاس، سنقوم بتعريف المتغيرات والإجراءات اللازمة.
تعريف المتغيرات:

في الكلاس FormControl، سنقوم بتعريف المتغيرات اللازمة كالتالي:

PHP كود :
using System;
using System.Collections.Generic;
using System.Windows.Forms;

public class 
FormControl
{
 
   private List<ControlPropertiescontrolList = new List<ControlProperties>();
 
   private int originalFormHeight;
 
   private int originalFormWidth;
 
   private double x_ratio;
 
   private double y_ratio;

 
   private class ControlProperties
    
{
 
       public int Index getset; }
 
       public string Name getset; }
 
       public int Left getset; }
 
       public int Top getset; }
 
       public int Width getset; }
 
       public int Height getset; }
 
   }

 
   public void ResizeForm(Form frm)
 
   {
 
       frm.Height Screen.PrimaryScreen.Bounds.Height 2;
 
       frm.Width Screen.PrimaryScreen.Bounds.Width 2;
 
   }

 
   public void ResizeControls(Form frm)
 
   {
 
       x_ratio = (double)frm.Height originalFormHeight;
 
       y_ratio = (double)frm.Width originalFormWidth;

 
       foreach (Control ctrl in frm.Controls)
 
       {
 
           var properties controlList.Find(=> p.Name == ctrl.Name);
 
           if (properties != null)
 
           {
 
               ctrl.Left = (int)(properties.Left y_ratio);
 
               ctrl.Width = (int)(properties.Width y_ratio);
 
               ctrl.Height = (int)(properties.Height x_ratio);
 
               ctrl.Top = (int)(properties.Top x_ratio);
 
           }
 
       }
 
   }

 
   public void GetLocation(Form frm)
 
   {
 
       controlList.Clear();
 
       foreach (Control ctrl in frm.Controls)
 
       {
 
           controlList.Add(new ControlProperties
            
{
 
               Name ctrl.Name,
 
               Index ctrl.TabIndex,
 
               Left ctrl.Left,
 
               Top ctrl.Top,
 
               Width ctrl.Width,
 
               Height ctrl.Height
            
});
 
       }

 
       originalFormHeight frm.Height;
 
       originalFormWidth frm.Width;
 
   }

 
   public int SetFontSize()
 
   {
 
       if (x_ratio 0)
 
       {
 
           return (int)(x_ratio 8);
 
       }
 
       return 8;
 
   }



PHP كود :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 
screen_result
{
 
   public partial class Form1 Form
    
{
 
       private FormControl formControl;

 
       public Form1()
 
       {
 
           InitializeComponent();
 
           formControl = new FormControl();
 
       }

 
       private void Form1_Load(object senderEventArgs e)
 
       {
 
           formControl.GetLocation(this);
 
           formControl.ResizeForm(this);

 
           foreach (Control ctrl in this.Controls)
 
           {
 
               ctrl.Font = new Font(ctrl.Font.FontFamilyformControl.SetFontSize());
 
           }
 
       }

 
       private void Form1_Resize(object senderEventArgs e)
 
       {
 
           formControl.ResizeControls(this);

 
           foreach (Control ctrl in this.Controls)
 
           {
 
               ctrl.Font = new Font(ctrl.Font.FontFamilyformControl.SetFontSize());
 
           }
 
       }
 
   }

ويصبح بإمكانك تغيير حجم النافذة وعناصر التحكم بشكل ديناميكي استنادًا إلى دقة عرض الشاشة.


الملفات المرفقة
.rar   screen result.rar (الحجم : 43.84 ك ب / التحميلات : 88)
غَزة شجرة سنديان لا تنحني، ووردة لا تذبل، وشوكة عصية على الكسر. غزة، دماؤها تنتصر على السيف والسياف.
متغيب لفترة ان اخطأت بحق احد ارجو المسامحة
الرد }}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  انشاء برنامج تشغيل الفيديو غزة العزة 1 754 08-11-24, 02:04 PM
آخر رد: ba2e44ca9a
  برنامج لقفل والغاء قفل واخفاء الملفات مصمم ب #C غزة العزة 1 614 25-10-24, 09:08 PM
آخر رد: mary
  عمل برنامج داونلود من الانترنت من قناة فوكس لارن . asemshahen5 2 2,864 25-08-24, 08:09 PM
آخر رد: ba2e44ca9a
Heart [مشروع] النسخة السابعة من برنامج استخراج مكتبة برمجية لاي قاعدة بيانات Sqlite 3 ربيع الهمداني 3 3,324 07-07-24, 06:13 PM
آخر رد: salamandal
  محتاج مساعده فى برنامج بسيط لادخال واضافة وتعديل بيانات بسيطهc# vba ُعزت 0 417 13-05-24, 11:53 AM
آخر رد: ُعزت
  [VB.NET] اريد سورس كود برنامج لادارة محلات الصرافة و تحويل العملات sher 0 1,132 11-11-23, 07:32 PM
آخر رد: sher
  [مشروع] برنامج تذةيد متابعين vipmasr 0 1,085 29-01-23, 05:48 AM
آخر رد: vipmasr
Star [مشروع] سورس كود || برنامج إدارة المبيعات islamf3thy 35 39,596 25-04-22, 12:37 PM
آخر رد: كريم الفقى
  [C#.NET] برنامج عياددة hassan desoky 1 2,618 17-01-22, 02:44 PM
آخر رد: الماجيك مسعد
  برنامج اعادة تحجيم الصور ابراهيم ايبو 3 3,669 07-08-21, 02:15 PM
آخر رد: devante.celvin

التنقل السريع :


يقوم بقرائة الموضوع: