تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[C#.NET] كيفية عمل مثل هذا التضليل لاكثر من سطر فى برنامج ايات
#17
قد فكرت فى طريقة وهى ان اجعل لكل صفحة كلاس خاص بة من اليبل 
كود :
 var p = new Page_1(Page);
                       p.eMouseLeave += this.LBL_S1_A6_2_MouseLeave;
                       p.eMouseClick += this.LBL_S1_A1_MouseClick;
                       p.eMouseHover += this.LBL_S1_A6_2_MouseHover;
كود :
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuranLibrary.ClassPages
{
   public delegate void dMouseLeave(object sender, EventArgs e);
    public delegate void dMouseHover(object sender, EventArgs e);
    public delegate void dMouseClick(object sender, MouseEventArgs e);
   public class Page_1 : Panel
   {
       public Color ColorMouseHover = Color.FromArgb(70, 185, 215, 252);
       public Color ColorMouseLeave = Color.FromArgb(0, 255, 255, 255);

       public event dMouseLeave eMouseLeave = null;
       public event dMouseHover eMouseHover = null;
       public event dMouseClick eMouseClick = null;
       private Label Page1_S0_A0;
     
       private Label Page1_S0_A1;
       private Label Page1_S0_A5_2;
       private Label Page1_S0_A5_1;
       private Label Page1_S0_A4;
       private Label Page1_S0_A3;
       private Label Page1_S0_A2;
       private Label Page1_S0_A6_3;
       private Label Page1_S0_A6_2;
       private Label Page1_S0_A6_1;
       public Page_1 (int  ImageNum1)
       {
           this.Page1_S0_A5_2 = new  Label();
           this.Page1_S0_A5_1 = new  Label();
           this.Page1_S0_A4 = new  Label();
           this.Page1_S0_A3 = new  Label();
           this.Page1_S0_A2 = new  Label();
           this.Page1_S0_A1 = new  Label();
           this.Page1_S0_A0 = new  Label();
           this.Page1_S0_A6_1 = new  Label();
           this.Page1_S0_A6_2 = new  Label();
           this.Page1_S0_A6_3 = new  Label();
           // panel1
           //
           this.BackgroundImage = Image.FromFile(Application.StartupPath + string.Format("\\images\\{0}.PNG", ImageNum1));
           this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
           this.Controls.Add(this.Page1_S0_A6_3);
           this.Controls.Add(this.Page1_S0_A6_2);
           this.Controls.Add(this.Page1_S0_A6_1);
           this.Controls.Add(this.Page1_S0_A5_2);
           this.Controls.Add(this.Page1_S0_A5_1);
           this.Controls.Add(this.Page1_S0_A4);
           this.Controls.Add(this.Page1_S0_A3);
           this.Controls.Add(this.Page1_S0_A2);
           this.Controls.Add(this.Page1_S0_A1);
           this.Controls.Add(this.Page1_S0_A0);
           this.AutoScroll = true;
           this.Dock = System.Windows.Forms.DockStyle.Fill;
           this.Location = new System.Drawing.Point(0, 0);
           this.Size = new System.Drawing.Size(462, 673);
           this.Name = "Page_1";
           this.TabIndex = 0;
           //
           // Page1_S1_A7_3
           //
           this.Page1_S0_A6_3.BackColor = System.Drawing.Color.Transparent;
           this.Page1_S0_A6_3.Location = new System.Drawing.Point(186, 446);
           this.Page1_S0_A6_3.Name = "Page1_S0_A6_3";
           this.Page1_S0_A6_3.Size = new System.Drawing.Size(93, 21);
           this.Page1_S0_A6_3.TabIndex = 9;
           this.Page1_S0_A6_3.Text = " ";
           this.Page1_S0_A6_3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
           this.Page1_S0_A6_3.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Page1_S1_A7_3_Click);
           this.Page1_S0_A6_3.MouseLeave += new System.EventHandler(this.label1_MouseLeave);
           this.Page1_S0_A6_3.MouseHover += new System.EventHandler(this.label1_MouseHover);
           //
           // Page1_S1_A7_2
           //
           this.Page1_S0_A6_2.BackColor = System.Drawing.Color.Transparent;
           this.Page1_S0_A6_2.Location = new System.Drawing.Point(155, 421);
           this.Page1_S0_A6_2.Name = "Page1_S0_A6_2";
           this.Page1_S0_A6_2.Size = new System.Drawing.Size(149, 21);
           this.Page1_S0_A6_2.TabIndex = 8;
           this.Page1_S0_A6_2.Text = " ";
           this.Page1_S0_A6_2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
           this.Page1_S0_A6_2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Page1_S1_A7_3_Click);
           this.Page1_S0_A6_2.MouseLeave += new System.EventHandler(this.label1_MouseLeave);
           this.Page1_S0_A6_2.MouseHover += new System.EventHandler(this.label1_MouseHover);
           //
           // Page1_S1_A7_1
           //
           this.Page1_S0_A6_1.BackColor = System.Drawing.Color.Transparent;
           this.Page1_S0_A6_1.Location = new System.Drawing.Point(125, 397);
           this.Page1_S0_A6_1.Name = "Page1_S0_A6_1";
           this.Page1_S0_A6_1.Size = new System.Drawing.Size(93, 21);
           this.Page1_S0_A6_1.TabIndex = 7;
           this.Page1_S0_A6_1.Text = " ";
           this.Page1_S0_A6_1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
           this.Page1_S0_A6_1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Page1_S1_A7_3_Click);
           this.Page1_S0_A6_1.MouseLeave += new System.EventHandler(this.label1_MouseLeave);
           this.Page1_S0_A6_1.MouseHover += new System.EventHandler(this.label1_MouseHover);
           //
           // Page1_S1_A6_2
           //
           this.Page1_S0_A5_2.BackColor = System.Drawing.Color.Transparent;
           this.Page1_S0_A5_2.Location = new System.Drawing.Point(233, 397);
           this.Page1_S0_A5_2.Name = "Page1_S0_A5_2";
           this.Page1_S0_A5_2.Size = new System.Drawing.Size(93, 21);
           this.Page1_S0_A5_2.TabIndex = 6;
           this.Page1_S0_A5_2.Text = " ";
           this.Page1_S0_A5_2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
           this.Page1_S0_A5_2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Page1_S1_A7_3_Click);
           this.Page1_S0_A5_2.MouseLeave += new System.EventHandler(this.label1_MouseLeave);
           this.Page1_S0_A5_2.MouseHover += new System.EventHandler(this.label1_MouseHover);
           //
           // Page1_S1_A6_1
           //
           this.Page1_S0_A5_1.BackColor = System.Drawing.Color.Transparent;
           this.Page1_S0_A5_1.Location = new System.Drawing.Point(115, 368);
           this.Page1_S0_A5_1.Name = "Page1_S0_A5_1";
           this.Page1_S0_A5_1.Size = new System.Drawing.Size(48, 21);
           this.Page1_S0_A5_1.TabIndex = 5;
           this.Page1_S0_A5_1.Text = " ";
           this.Page1_S0_A5_1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
           this.Page1_S0_A5_1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Page1_S1_A7_3_Click);
           this.Page1_S0_A5_1.MouseLeave += new System.EventHandler(this.label1_MouseLeave);
           this.Page1_S0_A5_1.MouseHover += new System.EventHandler(this.label1_MouseHover);
           //
           // Page1_S1_A5
           //
           this.Page1_S0_A4.BackColor = System.Drawing.Color.Transparent;
           this.Page1_S0_A4.Location = new System.Drawing.Point(164, 368);
           this.Page1_S0_A4.Name = "Page1_S0_A4";
           this.Page1_S0_A4.Size = new System.Drawing.Size(174, 21);
           this.Page1_S0_A4.TabIndex = 4;
           this.Page1_S0_A4.Text = " ";
           this.Page1_S0_A4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
           this.Page1_S0_A4.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Page1_S1_A7_3_Click);
           this.Page1_S0_A4.MouseLeave += new System.EventHandler(this.label1_MouseLeave);
           this.Page1_S0_A4.MouseHover += new System.EventHandler(this.label1_MouseHover);
           //
           // Page1_S1_A4
           //
           this.Page1_S0_A3.BackColor = System.Drawing.Color.Transparent;
           this.Page1_S0_A3.Location = new System.Drawing.Point(118, 340);
           this.Page1_S0_A3.Name = "Page1_S0_A3";
           this.Page1_S0_A3.Size = new System.Drawing.Size(111, 21);
           this.Page1_S0_A3.TabIndex = 3;
           this.Page1_S0_A3.Text = " ";
           this.Page1_S0_A3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
           this.Page1_S0_A3.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Page1_S1_A7_3_Click);
           this.Page1_S0_A3.MouseLeave += new System.EventHandler(this.label1_MouseLeave);
           this.Page1_S0_A3.MouseHover += new System.EventHandler(this.label1_MouseHover);
           //
           // Page1_S1_A3
           //
           this.Page1_S0_A2.BackColor = System.Drawing.Color.Transparent;
           this.Page1_S0_A2.Location = new System.Drawing.Point(236, 340);
           this.Page1_S0_A2.Name = "Page1_S0_A2";
           this.Page1_S0_A2.Size = new System.Drawing.Size(93, 21);
           this.Page1_S0_A2.TabIndex = 2;
           this.Page1_S0_A2.Text = " ";
           this.Page1_S0_A2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
           this.Page1_S0_A2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Page1_S1_A7_3_Click);
           this.Page1_S0_A2.MouseLeave += new System.EventHandler(this.label1_MouseLeave);
           this.Page1_S0_A2.MouseHover += new System.EventHandler(this.label1_MouseHover);
           //
           // Page1_S1_A2
           //
           this.Page1_S0_A1.BackColor = System.Drawing.Color.Transparent;
           this.Page1_S0_A1.Location = new System.Drawing.Point(144, 317);
           this.Page1_S0_A1.Name = "Page1_S0_A1";
           this.Page1_S0_A1.Size = new System.Drawing.Size(166, 21);
           this.Page1_S0_A1.TabIndex = 1;
           this.Page1_S0_A1.Text = " ";
           this.Page1_S0_A1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
           this.Page1_S0_A1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Page1_S1_A7_3_Click);
           this.Page1_S0_A1.MouseLeave += new System.EventHandler(this.label1_MouseLeave);
           this.Page1_S0_A1.MouseHover += new System.EventHandler(this.label1_MouseHover);
           //
           // Page1_S1_A1
           //
           this.Page1_S0_A0.BackColor = System.Drawing.Color.Transparent;
           this.Page1_S0_A0.Location = new System.Drawing.Point(161, 288);
           this.Page1_S0_A0.Name = "Page1_S0_A0";
           this.Page1_S0_A0.Size = new System.Drawing.Size(141, 21);
           this.Page1_S0_A0.TabIndex = 0;
           this.Page1_S0_A0.Text = " ";
           this.Page1_S0_A0.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
           this.Page1_S0_A0.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Page1_S1_A7_3_Click);
           this.Page1_S0_A0.MouseLeave += new System.EventHandler(this.label1_MouseLeave);
           this.Page1_S0_A0.MouseHover += new System.EventHandler(this.label1_MouseHover);
           //
       }
       private void label1_MouseHover(object sender, EventArgs e)
       {
           if (eMouseHover != null) eMouseHover(sender, e);
           Label lb = (Label)sender;
           //if (lb.Name == "Page1_S1_A1")
           //    Page1_S0_A1.BackColor = ColorMouseHover;
           //if (lb.Name == "Page1_S1_A2")
           //    Page1_S0_A2.BackColor = ColorMouseHover;
           //if (lb.Name == "Page1_S1_A3")
           //    Page1_S0_A3.BackColor = ColorMouseHover;
           //if (lb.Name == "Page1_S1_A4")
           //    Page1_S0_A4.BackColor = ColorMouseHover;
           //if (lb.Name == "Page1_S1_A5")
           //    Page1_S0_A5.BackColor = ColorMouseHover;
           if (lb.Name == "Page1_S0_A5_1")
           {
               Page1_S0_A5_1.BackColor = ColorMouseHover;
               Page1_S0_A5_2.BackColor = ColorMouseHover;

           }
           if (lb.Name == "Page1_S0_A6_1")
           {
               Page1_S0_A6_1.BackColor = ColorMouseHover;
               Page1_S0_A6_2.BackColor = ColorMouseHover;
               Page1_S0_A6_3.BackColor = ColorMouseHover;

           }
       }

       private void label1_MouseLeave(object sender, EventArgs e)
       {
           Label lb = (Label)sender;
           if (eMouseLeave != null) eMouseLeave(sender, e);
           //if (lb.Name == "Page1_S1_A1")
           //    Page1_S1_A1.BackColor = ColorMouseLeave;
           //if (lb.Name == "Page1_S1_A2")
           //    Page1_S0_A2.BackColor = ColorMouseLeave;
           //if (lb.Name == "Page1_S1_A3")
           //    Page1_S0_A3.BackColor = ColorMouseLeave;
           //if (lb.Name == "Page1_S1_A4")
           //    Page1_S0_A4.BackColor = ColorMouseLeave;
           //if (lb.Name == "Page1_S1_A5")
           //    Page1_S0_A5.BackColor = ColorMouseLeave;
           if (lb.Name == "Page1_S0_A5_1")
           {
               Page1_S0_A5_1.BackColor = ColorMouseLeave;
               Page1_S0_A5_2.BackColor = ColorMouseLeave;

           } if (lb.Name == "Page1_S0_A6_1")
           {
               Page1_S0_A6_1.BackColor = ColorMouseLeave;
               Page1_S0_A6_2.BackColor = ColorMouseLeave;
               Page1_S0_A6_3.BackColor = ColorMouseLeave;

           }
       }
       private void Page1_S1_A7_3_Click(object sender, MouseEventArgs e)
       {
           if (eMouseClick != null) eMouseClick(sender, e);

       }
       
   }
}
ولكن المشكلة هى كيف استدعى فى كل مرة هذة الكلاس من دون استخدام قاعدة IF او قادة switch


كل ما اريدة الان ان اجد طريقة لستدعاء الكلاس برقم الصفحة  

يعنى الصفحة رقم واحد 

كود :
  var sName = string.Format("Page_{0}", Page);


                       var p = new sName (Page);
                       p.eMouseLeave += this.LBL_S1_A6_2_MouseLeave;
                       p.eMouseClick += this.LBL_S1_A1_MouseClick;
                       p.eMouseHover += this.LBL_S1_A6_2_MouseHover;
اخذ رقم اصفحة وادمجة مع جزء من اسم الكلاس فاستدعى الكلاس المطلوب 

لان المصحف 604 صفحة لن ينفع قاعدة IF او قادة switch 

ارجوا الرد
الرد }}}
تم الشكر بواسطة: elgokr , elgokr


الردود في هذا الموضوع
RE: كيفية عمل مثل هذا التضليل لاكثر من سطر فى برنامج ايات - بواسطة abdalamask - 05-10-18, 02:04 PM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  [كورس] استفسار عن برنامج مطاعم remonmary 2 1,995 25-08-24, 08:06 PM
آخر رد: ba2e44ca9a
  [C#.NET] مشكل يخص قراءة التقارير في برنامج aziz-ouali 0 560 08-12-23, 06:25 AM
آخر رد: aziz-ouali
  [SQL] كيفية اضافة الارقام العربيه وخزنها في sql TITOMOH 1 898 12-12-22, 05:20 PM
آخر رد: mowza
  كيفية تثبيت الخطوط عند المستخدم بمجرد تنزيل البرنامج osama623 1 1,081 18-11-22, 02:07 PM
آخر رد: alfaiz678
  مشكلة في نشر برنامج يعتمد على ملف txt osama623 2 1,014 17-11-22, 08:53 PM
آخر رد: osama623
  كيفية قراءة وعرض ملفات pdf مخزنة في داتا كرد فيو من خلال زر بتن وبدون open file dialo مرتضى 0 838 31-10-22, 12:53 AM
آخر رد: مرتضى
  مشكلة في نشر برنامج يعتمد على الـ Selenium osama623 0 749 21-09-22, 11:26 PM
آخر رد: osama623
  كيفية التقاط الباركود من الزجاج الأمامي للسيارة من خلال كاميرا من c # abdalamask 0 913 11-09-22, 09:27 PM
آخر رد: abdalamask
  كيفية ضبط مقاس دقة الشاشة للمشروع بلغة السي شارب صبري بامرحول 1 1,676 01-05-22, 03:09 AM
آخر رد: سعود
  مساعدة في برنامج سكنر عدنان الشمري 4 3,665 18-02-22, 03:40 AM
آخر رد: adminh1

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


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