تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
تحويل مشروع تكبير الفورم من vb الى #c
#1
السلام عليكم ورحمة الله وبركاته 


يعطيكم العافية لو تكرمتو احتاج تعديل هذا المثال الى #C من VB


هو عبارة عن كلاس واكواد لتكبير الفورم 



لكم مني جزيل الشكر


الملفات المرفقة
.rar   تكبير الفورم.rar (الحجم : 77.12 ك ب / التحميلات : 14)



بكم نرتقي ونسأل الله لنا ولكم التوفيق ،،
الرد }}}
تم الشكر بواسطة:
#2
(24-06-19, 11:02 PM)hglogtd كتب : السلام عليكم ورحمة الله وبركاته 


يعطيكم العافية لو تكرمتو احتاج تعديل هذا المثال الى #C من VB


هو عبارة عن كلاس واكواد لتكبير الفورم 



لكم مني جزيل الشكر

(لست مبرمج #C)

تم تحويل الكود بالاستعانة بموقع Code Converter C# to VB and VB to C# – Telerik

كود :
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;

public class ResizeControls
{
   private Hashtable RatioTable = new Hashtable();

   private float WindowHeight;
   private float WindowWidth;
   private float HeightRatio;
   private float WidthRatio;

   private Control _Container = new Control();

   private static long m_FormWidth;                          // Original form width.
   private static long m_FormHeight;

   public Control Container
   {
       get
       {
           return _Container;
       }
       set
       {
           _Container = Ctrl;
           FullRatioTable();
       }
   }

   private struct SizeRatio
   {
       public float TopRatio;
       public float LeftRatio;
       public float HeightRatio;
       public float WidthRatio;
   }

   private void FullRatioTable()
   {
       WindowHeight = _Container.Height;
       WindowWidth = _Container.Width;
       RatioTable = new Hashtable();
       AddChildrenToTable(ref _Container);
   }

   private void AddChildrenToTable(ref Control ChildContainer)
   {
       SizeRatio R = new SizeRatio();

       foreach (Control C in ChildContainer.Controls)
       {
           {
               var withBlock = C;
               R.TopRatio = System.Convert.ToSingle(withBlock.Top / (double)WindowHeight);
               R.LeftRatio = System.Convert.ToSingle(withBlock.Left / (double)WindowWidth);
               R.HeightRatio = System.Convert.ToSingle(withBlock.Height / (double)WindowHeight);
               R.WidthRatio = System.Convert.ToSingle(withBlock.Width / (double)WindowWidth);
               RatioTable(withBlock.Name) = R;
               if (withBlock.HasChildren)
                   AddChildrenToTable(ref C);
           }
       }
   }

   public void ResizeControls()
   {
       HeightRatio = System.Convert.ToSingle(_Container.Height / (double)WindowHeight);
       WidthRatio = System.Convert.ToSingle(_Container.Width / (double)WindowWidth);

       WindowHeight = _Container.Height;
       WindowWidth = _Container.Width;

       ResizeChildren(ref _Container);
   }

   private void ResizeChildren(ref Control ChildContainer)
   {
       SizeRatio R = new SizeRatio();
       foreach (Control C in ChildContainer.Controls)
       {
           {
               var withBlock = C;
               R = (SizeRatio)RatioTable(withBlock.Name);
               withBlock.Top = System.Convert.ToInt32(WindowHeight * R.TopRatio);
               withBlock.Left = System.Convert.ToInt32(WindowWidth * R.LeftRatio);
               withBlock.Height = System.Convert.ToInt32(WindowHeight * R.HeightRatio);
               withBlock.Width = System.Convert.ToInt32(WindowWidth * R.WidthRatio);

               if (withBlock.HasChildren)
                   ResizeChildren(ref C);
           }


           switch (true)
           {
               case object _ when C is ListBox:
                   {
                       ListBox L = new ListBox();
                       L = (ListBox)C;
                       L.IntegralHeight = false;
                       break;
                   }
           }

           ResizeControlFont(ref C, WidthRatio, HeightRatio);
       }
   }

   public static void SubResize(Form F, float percentW, float percentH)
   {
       long FormHeight;
       long FormWidth;
       float HeightChange;
       float WidthChange;


       FormHeight = Int((Screen.PrimaryScreen.WorkingArea.Height) * (percentH / (double)100));
       FormWidth = Int((Screen.PrimaryScreen.WorkingArea.Width) * (percentW / (double)100));

       {
           var withBlock = F;
           withBlock.Height = FormHeight;
           withBlock.Width = FormWidth;

           HeightChange = withBlock.ClientSize.Height / (double)m_FormHeight;
           WidthChange = withBlock.ClientSize.Width / (double)m_FormWidth;
       }
   }



   private void ResizeControlFont(ref Control Ctrl, float RatioW, float RatioH)
   {
       float FSize = Ctrl.Font.Size;
       FontStyle FStyle = Ctrl.Font.Style;
       string FNome = Ctrl.Font.Name;
       float NewSize = FSize;

       NewSize = System.Convert.ToSingle(FSize * Math.Sqrt(RatioW * RatioH));
       Font NFont = new Font(FNome, System.Convert.ToSingle(NewSize), FStyle);
       Ctrl.Font = NFont;
   }
}
الرد }}}
تم الشكر بواسطة: hglogtd , asemshahen5
#3
الله يعطيك العافيه



بكم نرتقي ونسأل الله لنا ولكم التوفيق ،،
الرد }}}
تم الشكر بواسطة: wared
#4
عملت له تحويل مثل ما عملت انت لكن اعطاني اخطاء كثيرة



بكم نرتقي ونسأل الله لنا ولكم التوفيق ،،
الرد }}}
تم الشكر بواسطة: wared
#5
(25-06-19, 03:17 AM)hglogtd كتب : عملت له تحويل مثل ما عملت انت لكن اعطاني اخطاء كثيرة

(لست مبرمج #C)

يمكنك تحويل كلاس VB.NET هذا إلى مكتبة DLL عن طريق مشروع Class Library في VB.NET،
ومن ثم إدراجه واستدعائه في مشروع #C
الرد }}}
تم الشكر بواسطة: Rabeea Qbaha , hglogtd


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
Star [سؤال] مشكلة في السحب والأفلات داخل الفورم عند التصميم reduouo 1 100 02-03-24, 02:39 AM
آخر رد: Taha Okla
  [سؤال] احتاج الى مساعدة فى تعديل مشروع خاص C# وقاعدة البيانات SQL Server كتكوت المصري 1 497 15-08-23, 02:02 AM
آخر رد: WAEL ABED
  استفسار في كود غلق الفورم Ahmedelesawy 2 589 19-06-23, 09:25 PM
آخر رد: Ahmedelesawy
  [C#.NET] تحويل كود ahmed_king2023 2 525 06-06-23, 09:44 AM
آخر رد: fouadhdfouad
  [VB.NET] تحويل كود ahmed_king2023 6 813 22-04-23, 11:30 PM
آخر رد: ahmed_king2023
  [C#.NET] تحويل كود الي c# ali_ahmed12 2 501 10-01-23, 03:02 PM
آخر رد: ali_ahmed12
  [سؤال] السلام عليكم انا طالبة مشروع ولدي استفسار dodejogdam 1 491 28-12-22, 11:18 AM
آخر رد: Taha Okla
  [C#.NET] تحويل كود الي c# ali_ahmed12 2 654 03-12-22, 03:52 PM
آخر رد: ali_ahmed12
  [VB.NET] تحويل كود الي c# ali_ahmed12 5 867 30-11-22, 07:32 PM
آخر رد: ali_ahmed12
  [VB.NET] تحويل كود الي c# ali_ahmed12 0 456 29-11-22, 06:30 PM
آخر رد: ali_ahmed12

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


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم